Skip to main content
Skip table of contents

AGCLimiterCoreFract32

Overview

Soft knee gain computer for use in peak limiters

Discussion

The agc_limiter_core_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_fract32_module, and agc_multiplier_fract32_module modules is referred to as a "limiter" and is contained in the script limiter_module.m.

It is also possible to incorporate delay into the limiter effectively allowing it to "look ahead" and anticipate transients.  See the limiter_module.m script for details.

One way to understand the operation of the limiter is to consider the input / output curve shown in the figure below.  The X-axis represents the level of the input signal, in dB.  For simplicity, assume that the input signal is a sine wave.  The Y-axis represents the level of the output sine wave.  In the figure, the limitThreshold is set to -30 dB.  Signals below limitThreshold are unaffected.  Signals above limitThreshold are compressed by the parameter ratio.  In the figure, ratio is set to 3 dB/dB, and thus the output signal gets 1 dB louder for every 3 dB increase in the input signal.  In typical limiter applications, ratio is set to 100 preventing the signal from getting much louder than threshold.

The AGCLimiterCoreFract32 module computes the gain needed to realize the input / output curve shown above.  The gain curve is shown below.  Below limitThreshold, the gain equals 0 dB and thus the level of the signal is unaffected.  After limitThreshold, attenuation is applied.

The outputGain parameter allows you to specify additional gain through the limiter.  This gain is just incorporated into the output signal.

 

The limiter includes a soft knee which causes the attenuation to kick in gradually.  The knee is a quadratic function extending from limitThreshold – kneeDepth to limitThreshold + kneeDepth.  Due to manner in which the knee is implemented, kneeDepth must always be > 0.  The figure below illustrates the input / output level characteristic with:

limitThreshold = -10

ratio = 100

kneeDepth = 10

The dynamic behavior of the limit is controlled by an envelop detector.  attackTime specifies the rate at which sharp transients will be reduced.  decayTime specifies the rate at which the limiter returns to unity gain.

Type Definition

CODE
typedef struct _ModuleAGCLimiterCoreFract32
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    FLOAT32 threshold;                            // Amplitude level at which the AGC Limiter Core reduces its output gain value
    FLOAT32 outputGain;                           // Value used to scale the output of the AGC Limiter Core
    fract32 slope;                                // TBD
    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
    FLOAT32 sharpnessFactor;                      // TBD
    fract32 sharpnessFactorFract32;               // TBD
    fract32 attackCoeff;                          // TBD
    fract32 decayCoeff;                           // TBD
    fract32 envState;                             // TBD
    fract32 currentGain;                          // Instanteous gain applied at the end of the block
    fract32 thresholdFract32;                     // threshold - in 8.24 "base2 dB"
    fract32 kneeDepthFract32;                     // kneeDepth - in 8.24 "base2 dB"
    fract32 gainFract32;                          // outputGain - in 8.24 "base2 dB""
} ModuleAGCLimiterCoreFract32Class;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

threshold

float

parameter

0

-10

-60:0.1:0

dB

outputGain

float

parameter

0

0

-20:0.1:20

dB

slope

fract32

derived

0

0.75

Unrestricted

dB/dB

kneeDepth

float

parameter

0

2

0.1:60

dB

ratio

float

parameter

0

4

1:100

attackTime

float

parameter

0

1

0.01:1000

msec

decayTime

float

parameter

0

100

0.01:1000

msec

sharpnessFactor

float

derived

0

0.5

Unrestricted

sharpnessFactorFract32

fract32

derived

0

0.003906

Unrestricted

attackCoeff

fract32

derived

0

0.02062

Unrestricted

decayCoeff

fract32

derived

0

0.0002083

Unrestricted

envState

fract32

state

0

0

-60:1

currentGain

fract32

state

0

0

-10:5

thresholdFract32

fract32

derived

0

-0.07813

Unrestricted

kneeDepthFract32

fract32

derived

0

0.01563

Unrestricted

gainFract32

fract32

derived

0

0

Unrestricted

Pins

Input Pins

Name: in

Description: audio input

Data type: fract32

Channel range: 1

Block size range: Unrestricted

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

Sample rate: 48000

MATLAB Usage

File Name: agc_limiter_core_fract32_module.m

CODE
 M=agc_limiter_core_fract32_module(NAME)
 Creates a limiter gain computer with soft knee for use in the Audio
 Weaver. Arguments:
    NAME - name of the module.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.