Gratitude Day 12: A-law & µ-law Audio Companding

Sat 12 September 2026

Our first foray into lossy compression will be in the audio realm, looking at a pair of companding algorithms (short for "compressing and expanding") used extensively in telecommunications: A-law and µ-law.

Now, these algorithms don't exactly belong to the same category of the more well-known audio codecs, such as MP3, AAC, Opus, or ATRAC (eww).

Actually, companding algorithms aren't technically codecs at all, they're more like reversible audio filters that help preserve audio quality (particularly aiming at human voice) when it is being compressed by other means. In particular, A-law and µ-law are used to preserve audio quality when a signal is being reduced from 16-bit audio (CD-quality) down to 8-bit audio (telephone quality). From a bird's-eye perspective, the mechanism is a little bit like Dolby Noise Reduction, which was an analog system used to reduced tape noise.

The basic idea* behind Dolby NR is that tape noise or tape hiss was limited to a certain set of audio frequencies, so if you reduced those frequencies with a notch filter, you'd reduce the noticeable tape hiss of the audio. But then, you'd also be reducing parts of the audio signal you'd want to hear, particularly higher-pitched vocals and instruments. So the simple genius of Dolby NR was to boost those parts of the audio signal first when recording the tape, then have the tape player reduce those frequencies during playback. So the part of the audio signal that carried the noise/hiss was reduced, but the parts of the audio signal the coincided with those frequencies were only reduced down to their original levels, and not artificially subdued.

* This description isn't complete, nor probably fully accurate, but it's in the ballpark. Talk to an audio engineer if you want greater detail, or spend some time reading the Wikipedia article.


Similarly, the *-law companding algorithms boost the dynamic range of the audio before compression, and then expand them back again upon playback. By dynamic range, I mean the difference between the loud and soft parts of a recording. If you've ever listened to podcasts in the car, you probably know what I'm talking about: when a recording isn't professionally processed by a sound engineer (and even sometimes when they are!), you will have one person speaking quietly, which forces you to crank up the volume to hear them above the road noise, and then the interviewer will interject something at their regular volume and nearly blow out your speakers/eardrums.

It's such an annoying problem that I've literally downloaded entire podcasts in bulk, processed them in bulk with ffmpeg, and saved them on my phone so I can listen to them without having to play volume-knob-jockey. By compressing the dynamic range of the podcast, I can comfortably listen to the entire thing at a set volume level.

So, similarly, the *-law algorithms take incoming audio, compress the dynamic range through a reversible mathematical formula, and then the audio is reduced down to 8 bits per sample. That's the part that's equivalent to "lossy audio compression," but isn't an actual part of the algorithm. The algorithm is more like a filter. Upon playback, the dynamic range is "expanded" (the opposite of compression) and played back. This has the benefit of having the best possible playback quality (given the fact that we're not doing fancy psychoacoustic coding) without radically changing the way the recording sounds.

Back to index

Category: Tech
Tags: Monthly themes   Music   Non-religious post   Podcasts   Productivity