SAF
Loading...
Searching...
No Matches
ambi_drc.h

A frequency-dependent Ambisonic sound scene dynamic range compressor (DRC)

A frequency-dependent Ambisonic sound scene dynamic range compressor (DRC)

Files

ambi_drc.h (include), ambi_drc_internal.h, ambi_drc.c, ambi_drc_internal.c

Include Header

/*
* Copyright 2017-2018 Leo McCormack
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __AMBI_DRC_H_INCLUDED__
#define __AMBI_DRC_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define ENABLE_TF_DISPLAY
/* ========================================================================== */
/* Presets + Constants */
/* ========================================================================== */
#ifdef ENABLE_TF_DISPLAY
# define AMBI_DRC_NUM_DISPLAY_SECONDS ( 8 )
# define AMBI_DRC_NUM_DISPLAY_TIME_SLOTS ( (int)(AMBI_DRC_NUM_DISPLAY_SECONDS*48000.0f/(float)128) )
# define AMBI_DRC_READ_OFFSET ( 200 )
# define AMBI_DRC_NUM_BANDS ( 133 )
#endif
#define AMBI_DRC_SPECTRAL_FLOOR (0.1585f)
#define AMBI_DRC_IN_GAIN_MIN_VAL ( -40.0f )
#define AMBI_DRC_IN_GAIN_MAX_VAL ( 20.0f )
#define AMBI_DRC_THRESHOLD_MIN_VAL ( -60.0f )
#define AMBI_DRC_THRESHOLD_MAX_VAL ( 0.0f )
#define AMBI_DRC_RATIO_MIN_VAL ( 1.0f )
#define AMBI_DRC_RATIO_MAX_VAL ( 30.0f )
#define AMBI_DRC_KNEE_MIN_VAL ( 0.0f )
#define AMBI_DRC_KNEE_MAX_VAL ( 10.0f )
#define AMBI_DRC_ATTACK_MIN_VAL ( 10.0f )
#define AMBI_DRC_ATTACK_MAX_VAL ( 200.0f )
#define AMBI_DRC_RELEASE_MIN_VAL ( 50.0f )
#define AMBI_DRC_RELEASE_MAX_VAL ( 1000.0f )
#define AMBI_DRC_OUT_GAIN_MIN_VAL ( -20.0f )
#define AMBI_DRC_OUT_GAIN_MAX_VAL ( 40.0f )
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
void ambi_drc_create(void** const phAmbi);
void ambi_drc_destroy(void** const phAmbi);
void ambi_drc_init(void* const hAmbi,
int samplerate);
void ambi_drc_process(void* const hAmbi,
const float *const * inputs,
float* const* outputs,
int nCH,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
void ambi_drc_refreshSettings(void* const hAmbi);
void ambi_drc_setThreshold(void* const hAmbi, float newValue);
void ambi_drc_setRatio(void* const hAmbi, float newValue);
void ambi_drc_setKnee(void* const hAmbi, float newValue);
void ambi_drc_setInGain(void* const hAmbi, float newValue);
void ambi_drc_setOutGain(void* const hAmbi, float newValue);
void ambi_drc_setAttack(void* const hAmbi, float newValue);
void ambi_drc_setRelease(void* const hAmbi, float newValue);
void ambi_drc_setChOrder(void* const hAmbi, int newOrder);
void ambi_drc_setNormType(void* const hAmbi, int newType);
void ambi_drc_setInputPreset(void* const hAmbi, SH_ORDERS newPreset);
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
float** ambi_drc_getGainTF(void* const hAmbi);
int ambi_drc_getGainTFwIdx(void* const hAmbi);
int ambi_drc_getGainTFrIdx(void* const hAmbi);
float* ambi_drc_getFreqVector(void* const hAmbi, int* nFreqPoints);
float ambi_drc_getThreshold(void* const hAmbi);
float ambi_drc_getRatio(void* const hAmbi);
float ambi_drc_getKnee(void* const hAmbi);
float ambi_drc_getInGain(void* const hAmbi);
float ambi_drc_getOutGain(void* const hAmbi);
float ambi_drc_getAttack(void* const hAmbi);
float ambi_drc_getRelease(void* const hAmbi);
int ambi_drc_getChOrder(void* const hAmbi);
int ambi_drc_getNormType(void* const hAmbi);
int ambi_drc_getNSHrequired(void* const hAmbi);
int ambi_drc_getSamplerate(void* const hAmbi);
#ifdef __cplusplus
} /* extern "C" { */
#endif /* __cplusplus */
#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