Compression is crucial to sound recording and live sound mixing, but many musicians don’t understand exactly what it does. Compression is simple in theory but can be complex and subtle in practice.
A compressor reduces the dynamic range of sounds that pass through it. That sounds complicated, but it isn’t. “Dynamic range” is just the distance between the loudest and the quietest sounds in a recording or performance. Compression reduces this range by reducing the gain on sounds louder than some threshold, and/or increasing the gain on sounds quieter than some threshold.
In compressors designed for studio use, the user has detailed control over the low and high thresholds. In stompbox compressor sustainers, there is usually a single knob that controls both low and high thresholds.