Talk:Compressor

From Audacity Development Manual
Revision as of 04:41, 23 November 2009 by Billw58 (talk | contribs) (old contents of Compressor page saved here for future reference)
Jump to: navigation, search

CompressorIOgraph.png

Steve, is this correct?

Compressor settings:

  • Threshold -12 dB
  • Ratio 4:1
  • Noise Floor -42 dB


  • Blue graph is IO characteristic for "compress based on peaks" OFF and "make-up gain" OFF
  • Red graph is IO characteristic for "compress based on peaks" ON and "make-up gain" OFF or ON
  • Green graph is IO characteristic for "compress based on peaks" OFF and "make-up gain" ON

-- Bill


The characteristics when "Make up gain" is on cannot really be shown on this type of diagram. Unlike (most) hardware compressors, the "make-up" gain is not a fixed amount to compensate for the lower output, but is a Normailize function. The amount of gain depends on the peak level of the audio after compressing. The solid red line is approximately the effect of normalizing (make-up gain to 0dB) if the uncompressed signal had a peak of 0dB.

In the diagram below there are several alternative "post-make-up gain" plots drawn. The lower the peak amplitude after compression, the more make up gain is applied. The make-up gain would be described better as "Normalize to 0dB after compression".

RMS based normalise.png

This also applies to "Make-up gain for 0 dB after compressing" when using "Compress based on Peaks".

When Compress based on Peaks is selected, the threshold will appear to be at a different level, because it is working with peak values rather than RMS values. It's a bit tricky to show in this kind of diagram because we're mixing peak and rms measurements.

When compression is based on RMS, a threshold setting of -12dB will begin compression at an RMS value of -12dB (roughly -9dB peak). When compression is based on Peak, a threhold setting of -12dB will begin compression at a PEAK value of -12dB.

Peak vs rms.png


I'll add some better diagrams for upward vs. downward compression shortly.--Steve the Fiddle 17:18, 20 November 2009 (UTC)

Then again, perhaps the above diagram is sufficient if we take out the (incorrect) noise floor part?

Perhaps a diagram indicating Peak level vs. RMS level?

Peak-vs-rms.png

--Steve the Fiddle 18:03, 21 November 2009 (UTC)

Bill: Steve, here's a graph of the actual IO characteristic using Compress based on peaks, threshold = -12 dB, no make-up gain, attack and decay at minimum, noise floor at -80 dB. The red curve is for a chirp from 0 to 1, the green curve for a chirp from 0 to -0.707 (-3 dB). Note that the knee for the first case is at -9 dB, and moves left for the second case. Other than that the curves are very similar.

Compressor IO graph2.png


Technical details and input-output graphs

When "Compress based on peaks" is not checked

The following image shows the input-output characteristic of the Compressor effect when "Compress based on peaks" is not checked.

  • The light blue line shows the characteristic when "Make-up gain for 0 dB after compressing" is not checked.
In this mode the Compressor effect behaves like a traditional hardware compressor.
  • The dark blue line shows the characteristic when "Make-up gain for 0 dB after compressing" is checked, and corresponds to the line shown on the graph in the Compressor dialog.
In this mode the Compressor effect behaves like a traditional hardware compressor with a "smart" output gain control.

Note that the line from the threshold point to the left of the graph always has a slope of 1. CompressorIOgraphRMS.png

This is implied by the graph on the effect, but the graph is wrong. After make up gain to 0dB has been applied the slope below the threshold is no longer 1. This is easy to see when you consider the case of silence (-inf dB) - both input and output are silence. Steve the Fiddle

When "Compress based on peaks" is checked

The following image shows the input-output characteristic of the Compressor effect when "Compress based on peaks" is checked.

  • The red line shows the characteristic when "Make-up gain for 0 dB after compressing" is not checked.
  • The orange line shows the characteristic when "Make-up gain for 0 dB after compressing" is checked and the input signal had a maximum peak value of less than 0 dB.

Note that the line from the threshold point to the left of the graph no longer has a slope of 1.


When "Compress based on peaks" is checked the Compressor effect applies "upward compression" to the input. This is very different from the behaviour of a traditional hardware compressor. Note that when the volume of the input is below the threshold the volume is "stretched" to fit the new post-compression range. Sounds above the threshold still receive downward compression. The result is that very quiet sounds are not significantly amplified.

CompressorIOgraphPeak.png


