SAF
Loading...
Searching...
No Matches
ambi_drc.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-2018 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
50#ifndef __AMBI_DRC_H_INCLUDED__
51#define __AMBI_DRC_H_INCLUDED__
52
53#include "_common.h"
54
55#ifdef __cplusplus
56extern "C" {
57#endif /* __cplusplus */
58
59#define ENABLE_TF_DISPLAY
61/* ========================================================================== */
62/* Presets + Constants */
63/* ========================================================================== */
64
65#ifdef ENABLE_TF_DISPLAY
67# define AMBI_DRC_NUM_DISPLAY_SECONDS ( 8 )
69# define AMBI_DRC_NUM_DISPLAY_TIME_SLOTS ( (int)(AMBI_DRC_NUM_DISPLAY_SECONDS*48000.0f/(float)128) )
71# define AMBI_DRC_READ_OFFSET ( 200 )
73# define AMBI_DRC_NUM_BANDS ( 133 )
74#endif
76#define AMBI_DRC_SPECTRAL_FLOOR (0.1585f)
77
78#define AMBI_DRC_IN_GAIN_MIN_VAL ( -40.0f )
79#define AMBI_DRC_IN_GAIN_MAX_VAL ( 20.0f )
80#define AMBI_DRC_THRESHOLD_MIN_VAL ( -60.0f )
81#define AMBI_DRC_THRESHOLD_MAX_VAL ( 0.0f )
82#define AMBI_DRC_RATIO_MIN_VAL ( 1.0f )
83#define AMBI_DRC_RATIO_MAX_VAL ( 30.0f )
84#define AMBI_DRC_KNEE_MIN_VAL ( 0.0f )
85#define AMBI_DRC_KNEE_MAX_VAL ( 10.0f )
86#define AMBI_DRC_ATTACK_MIN_VAL ( 10.0f )
87#define AMBI_DRC_ATTACK_MAX_VAL ( 200.0f )
88#define AMBI_DRC_RELEASE_MIN_VAL ( 50.0f )
89#define AMBI_DRC_RELEASE_MAX_VAL ( 1000.0f )
90#define AMBI_DRC_OUT_GAIN_MIN_VAL ( -20.0f )
91#define AMBI_DRC_OUT_GAIN_MAX_VAL ( 40.0f )
94/* ========================================================================== */
95/* Main Functions */
96/* ========================================================================== */
97
103void ambi_drc_create(void** const phAmbi);
104
110void ambi_drc_destroy(void** const phAmbi);
111
118void ambi_drc_init(void* const hAmbi,
119 int samplerate);
120
131void ambi_drc_process(void* const hAmbi,
132 const float *const * inputs,
133 float* const* outputs,
134 int nCH,
135 int nSamples);
136
137
138/* ========================================================================== */
139/* Set Functions */
140/* ========================================================================== */
141
146void ambi_drc_refreshSettings(void* const hAmbi);
147
149void ambi_drc_setThreshold(void* const hAmbi, float newValue);
150
152void ambi_drc_setRatio(void* const hAmbi, float newValue);
153
155void ambi_drc_setKnee(void* const hAmbi, float newValue);
156
158void ambi_drc_setInGain(void* const hAmbi, float newValue);
159
161void ambi_drc_setOutGain(void* const hAmbi, float newValue);
162
164void ambi_drc_setAttack(void* const hAmbi, float newValue);
165
167void ambi_drc_setRelease(void* const hAmbi, float newValue);
168
173void ambi_drc_setChOrder(void* const hAmbi, int newOrder);
174
179void ambi_drc_setNormType(void* const hAmbi, int newType);
180
189void ambi_drc_setInputPreset(void* const hAmbi, SH_ORDERS newPreset);
190
191
192/* ========================================================================== */
193/* Get Functions */
194/* ========================================================================== */
195
200int ambi_drc_getFrameSize(void);
201
206float** ambi_drc_getGainTF(void* const hAmbi);
207
209int ambi_drc_getGainTFwIdx(void* const hAmbi);
210
212int ambi_drc_getGainTFrIdx(void* const hAmbi);
213
215float* ambi_drc_getFreqVector(void* const hAmbi, int* nFreqPoints);
216
218float ambi_drc_getThreshold(void* const hAmbi);
219
221float ambi_drc_getRatio(void* const hAmbi);
222
224float ambi_drc_getKnee(void* const hAmbi);
225
227float ambi_drc_getInGain(void* const hAmbi);
228
230float ambi_drc_getOutGain(void* const hAmbi);
231
233float ambi_drc_getAttack(void* const hAmbi);
234
236float ambi_drc_getRelease(void* const hAmbi);
237
243int ambi_drc_getChOrder(void* const hAmbi);
244
250int ambi_drc_getNormType(void* const hAmbi);
251
253SH_ORDERS ambi_drc_getInputPreset(void* const hAmbi);
254
259int ambi_drc_getNSHrequired(void* const hAmbi);
260
262int ambi_drc_getSamplerate(void* const hAmbi);
263
269
270
271#ifdef __cplusplus
272} /* extern "C" { */
273#endif /* __cplusplus */
274
275#endif /* __AMBI_DRC_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
Definition _common.h:38
void ambi_drc_setKnee(void *const hAmbi, float newValue)
Sets the compressor knee value; 0: hard knee, >0: soft knee, in DECIBELS.
Definition ambi_drc.c:257
void ambi_drc_init(void *const hAmbi, int samplerate)
Initialises an instance of ambi_drc with default settings.
Definition ambi_drc.c:106
int ambi_drc_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
Definition ambi_drc.c:395
float * ambi_drc_getFreqVector(void *const hAmbi, int *nFreqPoints)
Returns the frequency vector used by the processing.
float ** ambi_drc_getGainTF(void *const hAmbi)
Returns pointers to historic time-frequency data, which may be used for plotting purposes.
void ambi_drc_process(void *const hAmbi, const float *const *inputs, float *const *outputs, int nCH, int nSamples)
Applies the frequency-dependent dynamic range compression to the input spherical harmonic signals.
Definition ambi_drc.c:137
int ambi_drc_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
Definition ambi_drc.c:401
float ambi_drc_getThreshold(void *const hAmbi)
Returns the compressor threshold value, in DECIBELS.
Definition ambi_drc.c:353
int ambi_drc_getGainTFwIdx(void *const hAmbi)
Returns current TF gain data write index.
void ambi_drc_destroy(void **const phAmbi)
Destroys an instance of the ambi_drc.
Definition ambi_drc.c:83
void ambi_drc_setChOrder(void *const hAmbi, int newOrder)
Sets the Ambisonic channel ordering convention to decode with, in order to match the convention emplo...
Definition ambi_drc.c:287
void ambi_drc_create(void **const phAmbi)
Creates an instance of the ambi_drc.
Definition ambi_drc.c:44
float ambi_drc_getKnee(void *const hAmbi)
Returns the compressor knee value 0: hard knee, >0: soft knee, in DECIBELS.
Definition ambi_drc.c:365
int ambi_drc_getGainTFrIdx(void *const hAmbi)
Returns current TF gain data read index.
void ambi_drc_setOutGain(void *const hAmbi, float newValue)
Sets the compressor output gain value, in DECIBELS.
Definition ambi_drc.c:269
void ambi_drc_setRelease(void *const hAmbi, float newValue)
Sets the compressor envelope release time, in miliseconds.
Definition ambi_drc.c:281
void ambi_drc_setNormType(void *const hAmbi, int newType)
Sets the Ambisonic normalisation convention to decode with, in order to match with the convention emp...
Definition ambi_drc.c:294
int ambi_drc_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
Definition ambi_drc.c:413
float ambi_drc_getOutGain(void *const hAmbi)
Returns the compressor output gain value, in DECIBELS.
Definition ambi_drc.c:377
void ambi_drc_setRatio(void *const hAmbi, float newValue)
Sets the compression ratio.
Definition ambi_drc.c:251
void ambi_drc_setInputPreset(void *const hAmbi, SH_ORDERS newPreset)
Sets processing order.
Definition ambi_drc.c:301
void ambi_drc_setThreshold(void *const hAmbi, float newValue)
Sets the compressor threshold value in DECIBELS.
Definition ambi_drc.c:245
void ambi_drc_refreshSettings(void *const hAmbi)
Sets all intialisation flags to 1; re-initialising all settings/variables as ambi_drc is currently co...
Definition ambi_drc.c:239
float ambi_drc_getAttack(void *const hAmbi)
Returns the compressor envelope attack time, in miliseconds.
Definition ambi_drc.c:383
int ambi_drc_getProcessingDelay(void)
Returns the processing delay in samples; may be used for delay compensation features.
Definition ambi_drc.c:425
SH_ORDERS ambi_drc_getInputPreset(void *const hAmbi)
Returns the current processing order (see SH_ORDERS enum)
Definition ambi_drc.c:407
float ambi_drc_getRelease(void *const hAmbi)
Returns the compressor envelope release time, in miliseconds.
Definition ambi_drc.c:389
int ambi_drc_getSamplerate(void *const hAmbi)
Returns the DAW/Host sample rate.
Definition ambi_drc.c:419
float ambi_drc_getInGain(void *const hAmbi)
Returns the compressor input gain value, in DECIBELS.
Definition ambi_drc.c:371
void ambi_drc_setAttack(void *const hAmbi, float newValue)
Sets the compressor envelope attack time, in miliseconds.
Definition ambi_drc.c:275
void ambi_drc_setInGain(void *const hAmbi, float newValue)
Sets the compressor input gain value, in DECIBELS.
Definition ambi_drc.c:263
int ambi_drc_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
Definition ambi_drc.c:318
float ambi_drc_getRatio(void *const hAmbi)
Returns the compression ratio.
Definition ambi_drc.c:359