SignalProcessing.Compute.AudioRelated.SignalLimiter

This node implements an audio limiter. Limiters are very useful to avoid clipping of a signal when the signal's amplitude leaves its allowed range between -1 and 1. For example, clipping is a typical problem when multiple audio sources are added together to generate a mix. Trivial solutions to avoid clipping would be either to clamp the signal to the range [-1,1], which might introduce strong distortion, or to scale down the amplitude of the complete signal linearly, which reduce the perceived loudness.

In contrast, a dynamic range limiter avoids clipping by a non-linear scaling that effects only large amplitudes above a certain threshold and leaves smaller amplitudes intact. Thereby, the limiter allows to control how smoothly the scaling factor (gain) is changing over time.

The images below shows typical characteristics of the applied non-linear scaling function. The left curve is call soft-knee characteristic due to its soft transition in the area around the threshold. The right one is call hard-knee characteristic.

characteristic

Because loudness is perceived linear in logarithmic units, the scaling function is applied after conversion to the logarithmic decibel (dB) scale. The characteristic maps an input value on the x-axis (in dB) to a value on the y-axis (in dB). In this example, the threshold is -10 dB. Therefore, all input values above -10 db are mapped to -10 dB after the characteristic is applied.

Input Slots

The limiter node has the follow input slots:

  • Threshold (default: -6 dB): The threshold in dB at which limiting starts.
  • Knee width (default: 0 dB): The width of the soft-knee in dB. A value of 0 dB, generates a hard-knee characteristic.
  • Attack time (default: 0 sec): Attack time in seconds. This parameter controls how fast the limiter is responding to a signal value above the threshold. A value of 0 seconds means that the limiter react immediately and the output is guaranteed to stay below the threshold. Because of this property, limiters with an attack time of 0 seconds are also called "brickwall" limiters. A longer attach time means that the gain is changed more slowly. This has the advantage of a less abrupt gain change, but values above the threshold can occur.
  • Release time (default: 0.5 sec): Release time in seconds. This parameter controls how fast the limiter releases the scaling once the signal drops below the threshold.
  • Sample rate (default: 44100 samples/sec): Sample rate of the input audio signal.
  • Apply make-up gain (default: true): As the limiter reduces the amplitude, this option allows to automatically compensate for this loss.
  • Stream (default: false): Enable this Boolean parameter if the limiter is used as a node in a streaming audio pipeline. This is important because with this option enabled, the gain value is maintained from one processed frame to the next.
  • Debug (default: Final Gain): selects which debug signal is displayed at the debug output (Input dB, Applied Characteristic, Gain, Smoothed Gain, Make-up Gain, Final Gain, Characteristic).

Implementation Details

The implementation of the dynamic range limiter follows the feed-forward design from Josh Reiss's tutorial, which proposes a 6-step side-chain that computes the final gain factor for each input sample. The following figure illustrates the internal signals after each side-chain step for a test input signal.

side_chain_steps
  • Step 1: Convert to dB
    The conversion to decibel (dB) scale is computed by:
    $x_{\mathrm{dB}} = 20 \log_{10}|x|$,
    where $x$ is a sample of the input signal. As can be seen in the figure above, an amplitude in range [-1,1] will result in a $x_{dB}$ less than or equal to zero, whereas the problematic values outside this range, which would cause clipping, have a $x_{dB}$ larger than zero.
  • Step 2: Apply Characteristic
    In this step the static characteristic is applied. The user can select a threshold $T$ and a knee width $W$. For a hard-knee characteristic (with $W \le 0$), the formula is:
    $x_{c} = \begin{cases} x_{\mathrm{dB}} & \,\,:\,\, x_{\mathrm{dB}} < T\\ T & \,\,:\,\, x_{\mathrm{dB}} \ge T \\ \end{cases}$
    and for a soft knee characteristic with knee width $W$:
    $x_{c} = \begin{cases} x_{\mathrm{dB}} & \,\,:\,\, x_{\mathrm{dB}} < (T - W/2)\\ x_{\mathrm{dB}} - \frac{ \left(x_{\mathrm{dB}} - T + W/2\right)^2}{2 \,W } & \,\,:\,\, (T - W/2) \le x_{\mathrm{dB}} \le (T + W/2) \\ T & \,\,:\,\, x_{\mathrm{dB}} > (T +W/2).\\ \end{cases}$
    Thereby, the threshold $T$ and the knee width $W$ are specified in dB. For example, in the figure above a hard knee characteristic ($W=0\, \mathrm{dB}$) with a threshold of $T = -10\,\mathrm{dB}$ is applied.
  • Step 3: Compute Gain
    The gain that should be applied to the input signal is computed by the difference between the signal after the applied characteristic and the input signal in dB:
    $x_{g} = x_{c} - x_{\mathrm{dB}} $
  • Step 4: Smooth Gain
    In this step the gain is smoothed over time using a single pole recursive low-pass filter. Two different filter coefficents $\alpha$ and $\beta$ are applied, where the filter coefficent $\alpha$ is controlled by the attack time and $\beta$ is controlled by the release time.
    $x_{s}[n] = \begin{cases} \alpha \, x_{s}[n-1] + (1.0 - \alpha) \,x_{g}[n] & \,\,:\,\, x_{g}[n] < x_{s}[n-1]\\ \beta \, x_{s}[n-1] + (1.0 - \beta) \, x_{g}[n] & \,\,:\,\, x_{g}[n] \ge x_{s}[n-1]\\ \end{cases}$
    For the example in the figure above, the attack time is selected to be 0 seconds, resulting in an $\alpha$ of zero, and therefore no smoothing is done while the required gain $x_{g}$ continiously gets lower at the beginning of the signal. A limiter with an attack time of 0 seconds is called "brickwall" limiter because it will always directly apply the required negative gain if the signal goes above the threshold. The release time is chosen as 0.2 seconds and, therefore, we can observe smoothing of the gain once the required gain $x_{g}$ gets higher.
  • Step 5: Make-up Gain
    Typically, because input amplitudes above the threshold are suppressed, the output signal has a reduced loudness. To compensate for this loss, additional make-up gain can be applied. The amount of make-up gain can be determined by computing how much loss would be realized by the characteristic for an amplitude of 1.0, corresponding to 0 dB.
    $x_{m} = x_{s} - \mbox{characteristic}(0 \,\mbox{dB})$
    In the example in the figure above, the threshold is $T = -10\,\mathrm{dB}$ and, thus, the gain is raised by $10\,\mathrm{dB}$ for the complete signal.
  • Step 6: Convert to Linear
    This last step converts the gain from decibel (dB) scale back to the linear domain. The inverse function to the one in step 1 must be applied, which is given by:
    $g = 10^{\frac{x_{m}}{20}}$
    The resulting final gain $g$ is the output of the side-chain and is multiplied with the current sample of the input signal.