Here's my suggestion: Steve the Fiddle
The Compressor effect reduces the dynamic range of audio. 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 by default the Compressor amplifies 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.
Compressor settings window


Graph

The graph 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, reflecting the settings made. The actual characteristics of the effect is also dependent on the other settings (not shown in the graph).

Controls

  • Threshold: Compression is applied to sounds above this level.
  • Noise Floor: This setting helps to prevent low level sound (background noise below this level) from being unduly amplified as a result of the processing.
  • 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.
  • 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.
  • Decay 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.
  • Make-up gain for 0 dB after compressing: Boosts the resultant audio after compression to a peak level of 0dB.
  • Compress based on Peaks: The threshold and gain adjustment are based on peak values of the waveform rather than the average (RMS) value. The method used for compressing dynamics is different when this option is selected. When not selected, the compressor reduces the volume of louder sounds while leaving quieter ones untouched, but when "compress based on peaks" is selected, quieter sounds are amplified more than loud sounds. The result in both cases is to reduce the dynamic range of sounds above the threshold.


The illustration below compares characteristics of compression based on peak and compression based on average levels (before make-up gain).



Compression characteristics for peak based and rms based compression


Schematic example

Uncompressed: A simple sine wave that drops off by 6 dB half way through the selection, to demonstrate how some compressors handle signals.

Uncompressed signal

After: The attack part of where the compressor is working is clearly visible at the start of the audio.The release part still affects some audio that is beneath the threshold as the compressor gain change slowly ebbs out and the material fades back to normal level.

Compressed signal


Steve the Fiddle



OLD CONTENTS OF THE MAIN PAGE

Bill: Note to self for post 2.0. Virtually all real-world compressors use the word "Release", not "Decay". The graphic example uses "Release".

This page need a major make-over. The Compressor plugin now has another slider - Noise Floor - that needs to be documented. 'Normalize to 0 dB after compressing' now reads 'Make-up gain for 0 dB after compressing'. There is a checkbox for 'Compress based on peaks'. The blue line in the graph is now pinned to the upper-right instead of the lower-left. This is confusing for audio engineers as they're used to seeing compressor graphs with the curve pinned to the lower-left. The old graph was better in that regard. The new graph display is, I suppose, appropriate when the 'Make-up gain' option is chosen. It would be nice if the graph would change where it's pinned based on that option.

  • Gale: I will raise this on -devel list - I don't recall any reason for the pinning axis changing, but I will ask. I agree Cool Edit Pro pins as you suggest.


All that aside, I guess we need to document what the Compressor currently does and how it behaves. I may have a go at describing how the graph works and what it means, after I un-learn 35 years of using compressors.
Does anybody know what the 'Noise Floor' slider does? - Bill W

  • Gale: I had asked the contributor who made these changes to document them. I have some very basic information I can add based on the -devel list discussions. I think it's better I do that and you ask questions after that if you have suggestions for improvement.

Bill: I've gone ahead and documented this, as it seems unlikely to be fixed in time for 2.0.

Compressor reduces the volume of louder sounds while leaving quieter ones untouched,
Steve the Fiddle Only in the case of downward compression. When "Compress based on peaks" is selected, this is an "upward" compressor - it keeps audio with high peak amplitude at the same level and raises the level of audio that has a peak amplitude below the Threshold.

Audio with a peak level below the "Noise Floor" is not changed.
Essentially, when "Compress based on peaks" is selected, there is dynamic expansion between the Noise Floor and Threshold, and dynamic compression above the Threshold.
Bill: Your third statement is correct, but it conflicts with your first statement. There is always downward compression above the threshold. How the code handles this I can't tell, but I've done a series of tests with chirps that clearly show that downward compression (according to the ratio) happens above the threshold when "compress based on peaks" is checked. You are correct about the "upward expansion" between the threshold and the noise floor when "compress based on peaks" is checked. Sounds below the noise floor are not amplified. Sounds with volumes between the noise floor and the new threshold (after downward compression and calculation of the amount of amplification possible after this compression?) have their volumes "stretched" to fit the new range. I you'd like I'd be happy to put some screenshots and a detailed step-by-step procedure on the talk page.

