Compute. Volume. Compressor
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.
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.
- 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).
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.