DC archive

From Audacity Wiki
Jump to: navigation, search

Template:No-rename

Template:I18n

The Dynamic Compressor effect reduces the dynamic range of audio by applying a variable amplification which is controlled by the envelope of the signal. There are many possible uses of a compressor, including audio effects like drum compression and waveshaping. One of the main purposes of reducing dynamic range is to permit the audio to be amplified further (without clipping) than would be otherwise possible. Therefore the Dynamic Compressor has an optional output amplifier which can be used to amplify the audio as much as possible after compression. The resultant increase in average or RMS level can be useful for audio played in a noisy environment such as in a car, or in speech, to make a distant voice sound as loud as a close one. Because the gain changes relatively slowly, a compressor does not distort the signal in the way that a Limiter or clipping would do.
Accessed by: Effect > Dynamic Compressor...

Template:Effects

ToDo-1 needs updated picture

Dynamic Compressor.png

GUI overview

Compressor Graph

Compressor gain

The left graph in the dialog shows the input level along the bottom (horizontal axis) and the output level scale on the left (vertical axis) to illustrate the dynamic range compression effect. The graph will change as you adjust the Threshold and Ratio sliders (the sliders on the left side of the dialog), reflecting those settings. The graph does not reflect changes in any of the other controls, although they all affect how the audio sounds after applying the effect.



Step Response Graph

Compressor Step Response

The right graph shows the output perview of the compressor. The blue subplot shows a simplified input transient, for example a pure sine wave with a step in the amplitude (like in the envelope estimation graph in the Usage section). The red subplot shows the compressor output signal. The graph will change when you adjust any setting, reflecting those settings.

Controls

  • Envelope Algorithm: Selects the used envelope detector. It is recommended to use the new "Analog Model" algorithm which simulates the behaviour of an analog compressor as it is suitable for most use cases, including audio effects and waveshaping.
The Exponential-Fit detector uses the algorithm from Audacity's old Compressor. This is a non-causal envelope detector, that is the "attack" stage will react to signal changes before they happen independently of the lookahead stage.
Use this envelope detector to generate audio effects, if you have to avoid clipping or need more precise threshold values since the estimated envelope will be always on top of the signal.
In the last case you have to listen to the different results and decide.
  • Compress based on: Selects whether you like to compress based on peaks or RMS. In case of peaks, the sliding maximum inside the lookaround window is used as input for the envelope detector. In case of RMS, the sliding RMS over the lookaround window is calculated. Without lookaround, both modes do the same.
  • Compress stereo channels independently: If checked, stereo signals are compressed as two mono passes.


  • Threshold: The level of the estimated envelope above which compression is applied to the audio. If the estimated envelope is below threshold, the signal passes unchanged so you do not have to worry about amplification of noise in silent audio parts.
  • Ratio: The amount of compression applied to the audio once it passes the threshold level. The higher the Ratio the more the loud parts of the audio will be compressed. The Ratio sets the slope of the blue line on the graph above the threshold.
  • Knee Width: The "softness" of the gain response around the threshold value. A Knee Width of 0 corresponds to a sharp kink at this point. Larger values soften the response symmetrically around the threshold point. From that it follows, that input signals below (threshold - Knee Width/2) are now affected by the compressor as well.
Use soft knee to reduce distortions around the threshold point when the compressor kicks in (best used for waveshaping).
  • Output Gain: Adjustable output gain which is used to compensate the amplitude loss during compression. USe the right preview plot to adjust this slider so that the maximum of the red plot in the right graph is approximately that of the blue graph.


  • Attack Time: How soon the compressor starts to compress the dynamics after the threshold is exceeded. If volume changes are slow, you can push this to a high value. Short attack times will result in a fast response to sudden, loud sounds, but will make the changes in volume much more obvious to listeners. Every attack time interval, the signal increases by 1-1/e (~0.63).
  • Release Time: How soon the compressor starts to release the volume level back to normal after the level drops below the threshold. A long time value will tend to lose quiet sounds that come after loud ones, but will avoid the volume being raised too much during short quiet sections like pauses in speech. Every release time interval, the signal decreases by 1-1/e (~0.63).
  • Lookahead Time: Controls how much the compressor looks ahead into the future, so that it can react to coming transients even before they actually hit. The benefit of look-ahead is that sudden peaks do not pass through the effect before the gain has had time to change.
  • Hold Time: Controls how much the compressor looks behind into the past, so that gone signals still affect the output.


Buttons

Template:Effectbuttons

Architecture and Latency

Compressor Architecture Block Diagram

