An audio compressor is the complement to a expander, in that it reduces the dynamic range of a performance.
The compressor may be applied to a single instrument, or to a sub- or full mix. It contains a VCA which is controlled inversely by the level of the input. As the level rises, the amplification is reduced; though never to the extent that the overall level drops, but just so that the extra level is reduced. As the input level drops, the amplification is raised in the same manner.
The attack of the compressor may be fast, so that loud sounds are instantly compressed, or slow, so that, for instance, the initial sound of a drum will still pass unhindered. The decay is also controllable, and sets how quickly the compressor will recover, once the input level drops.
The net effect of the device is to pass the input to output with a disproportionate effect on the level. Loud sounds come out only moderately loud, and quiet sounds only moderately quiet.
A major use of a compressor is to get control of a vocalist who is not expert at controlling the level of their voice. Through the compressor, the level will be much more even. Another use is to add a sustain to guitar or piano sounds.
A 'perfect' compressor should not be audible in itself, but a non-linear compressor may be used to add character to the sound. The Joemeek range is a good example.