Document toolboxDocument toolbox

(8.D.2.4) AGCCore

Overview

Slowly varying RMS based gain computer

Discussion

The AGCCore module is a slowly varying dynamics computer based on the RMS level of the signal. The module is used inconjunction with the MultiplierV2 module to create automatic gain controls. The module outputs a linear gain which can be applied to another signal using the MultiplierV2 module.

The first part of the module's processing function computes the RMS signal level over all input samples. The RMS value is then smoothed by a filter with the specified smoothingTime. The smoothed value is converted to dB and this input level feeds the control logic. The control logic computes an output gain so that when multiplied by the input signal the output signal has an RMS level of .targetLevel. .targetLevel is similar to the threshold in a limiter and .ratio has a similar meaning. If the input signal is .ratio dB loader than .targetLevel then the output will actually be 1 db above .targetLevel. Basically, .ratio specifies how hard the AGC will work to achieve the .targetLevel.

The variables .maxGain and .maxAttenuation control the maximum boost and cut that the AGC will allow. Both .maxGain and .maxAttenuation are positive numbers. For example, if maxGain = 10 and maxAttenuation = 20 then the AGCCore will boost by up to +10 dB and cut by up to -20 dB.

When the input level falls below .activationThreshold then the AGC freezes and holds its output gain. If .enableRecovery is checked then when the input signal falls below .activationThreshold then the AGCCore's gain will slew back to 0 dB. The rate of slewing is specified by recoveryRate which has units of dB/sec.

Type Definition

typedef struct _ModuleAGCCore { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 targetLevel; // Target audio level. FLOAT32 maxAttenuation; // Maximum attenuation of the AGC. FLOAT32 maxGain; // Maximum gain of the AGC. FLOAT32 ratio; // Slope of the output attenuation when the signal is above threshold. FLOAT32 activationThreshold; // Activation threshold of the AGC. The AGC stops updating its gain when the instantaneous input level is below this value. FLOAT32 smoothingTime; // Response time of the AGC. This controls the RMS smoothing interval and the time constant of the smoothly updating gain. INT32 enableRecovery; // Boolean which enables the AGC's gain recovery. If enabled, the AGC slows returns 0 dB gain when the input is below the activation threshold. FLOAT32 recoveryRate; // Rate at which the gain is adjusted when the input is below the activation threshold. FLOAT32 currentGain; // Instantaneous gain of the smoothing operation. FLOAT32 oneOverSlope; // Used by the processing function to compute the amount of cut/boost. Equal to 1-1/ratio. FLOAT32 smoothingCoeffSample; // Sample-by-sample smoothing coefficient for the output gain adjustment. Set via smoothingTime. FLOAT32 smoothingCoeffBlock; // Block-by-block smoothing coefficient for the RMS measurement. Set via smoothingTime. FLOAT32 recoveryRateUp; // Recovery rate coefficient when increasing the gain (it is always >= 1). FLOAT32 recoveryRateDown; // Recovery rate coefficient when decreasing the gain (it is always <= 1). FLOAT32 targetGain; // Target gain of the smoothing operation. FLOAT32 energy; // Smoothed energy measurement. FLOAT32 oneOverNumSamples; // 1 divided by the number of samples in the input pin. Used internally by the algorithm in order to save a divide operation. } ModuleAGCCoreClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

targetLevel

float

parameter

0

-20

-50:0.1:50

dB

maxAttenuation

float

parameter

0

100

0:100

dB

maxGain

float

parameter

0

12

0:50

dB

ratio

float

parameter

0

10

1:100

dB/dB

activationThreshold

float

parameter

0

-50

-100:-20

dB

smoothingTime

float

parameter

0

100

1:5000

msec

enableRecovery

int

parameter

0

1

0:1

 

recoveryRate

float

parameter

0

2.4

1:20

dB/sec

currentGain

float

state

0

0

-12:12

 

oneOverSlope

float

derived

1

0.9

Unrestricted

 

smoothingCoeffSample

float

derived

1

0.0002083

Unrestricted

 

smoothingCoeffBlock

float

derived

1

0.006644

Unrestricted

 

recoveryRateUp

float

derived

1

1

Unrestricted

 

recoveryRateDown

float

derived

1

0.9998

Unrestricted

 

targetGain

float

state

1

1

Unrestricted

 

energy

float

state

1

0

Unrestricted

 

oneOverNumSamples

float

derived

1

0.03125

Unrestricted

 

Pins

Input Pins

Name: in

Description: Audio input

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: audio output

Data type: float

MATLAB Usage

File Name: agc_core_module.m

M=agc_core_module(NAME) Audio Weaver module which calculates the instantaneous gain needed by an automatic gain control AGC module. This module is used in conjunction with the agc_multiplier_module. Arguments: NAME - name of the module.

Â