The compressor is made up of several stages (see picture). The first stage is a preprocessor which detects the peak amplitude or RMS in the given lookaround area around the current sample. This preprocessed signal is fed into an envelope estimator which controls the varying gain of the calculated output signal. Since the lookahead stage cannot look into the future when doing realtime processing, the whole signal has to be delayed so that all samples required by the algorithm are available during the processing. For this, the dymanic compressor effect uses a four stage pipeline with a dynamic block size which depends on the used parameters.

In case of the analog simulation envelope detector, the latency is 4 * lookahead_time. The minimum latency is 11 ms at a sample rate of 44,100 Hz (2,048 Samples). In case of the exponential fit envelope detector, the latency is 4 * max(lookahead_time, 5*(attack_time + 0.1s)). Hence, the minimum latency is about 2 seconds here. In realtime mode, it will take the latency time until you can hear the impact of changed settings.

At the beginning, it will take 1.5 times the latency until you start hearing audio due to additional pipeline filling steps.

Usage

Envelope estimation and lookaround

If you want to have a simple (analog) compressor for beginners, use just Threshold, Ratio, Attack Time and Release Time.

  • Set Envelope Algorithm to "Analog Model", compress based on peaks and uncheck "Compress stereo channels independently".
  • Then set Knee Width, Lookahead Time, Hold Time and output gain to zero.
  • Attack time should always be much lower than release time. Otherwise, the estimated envelope has no time to rise and the compressor will do nothing (see interactive step response plot as well).
  • If you are curious, try experimenting with a little soft-knee lookahead or hold.
  • Finally adjust the output gain so the the red graph in the output preview plot is slightly below the blue graph.
  • Apply the effect and listen to the result. Important is how it sounds to you, not the numbers on some controls.
* Use real-time preview to hear the effect.
Please note, that with these settings the threshold is not absolute compared with your input signal but rather an estimation somewhere below because of the internal functionality of the envelope detector (see picture). So if the compressor seems to do nothing, try lowering the threshold.
The Make-up Gain control is usually only needed for real-time preview.
If the processed audio has sharp transients that go through the compressor, experiment with a short Lookahead Time.

Compression methods

When compressing based on peaks, the estimated envelope is below the real envelope. This effect can be reduced by adding a small lookaround either lookahead, hold or both (see picture), and should be kept in mind. If the compressor seems to have no effect, the estimated envelope might be below threshold. As solution, try lowering the threshold or increase lookaround.

In RMS mode, the estimated envelope level is automatically corrected with known-good factors for standard audio so that is is very close to the real level independently of lookaround.

Examples

Waveshaping

Waveshaping an audio-like noise signal

As an example, if you like to subtly reduce the dynamic of some music, for example for listening in noisy environments for example in a car, try the following settings:

  • Envelope: Analog model
  • Compress based on: peak amplitude
  • Compress stereo channels independently: no
  • Threshold: -40 (Just for noise blocking)
  • Ratio: 2.5 (Lower ratio to avoid distortion)
  • Knee Width: 6 (Use a soft-knee to avoid distortion at the transition from/to quiet sections)
  • Output Gain: 23 dB
  • Attack Time: 0.3 (Quite high symmetric attack/release times to keep beats intact)
  • Release Time: 0.3
  • Lookahead Time: 0.5 (Quite high symmetric lookahead/hold times to suppress short-time events like beats and pauses)
  • Hold Time: 0.5

The picture on the right shows the above settings applied to a audio-like noise signal with a quieter first half and a louder second half as well as the estimated envelope. With this settings, the estimated envelope follows the "loudness" of the signal so that the compressor produces an equal loud output signal by reducing the amplitudes of the second half while leaving the beats intact. The threshold is effectively disabled and just blocks noise from silent sections.


Peak limiting

Limiting isolated spikes of an audio-signal

ATo reduce isolated peaks of an audio signal which would clip when the signal is amplified, try the following settings:

  • Envelope: Analog model
  • Compress based on: peak amplitude
  • Compress stereo channels independently: no
  • Threshold: -10 (Threshold slightly above base signal)
  • Ratio: 10 (Lower ratio to reduce distortion)
  • Knee Width: 0
  • Output Gain: 0 dB
  • Attack Time: 0.001 (Fast attack time to catch the peaks)
  • Release Time: 0.05 (Fast but not too fast)
  • Lookahead Time: 0 (No lookahead or hold for fast reaction)
  • Hold Time: 0

The picture on the right shows the above settings applied to a audio-like noise signal with strong isolated spikes on it. With this settings, the estimated envelope follows the peaks and the compressor squashes them down so that they do not clip when the signal is amplified. After the peak, the envelope drops rapidly below the threshold so the rest of the signal is not affected.


Further reading on compressors

There are some good (but not too technical) explanations of compression here:

More advanced:

An alternative free compressor

Please see Chris's Dynamic Compressor for a popular alternative compressor which may be downloaded for free.


Links

|< Index of Effects, Generators and Analyzers

|< Effect Menu