This node implements a dynamic range compressor. A range compressor applies non-linear scaling that reduces large amplitudes above a certain threshold and leaves smaller amplitudes intact. This can even out audio recordings of instruments or voices because quiet and loud parts are getting more similar.

Despite the fact that compression makes the signal less loud, it is often used for the opposite effect. If an audio signal would be amplified above a certain factor it is likely to leave its allowed amplitude range between -1 and 1. However, with an applied compressor the signal can be amplified much more before clipping occurs. This way the overall perceived loudness can be increased and compressors can make drums and bass lines much punchier.

The images below shows typical characteristics of the applied non-linear scaling function.


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 the examples above, the thresholds are -10 dB, which means that values above -10 dB are compressed whereas the ones below the threshold are maintained. The compression ratio controls how strongly the compression is applied. The rightmost curve is call soft-knee characteristic due to its soft transition in the area around the threshold. A compressor with a very high compression ratio is called limiter because it limits the maximal amplitude to the selected threshold.

Input Slots

The compressor node has the follow input slots:

  • Threshold (default: -6 dB): The threshold in dB at which limiting starts.
  • Ratio (default: 3): The compression ratio for amplitudes above the threshold (must be larger than or equal to 1).
  • Knee width (default: 3 dB): The width of the soft-knee in dB. A value of 0 dB, generates a hard-knee characteristic.
  • Attack time (default: 0.1 sec): Attack time in seconds. This parameter controls how fast the limiter is responding to a signal value above the threshold.
  • 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.
  • 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 compressor 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 implementation of a dynamic range compressor only differs in how the characteristic is computed from the implementation of a dynamic range limiter. Please refer to the documentation of the dynamic range limiter for details on the implementation of the other steps.

The characteristic is computed from user selected values for the threshold $T$, the compression ratio $R$, and 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 + \frac{x_{\mathrm{dB}} - T} {R} & \,\,:\,\, 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(1.0 - \frac{1}{R}\right) \left(x_{\mathrm{dB}} - T + \frac{W}{2}\right)^2}{2 \,W } & \,\,:\,\, (T - W/2) \le x_{\mathrm{dB}} \le (T + W/2) \\ T + \frac{x_{\mathrm{dB}} - T} {R} & \,\,:\,\, x_{\mathrm{dB}} > (T +W/2).\\ \end{cases}$
Thereby, the threshold $T$ and the knee width $W$ are specified in dB.