There are two types of compression. Data compression, and Dynamic Range Compression. In this post we'll be dealing with the latter. The former refers to how we mix RAW audio into formats such as .wav, MP3 and so on.
Compression is where the dynamic range, the difference between loud and soft stuff, is reduced. Contrary to what a lot of people believe, it doesn't just make stuff louder. More importantly, it can be used to drastically change something without altering the volume at all.
For instance, the most common real-world example of this exists in radio, specifically classical radio. Switch on your radio and tune into any local classical radio station, and you will notice something. The loud stuff and quiet stuff are at the same level. There is very little difference between a flute playing solo, and the entire brass section playing. Yes, the frequency spectrum is fuller and it sounds louder, but the actual volume doesn't change.
Why do they do this? Simple. Motorways/Highways are noisy places, and nothing sucks more than turning up the volume to hear a quiet part, only to be deafened by the whole orchestra playing a chord suddenly. So they compress it. You get a similar feel to the dynamics, but you can leave your dial at a comfortable level.
In terms of producing, there are multiple things you can do with a compressor. The most common controls are the following, along with what they are for:
Gain: Increases the output of the compressor.
Threshold: When the volume of the input reaches this level, it turns on.
Ratio: When it is turned on, how much it will compress the sound. It works like this, if the ratio is 2:1, if the sound goes up to 2dB, the output will be 1dB, halving the output. If it's 4:1, when the level reaches 4dB, it will be compressed to 1dB, quartering the output. In a nutshell, the higher the ratio, the more it's compressed. Normally it's best to experiment, you get a knack for it eventually.
Attack: How long it takes for the compressor to turn on once it is activated (In ms, usually)
Release: How long it takes for the compressor to turn off, how quickly the level drops back down, again, in ms.
Anything else is usually specific to the compressor and has it's own fancy name.
"But that makes no sense! You're not making stuff louder, you're making everything quieter!" While yes, that's semi-true, in the way that a compressor works, it's only making the loud stuff quieter, not everything. So by turning down the threshold, or increasing the ratio, you are controlling how much the loud stuff is being pushed further towards the quiet stuff.
So how is this useful? Well using compression on individual drums is always effective. A snare, for example, has a very loud attack and a gradual decay, but you can drastically alter how it sounds using a compressor. For instance, you can change that gradual decay into a very sharp one using the attack. If it takes a few moments to turn on, you get the initial impact of the snare, then the whole thing is squashed together, and you get all the harmonics within the snare being pushed to the foreground, and you get a completely different sound. Here is an example:
Drum loop without compression.
Drum loop WITH compression.
Can you hear the difference in the snare? This is but one of many different applications of compression, and learning how to use it effectively and not restrict yourself to just twiddling the presets until something sounds good can give a whole new life to not only your tracks but your sample library and sound palette.
A term you may run into is Parallel compression. Put simply, this is where you have the exact same sound duplicated, where you layer an uncompressed sample with the same sample with compression applied. This allows you to blend the two together, allowing you the same dynamic control of compression, and still retain the fullness of a raw sample. I have heard of people running into phasing issues within their DAW when using this technique–something I've never run across because most modern DAWs compensate for this, however if you do, you can either alter the sound of one of the samples drastically with EQ, or invert the waveform. (A common function within the audio/sample editor)
Finally, a brief note on Sidechain compression. While most people know what this does, they don't understand why, and just put a 4/4 kick drum loop on and then leave it at that. So what is the difference between normal and sidechain compression? Simply, the compressor is activated by another input than what is being compressed. For instance, a drum beat may be going above the set threshold of -4dB, but the compressor will only activate once the input goes over that level. Once it does, it behaves in the same way, and while this is useful for creating those 'pumping' sounds in electronic music, it can also be used very subtly, for instance when someone is singing along with a guitar, it can help bring out the voice if the guitar is compressed lightly when the voice is present. It can also be used in incredibly crazy ways, for making strange gated effects with high ratiosor controlling layers of complex soundscape pads.
If anything in this article is wrong, or if you have a better way of explaining it, throw it down below!