AGCR

From STX Wiki
Jump to navigationJump to search

AGCR - automatic gain control

Usage:

AGCR X FULL AMAX NULL GMAX GREF GINT DELAY PAUSE

Inputs:
X
The input signal.
FULL
The value for maximum attenuation; -FULL <= x <= FULL
AMAX
The end of the magnitude control range; 0 < AMAX < FULL
NULL
The maximum magnitude for 'pause' signals; NULL < AMAX, if NULL=0: pause-detection is disabled
GMAX
The maximum attenuation factor.
GREF
The attenuation reference value = attenuation factor for signals with magnitude AMAX/2; GREF>1; GREF should be lower than 2
GINT
The attenuation control interval factor; GINT>1; GINT should be lower than GREF
DELAY
The duration of the control interval in samples; DELAY>2; should be in the range of 40-100ms
PAUSE
The minimum NULL-duration for pause-detection; PAUSE>=DELAY; should be in the range of 100-1000ms
Outputs:
Y
adaptive attenuated signal
Function:

This atom implements an adaptive attenuation module (similar to AGC) and was designed to align the magnitude range of signals from different sources (e.g. 2 speakers).

1) A new gain factor is computed for each control-interval. For the gain computation the maximum of the absolute signal values in the interval is used.

Xmax , .., |xn-1|)
Amax maximum magnitude for gain control
Gmax maximum gain factor
Gref reference gain (gain for signals with magnitude Amax/2)
Gint gain step factor
Gset computed gain factor for this interval


Xmax >= Amax -> Gset = 1, no attenuation
Xmax < Amax -> Gset = Gref ld(Amax / Xmax) (ld = logarithm base 2)

The value Gref must be greater than 1 and should be lower than 2. With this method of gain computation, signals with an amplitude Amax/2n are amplified with the gain factor Grefn.

Gref < 2 weaker signals are more amplified than stronger (amplitude relations are compressed)
Gref = 2 all signal parts are shifted into the same magnitude range

To the computed gain factor following corrections are applied:

Gset is set to Gmax if the computed value is greater than Gmax

Gset is aligned to the nearest value of the discrete grid <1, Gint, Gint2, ..., Gmax>; this alignment avoids gain factor changes induced by small magnitude changes

2) The adaptive attenuation is applied to the delayed signal (DELAY samples). This guaranties that the calculated gain factor is always applied to the signal from that it was derived. For the gain factor transition between two intervals a smooth function is used.

Gcur gain factor at the beginning of the control-interval
Gset desired gain factor at the end of the control-interval
n length of control interval (DELAY)
G[i] = Gcur . (Gset / Gcur)1/n

The signal delayed by DELAY samples is multiplied with the gain G[i]. Because the control-function is falling exponential, G[i] is near Gset in the middle of the control-interval.

3) If a possible "overload" is detected during a control interval, the control-method is changed. A new gain is computed and set as described in 1, but the length of the change-interval for the gain is set to DELAY/2. With this method overloads are not possible.

4) If the signal magnitude is lower than NULL for a longer time than PAUSE, the gain is set to 1 using the same control-function as described in 2. This should avoid/reduce the amplification of background-signals or noise for a longer time.

5) For each input sample one output sample is computed. But the output is delayed by the duration of the control-interval (DELAY). This means, the first DELAY output samples are set to zero and the last DELAY input samples are not included in the output signal.

Navigation menu

Personal tools