49 *phAmbi = (
void*)pData;
59#ifdef ENABLE_TF_DISPLAY
90 if (pData->
hSTFT != NULL)
95#ifdef ENABLE_TF_DISPLAY
96 free(pData->gainsTF_bank0);
97 free(pData->gainsTF_bank1);
114 pData->
fs = (float)sampleRate;
118#ifdef ENABLE_TF_DISPLAY
139 const float *
const * inputs,
140 float*
const*
const outputs,
147 float xG, yG, xL, yL, cdB, alpha_a, alpha_r;
148 float makeup, boost, theshold, ratio, knee;
160 boost = powf(10.0f, pData->
inGain / 20.0f);
161 makeup = powf(10.0f, pData->
outGain / 20.0f);
163 ratio = pData->
ratio;
172 for(; i<pData->
nSH; i++)
185 for (ch = 0; ch < pData->
nSH; ch++)
189 xG = 10.0f*log10f(powf(cabsf(pData->
inputFrameTF[band][0][t]), 2.0f) + 2e-13f);
193 pData->
yL_z1[band] = yL;
197#ifdef ENABLE_TF_DISPLAY
199 if(pData->storeIdx==0)
200 pData->gainsTF_bank0[band][pData->wIdx] = cdB;
202 pData->gainsTF_bank1[band][pData->wIdx] = cdB;
206 for (ch = 0; ch < pData->
nSH; ch++)
209#ifdef ENABLE_TF_DISPLAY
215 pData->storeIdx = pData->storeIdx == 0 ? 1 : 0;
226 for(ch = 0; ch <
SAF_MIN(pData->
nSH, nCh); ch++)
228 for (; ch < nCh; ch++)
232 for (ch=0; ch < nCh; ch++)
323#ifdef ENABLE_TF_DISPLAY
327 if(pData->storeIdx==0)
328 return pData->gainsTF_bank0;
330 return pData->gainsTF_bank1;
404 return (
int)pData->
norm;
422 return (
int)(pData->
fs+0.5f);
NORM_TYPES
Available Ambisonic normalisation conventions.
@ NORM_SN3D
Schmidt semi-normalisation (SN3D)
@ NORM_FUMA
(Legacy) Furse-Malham scaling
CH_ORDER
Available Ambisonic channel ordering conventions.
@ CH_ACN
Ambisonic Channel Numbering (ACN)
@ CH_FUMA
(Legacy) Furse-Malham/B-format (WXYZ)
#define MAX_NUM_SH_SIGNALS
Maximum number of spherical harmonic components/signals supported.
SH_ORDERS
Available spherical harmonic (SH) input/output order options.
@ SH_ORDER_FIRST
First-order (4 channels)
void afSTFT_backward_knownDimensions(void *const hSTFT, float_complex ***dataFD, int framesize, int dataFD_nCH, int dataFD_nHops, float **dataTD)
Performs backward afSTFT transform (dataFD dimensions are known)
void afSTFT_forward_knownDimensions(void *const hSTFT, float **dataTD, int framesize, int dataFD_nCH, int dataFD_nHops, float_complex ***dataFD)
Performs forward afSTFT transform (dataFD dimensions are known)
void afSTFT_getCentreFreqs(void *const hSTFT, float fs, int nBands, float *freqVector)
Returns current frequency vector.
void afSTFT_destroy(void **const phSTFT)
Destroys an instance of afSTFT.
#define TIME_SLOTS
Number of STFT timeslots.
#define HOP_SIZE
STFT hop size.
#define HYBRID_BANDS
Number of frequency bands.
void ambi_drc_setKnee(void *const hAmbi, float newValue)
Sets the compressor knee value; 0: hard knee, >0: soft knee, in DECIBELS.
void ambi_drc_init(void *const hAmbi, int sampleRate)
Initialises an instance of ambi_drc with default settings.
int ambi_drc_getChOrder(void *const hAmbi)
Returns the Ambisonic channel ordering convention currently being used to decode with,...
int ambi_drc_getNormType(void *const hAmbi)
Returns the Ambisonic normalisation convention currently being usedto decode with,...
int ambi_drc_getProcessingDelay()
Returns the processing delay in samples; may be used for delay compensation features.
float ambi_drc_getThreshold(void *const hAmbi)
Returns the compressor threshold value, in DECIBELS.
void ambi_drc_destroy(void **const phAmbi)
Destroys an instance of the ambi_drc.
void ambi_drc_process(void *const hAmbi, const float *const *inputs, float *const *const outputs, int nCh, int nSamples)
Applies the frequency-dependent dynamic range compression to the input spherical harmonic signals.
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...
void ambi_drc_create(void **const phAmbi)
Creates an instance of the ambi_drc.
float ambi_drc_getKnee(void *const hAmbi)
Returns the compressor knee value 0: hard knee, >0: soft knee, in DECIBELS.
void ambi_drc_setOutGain(void *const hAmbi, float newValue)
Sets the compressor output gain value, in DECIBELS.
void ambi_drc_setRelease(void *const hAmbi, float newValue)
Sets the compressor envelope release time, in miliseconds.
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...
int ambi_drc_getNSHrequired(void *const hAmbi)
Returns the number of spherical harmonic signals required by the current decoding order: (current_ord...
float ambi_drc_getOutGain(void *const hAmbi)
Returns the compressor output gain value, in DECIBELS.
void ambi_drc_setRatio(void *const hAmbi, float newValue)
Sets the compression ratio.
void ambi_drc_setInputPreset(void *const hAmbi, SH_ORDERS newPreset)
Sets processing order.
void ambi_drc_setThreshold(void *const hAmbi, float newValue)
Sets the compressor threshold value in DECIBELS.
void ambi_drc_refreshSettings(void *const hAmbi)
Sets all intialisation flags to 1; re-initialising all settings/variables as ambi_drc is currently co...
float ambi_drc_getAttack(void *const hAmbi)
Returns the compressor envelope attack time, in miliseconds.
SH_ORDERS ambi_drc_getInputPreset(void *const hAmbi)
Returns the current processing order (see SH_ORDERS enum)
float ambi_drc_getRelease(void *const hAmbi)
Returns the compressor envelope release time, in miliseconds.
int ambi_drc_getSamplerate(void *const hAmbi)
Returns the DAW/Host sample rate.
float ambi_drc_getInGain(void *const hAmbi)
Returns the compressor input gain value, in DECIBELS.
void ambi_drc_setAttack(void *const hAmbi, float newValue)
Sets the compressor envelope attack time, in miliseconds.
void ambi_drc_setInGain(void *const hAmbi, float newValue)
Sets the compressor input gain value, in DECIBELS.
int ambi_drc_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
float ambi_drc_getRatio(void *const hAmbi)
Returns the compression ratio.
A frequency-dependent Ambisonic sound scene dynamic range compressor (DRC)
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.
#define AMBI_DRC_THRESHOLD_MIN_VAL
Minimum threshold, dB.
#define AMBI_DRC_NUM_DISPLAY_TIME_SLOTS
Number of time slots of historic TF data.
#define AMBI_DRC_OUT_GAIN_MAX_VAL
Maximum output gain, dB.
#define AMBI_DRC_IN_GAIN_MAX_VAL
Maximum input gain, dB.
#define AMBI_DRC_KNEE_MIN_VAL
Minimum knee, dB.
#define AMBI_DRC_ATTACK_MIN_VAL
Minimum attack time, ms.
int ambi_drc_getGainTFwIdx(void *const hAmbi)
Returns current TF gain data write index.
int ambi_drc_getGainTFrIdx(void *const hAmbi)
Returns current TF gain data read index.
#define AMBI_DRC_THRESHOLD_MAX_VAL
Maximum threshold, dB.
#define AMBI_DRC_ATTACK_MAX_VAL
Maximum attack time, ms.
#define AMBI_DRC_IN_GAIN_MIN_VAL
Minimum input gain, dB.
#define AMBI_DRC_RELEASE_MIN_VAL
Minimum release time, ms.
#define AMBI_DRC_SPECTRAL_FLOOR
-16dB, maximum gain reduction for a given frequency band
#define AMBI_DRC_KNEE_MAX_VAL
Maximum knee, dB.
#define AMBI_DRC_RATIO_MIN_VAL
Minimum ratio, X:1.
#define AMBI_DRC_RELEASE_MAX_VAL
Maximum release time, ms.
#define AMBI_DRC_RATIO_MAX_VAL
Maximum ratio, X:1.
#define AMBI_DRC_OUT_GAIN_MIN_VAL
Minimum output gain, dB.
void ambi_drc_setInputOrder(SH_ORDERS inOrder, int *nSH)
Sets the internal input order.
float ambi_drc_gainComputer(float xG, float T, float R, float W)
The DRC gain computer.
void ambi_drc_initTFT(void *const hAmbi)
Initialise the filterbank used by ambi_drc.
float ambi_drc_smoothPeakDetector(float xL, float yL_z1, float alpha_a, float alpha_r)
The envelope detector.
A frequency-dependent Ambisonic sound scene dynamic range compressor (DRC)
#define AMBI_DRC_FRAME_SIZE
Framesize, in time-domain samples.
#define SAF_CLAMP(a, min, max)
Ensures value "a" is clamped between the "min" and "max" values.
#define SAF_MAX(a, b)
Returns the maximum of the two values.
void utility_svvcopy(const float *a, const int len, float *c)
Single-precision, vector-vector copy, i.e.
#define SAF_MIN(a, b)
Returns the minimum of the two values.
void ** malloc2d(size_t dim1, size_t dim2, size_t data_size)
2-D malloc (contiguously allocated, so use free() as usual to deallocate)
void * malloc1d(size_t dim1_data_size)
1-D malloc (same as malloc, but with error checking)
void *** malloc3d(size_t dim1, size_t dim2, size_t dim3, size_t data_size)
3-D malloc (contiguously allocated, so use free() as usual to deallocate)
Main structure for ambi_drc.
float ratio
Compression ratio.
float attack_ms
Attack time, in ms.
float knee
Knee width, in dB.
NORM_TYPES norm
Ambisonic normalisation convention (see NORM_TYPES)
int reInitTFT
0: no init required, 1: init required, 2: init in progress
SH_ORDERS currentOrder
Current input SH order.
void * hSTFT
Time-frequency transform handle.
float yL_z1[HYBRID_BANDS]
Delay elements.
float ** frameTD
Input/output SH signals, in the time-domain; MAX_NUM_SH_SIGNALS x AMBI_DRC_FRAME_SIZE.
float_complex *** inputFrameTF
Input SH signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS.
float freqVector[HYBRID_BANDS]
Frequency vector.
CH_ORDER chOrdering
Ambisonic channel order convention (see CH_ORDER)
float theshold
Threshold parameter, in dB.
float_complex *** outputFrameTF
Output SH signals, in the time-frequency domain; HYBRID_BANDS x MAX_NUM_SH_SIGNALS x TIME_SLOTS.
float outGain
Post-gain, in dB.
float inGain
Pre-gain, in dB.
int nSH
Current number of SH signals.
float release_ms
Release time, in ms.
int new_nSH
New number of SH signals (current value will be replaced by this after next re-init)
float fs
Host sampling rate, in Hz.