Overview
Soft knee gain computer for use in peak limiters
Discussion
The agc_limiter_core_v2_fract32_module computes a time varying gain which is used to restrict the peak value of a signal. The module is designed to take its input from the max_abs_fract32_module. The module computes a time varying gain on a sample-by-sample basis, and this gain is later applied by the agc_multiplier_fract32_module. The output gain signal is in 8.24 format. The agc_multiplier_fract32_module expects the gain to be in 1.31 format. Thus, the multiplier must be configured to shift by 7 bits. The combination of max_abs_fract32_module, agc_limiter_core_v2_fract32_module, and agc_multiplier_fract32_module modules is referred to as a "limiter" and is contained in the script limiter_module.m.
...
ratio = 100
kneeDepth = 10
...
Type Definition
Code Block |
---|
typedef struct _ModuleAGCLimiterCoreV2Fract32 { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 numChan; // Number of channels. FLOAT32* threshold; // Amplitude level at which the AGC Limiter Core reduces its output gain value FLOAT32* gain; // Value used to scale the output of the AGC Limiter Core (make up gain) FLOAT32* kneeDepth; // Knee depth controls the sharpness of the transition between no limiting and limiting FLOAT32* ratio; // Slope of the output attenuation when the signal is above threshold - derived from the standard compression ratio parameter by the formula slope = 1.0 - (1.0/ratio) FLOAT32* attackTime; // Envelope detector attack time constant FLOAT32* decayTime; // Envelope detector decay time constant fract32* slope; // Internal derived variable which holds the slope of the compression curve FLOAT32* sharpnessFactor; // Internal derived variable which is used to implement the soft knee fract32* attackCoeff; // Internal derived variable which implements the attackTime fract32* decayCoeff; // Internal derived variable which implements the decayTime fract32* thresholdFract32; // threshold - in 8.24 "base2 dB" fract32* gainFract32; // gain - in 8.24 "base2 dB" fract32* kneeDepthFract32; // Knee depth - in 8.24 "base2 dB" fract32* sharpnessFactorFract32; // Internal derived variable which is used to implement the soft knee fract32* envState; // Holds the instantaneous state of the envelope detector fract32* currentGain; // Instantaneous gain computed by the block } ModuleAGCLimiterCoreV2Fract32Class; |
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
numChan | int | const | 1 | 1 | Unrestricted | |
threshold | float* | parameter | 0 | [1 x 1] | -60:0 | dB |
gain | float* | parameter | 0 | [1 x 1] | 0:40 | dB |
kneeDepth | float* | parameter | 0 | [1 x 1] | 0.1:60 | dB |
ratio | float* | parameter | 0 | [1 x 1] | 1:100 | |
attackTime | float* | parameter | 0 | [1 x 1] | 1:2000 | msec |
decayTime | float* | parameter | 0 | [1 x 1] | 1:2000 | msec |
slope | fract32* | derived | 1 | [1 x 1] | Unrestricted | dB/dB |
sharpnessFactor | float* | derived | 1 | [1 x 1] | Unrestricted | |
attackCoeff | fract32* | derived | 1 | [1 x 1] | Unrestricted | |
decayCoeff | fract32* | derived | 1 | [1 x 1] | Unrestricted | |
thresholdFract32 | fract32* | derived | 0 | [1 x 1] | Unrestricted | |
gainFract32 | fract32* | derived | 0 | [1 x 1] | Unrestricted | |
kneeDepthFract32 | fract32* | derived | 0 | [1 x 1] | Unrestricted | |
sharpnessFactorFract32 | fract32* | derived | 1 | [1 x 1] | Unrestricted | |
envState | fract32* | state | 1 | [1 x 1] | Unrestricted | |
currentGain | fract32* | state | 0 | [1 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: audio input
...
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: audio output
Data type: fract32
Scratch Pins
Channel count: 1
Block size: 32
...
Block size: 32
Sample rate: 48000
MATLAB Usage
File Name: agc_limiter_core_v2_fract32_module.m
...