Dynamics
Dynamic modules de/emphasize the amplitude structure of data. AGC stands for Automatic Gain Control. It differs from standard gain modules in that the gain value changes by itself over time, and the gain can scale loud volumes separate from quiet volumes. This ‘warping’ of the volume information can regulate perceived volume, maximize output, add a safety stage before the signal hits the speakers, remove low volume noise, and manage sound source priority like ducking music behind a dialog track. This section of the guide will cover the modules in the AGC folder: compressor core, envelope followers, limiter core, expander(and noise gate), ducker, and agc core. It will then go over building a custom AGC, and finally optimize an AGC to run at reduced computation cycles.
The dynamics modules operate with different gain variation speeds and different magnitude reference signals. All dynamics modules with the suffix ***Core do not generate audio data, but instead output volume data to be sent to a scaler control pin or an AGC Multiplier. The following diagrams represent the typical input/output response for various AGC types.
Compressor – reduce the peak dynamic range of a signal
Downward expander (and noise gate) – reduce small signal levels and behave as noise gates
Limiter – restrict peak signal levels to avoid digital clipping (limiters generally have a horizontal or flat slope, which means high ratio)
Ducker - use a trigger signal to determine when to boost or reduce gain of another signal.
AGC Core– adjust the gain to keep the signal within a specified RMS range
Compressors
A compressor reduces the signal’s dynamic range, meaning that it lowers the level of loud signals and boosts quiet ones, reducing the difference between loud and soft signals. Make-up gain is usually applied after for increasing the perceived loudness. This can be used for scenarios when keeping the overall volume low is desired but hearing small details is still important, such as night-time movie watching. The behavior of the compressor is best understood by looking at its input-output response:
Above the threshold the compressor reduces the signal level; below the threshold the compressor increases the signal level (it’s expanding the system). This brings all output signals closer to the threshold level and reduces the overall dynamic range. The AGCCompressorCore module is wired the same way as the limiter module, receiving its input from an Abs or MaxAbs module and outputting to a multiplier, as shown below:
Envelope Modulation
Envelope modulators control the impact that relative peaks have. The Attack Release module uses attackTimeInitial and attackTimeFinal to smooth peaks. The Attack Decay Sustain Release is similar, but also includes 2 stages in between the attack and release. Decay lowers the level into a hold that is based on the sustain level. After this hold ends, the release occurs.
Limiters
The AGCLimiterCore module is parameterized by its threshold, ratio, gain, knee depth, attack time, and decay time. The AGCLimiterCore module computes the time varying gain.
Take the absolute value of the signal so that the AGCLimiterCore module treats positive and negative signals equally. The first pin on the AGCMultiplier is the gain to apply and the second input is the audio signal itself.
(standard arrangement for a mono limiter)
When the input is below the threshold the line has a slope of 1 indicating that the signal level is unchanged. Above the threshold the slope drops indicating that the output level will be reduced compared to the input level. Limiters have a parameter called the “ratio” referring to the reciprocal slope of the gain ratio above the threshold. A high ratio provides hard limiting, close to 1 provides gentle limiting.
The limiter applies a piecewise function to determine its gain: at a specified threshold, the slope changes. The transition between sections is smoothed by a connecting polynomial section, often referred to as the “knee”. The knee provides a gentle polynomial interpolation between the threshold and the requested slope. The kneeDepth parameter controls the extent of the polynomial section. The polynomial starts at threshold-kneeDepth and ends at threshold+kneeDepth.
The speed with which a limiter responds to an increase in sound level is described by its “attack time”. The lower the attack time, the faster the limiter will respond to the sound level rising above its threshold. Similarly, decay (or release) time describes the speed with which the limiter’s effect is relaxed after the sound level drops back under its threshold. The time behavior of the dynamics processors is implemented with first order IIR smoothers with different attack and decay coefficients. The above image shows example attack and decay curves.
Downward Expander
The DownwardExpanderCore module is also a limiter with a piecewise gain, but its piecewise function is different. Whereas most limiters use a slope of 1 below a threshold and a reduced slope above it, this module features a very steep slope below its threshold and a slope of 1 above it. Rather than reducing the level of loud signals, this reduces the level of quiet signals.
The DownwardExpanderCore module’s response behavior
One use of this module is for filtering out low-level noise while retaining a louder signal. This is very useful for eliminating “hiss,” low level background noise in a signal. Like most dynamic processing modules, the DownwardExpanderCore is designed to take its input from the MaxAbs module and output its gain as an input to the AGCMultiplier module.
Example of a noise gate which eliminates low level signals
AGC Core
This module has a slowly varying volume control which transfers the input signal level towards a targetLevel, a specified RMS level. The input RMS is smoothed via the smoothing time variable. This allows the gain to change gradually. The gain is limited to the range [-maxAttenuation and maxGain]. The ratio control determines the speed of the gain change for all signals above the activation Threshold. When the level of the input signal falls below activationThreshold, the AGCCore holds the last gain setting. If the enableRecovery checkbox is checked, the gain will slowly return to 0 dB when not activated. The rate of return is governed by recoveryRate.
Table of Dynamics Modules
Module Name | Input type supported | Gain Variation Speed | Vol. Reference | Output Type |
AGC Core | Floating Point | Slow | RMS | Gain Control Data |
AGC Multiplier | Floating Point | Instant | Pin Controlled | Audio Data |
AGC Multiplier Fract32 | Fract32 | Instant | Pin Controlled | Audio Data |
AGCAttack Release Fract32 | Fract32 | Variable Controlled | Peak | Audio Data |
AGCCompressor Core Fract32 | Fract32 | Variable Controlled | Peak | Audio Data |
AGCCore Fract32 | Fract32 | Slow | RMS | Gain Control Data |
Attack Decay Sustain Release | Floating Point | Variable Controlled | Peak | Audio Data |
Attack Release | Floating Point | Variable Controlled | Peak | Audio Data |
Compressor Core | Floating Point | Variable Controlled | Threshold | Audio Data |
Downward Expander Core | Floating Point | Variable Controlled | Threshold | Audio Data |
Downward Expander Core Fract32 | Fract32 | Variable Controlled | Threshold | Audio Data |
Ducker | Floating Point | Variable Controlled | Trigger | Audio Data |
Ducker Fract32 | Fract32 | Variable Controlled | Trigger | Audio Data |
Limiter Core | Floating Point | Variable Controlled | Peak | Audio Data |
Limiter Core Fract32 | Fract32 | Variable Controlled | Peak | Audio Data |
Noise Gate Core | Floating Point | Variable Controlled | RMS Threshold | Audio Data |
Variable Attack Release | Floating Point | Variable Controlled | Peak | Audio Data |