What is the math behind audio compression?
Audio levels are measured in decibels. To be more correct, the levels of two audio signals can be compared in decibels. One signal, for instance, could be ten decibels (10 dB) louder than another. Or there could be a single signal and you raise it in level by 10 dB.
A difference or change in level of 1 dB is hardly noticeable to most people. 3 dB should be just noticeable to most people, and obvious to audio experts. 10 dB is a significant change. 20 dB is a big change.
A real-world example
If a vocal recording, for instance, is mostly quiet during the verse of a song, then rises in level during the chorus this can create the problem that it is too quiet during the verse and too loud during the chorus. Or you could set it so that it is just right during the verse, but then it is way too loud in the chorus. Or you could set it so that it is just right in the chorus, but way too quiet in the verse.
Let's suppose that the vocal is around 12 dB louder in the chorus than the verse...
Setting the ratio control of the compressor
If you set the ratio control to 2:1, this means that for every 2 dB the input signal level rises (above the threshold setting, but that's another explanation for another day), the output signal from the compressor will rise only 1 dB.
So in this case the level of the vocal would rise by only 6 dB during the chorus, rather than the original 12 dB.
This might work, or you might need more compression.
So set the ratio to 3:1. Now for every 3 dB the input signal rises, the output signal from the compressor will rise only 1 dB.
So the chorus will be 4 dB louder than the verse.
One more example... Set the ratio to 4:1. Now for every 4 dB the input signal rises, the output signal from the compressor will rise only 1 dB.
So the chorus will be 3 dB louder than the verse. This might work - the chorus is often louder than the verse. Or you could raise the compression ratio further to control the level even more strictly.
4:1 is a useful compression ratio for vocals. 10:1 would be quite a lot of compression. 20:1 would be extreme, but don't be afraid to use any ratio that you think helps the song.
The math is simple. With a 2:1 ratio, when the input level rises by 2 dB, the output will rise by 1 dB.