Are you getting a feeling of deja vu here?
reducing the dynamic range of the audio. 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 by default Compressor amplifies audio as much as possible after compression. The resultant increase in average or RMS level can be useful for audio played in a noisy background, such as in a car stereo, or in speech, to make a distant voice sound as loud as a close one.
Accessed by: Effect > Compressor...
Compressor settings window
ToDo Old text "Compressing the louder sounds gives more headroom for amplifying the fainter sounds without causing clipping" and "Because the gain changes relatively slowly, a compressor does not distort the signal in the way that a Limiter or clipping would do." should be worked in or not, as thought best, and section written for graph describing what the axes mean. Then probably work in the two images at the bottom. Gale

Graph

The graph shows the input level along the bottom (x-axis) and the output level along the left (y-axis). Note that the graph always goes through the (0,0) point at the upper right - this is consistent with the "Make-up gain for 0 dB after compressing" option. The graph will change as you adjust the sliders.

Controls

  • Threshold: Sounds above this threshold will cause the compressor to reduce the level of the audio. It sets the horizontal (left to right) position of the corner of the blue line on the graph.
  • Noise Floor: Sets the level below which make-up gain will not be applied. This prevents the compressor from amplifying noise.
Steve the Fiddle When "Compress based on peaks" is NOT selected, the effect applies "downward expansion" below the Noise Floor. This will approximately compensate for the increase in gain produced by the "make-up gain" so the net effect is approximately unity gain below the Noise Floor.

When "Compress based on peaks" IS selected, the effect leaves sound below the Noise Floor unchanged, and upwardly expands between the Noise Floor and the Threshold, thus producing reduced (compressed) dynamic range above the Threshold.

Bill: OK, I'll accept that, but it implies that the noise floor setting is not relevant when "compress based on peaks" is not checked and "make-up gain" is not checked, right? And would you agree that the "upward expansion" cannot happen unless the "downward compression" takes place above the threshold?
  • 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 turned down. The Ratio sets the slope of the blue line on the graph above the corner.
  • Attack Time: How soon the compressor starts to reduce the volume level after it rises above the threshold. 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.
  • Decay Time: How soon the compressor starts to increase 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.
  • Make-up gain for 0 dB after compressing: Boosts the resultant audio after compression equally at all volume levels, to be as loud as possible without distortion. Because the compressor works by making loud sections quieter, you will usually want to do this. If this option is selected, the effect will be both to make the quiet sections of the audio louder, and increase the overall loudness.
  • Compress based on Peaks: The threshold setting will react to the peak values of the waveform rather than the average value.
When "Compress based on Peaks" is checked, make-up gain is always applied regardless of the setting of the make-up gain checkbox.
Steve the Fiddle No it's not. It appears to be because when "Compress based on Peaks" is checked the effect uses upward compression

Bill: OK, I've done some more testing. I can create cases where there is a slight difference when "make-up gain" is ON versus OFF. In one test I did you could further amplify the compressed wave by 1 dB when "make-up gain" was OFF.
But there's that "upward compression" (expansion?) description again. If you treat this effect like a black box, give it a known input and look at the output, this is what appears to happen when "compress based on peaks" is checked. 1) Downward compression is applied to sounds above the threshold. 2) An amplification factor "A" is calculated based on the new peak amplitude of the selection (but it doesn't always get it right). 3) Sounds with volumes above the threshold are amplified by this factor. 4) Sounds below the noise floor are not amplified. 5) Sounds with volumes between the noise floor and the threshold are amplified by a factor between 1 and "A" depending on where their pre-compression volume was. Of course it doesn't actually work that way in the code, but this is the net effect.

<rant on>IMO this effect has become way too complex. Here's Steve and me, two experienced audio engineers, debating the fine points of how this effect actually works. What we want on this page is something that novice users can understand. It has been said that Steve Harris' SC-4 compressor is too complex for novice users, but compared to what Compressor has become I am beginning to question that. And at least SC-4 behaves like a real-world hardware compressor. I've read Steve's very good description of the effect of the noise floor setting and how it changes based on the setting of "compressed based on peaks" and I understand now what it does - the difference is subtle put important. Do we want to expose novice users to these esoteric technical nuances? All they want to know is "does it make my song louder and how does it do it".<rant off>


Schematic example

Uncompressed:

A simple sine wave that drops off by 6 dB half way through the selection, to demonstrate how some compressors handle signals.

Uncompressed signal
After:

The attack part of where the compressor is working is clearly visible at the start of the audio.The release part still affects some audio that is beneath the threshold as the compressor gain change slowly ebbs out and the material fades back to normal level.

Compressed signal