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  


Gratitude Day 10: GIF

Thu 10 September 2026

Continuing my "Unsung Heroes, Human and Algorithmic" subseries in my September Gratitude series, I want to talk about GIF, the venerable and stalwart Graphics Interchange Format.

First of all, a little housekeeping: It's pronounced JIF, like the brand of peanut butter. If you insist on pronouncing it like you're having …

Category: Tech
Tags: Amiga   Computing   Entertainment   Gaming   Hobbies   Monthly themes   Non-religious post   Productivity   Retrocomputing  

Read More

Gratitude Day 9: Run-Length Encoding / PackBits

Wed 09 September 2026

I'm taking this little detour within my gratitude series because I want to explore some of the very basic algorithms that are an essential part of our daily lives, for which we have little awareness, and to which is given little thought or thanks.

Data Compression has always been a …

Category: Tech
Tags: ADHD   Computing   Hobbies   Monthly themes   Non-religious post   Personal favorites   Productivity   Retrocomputing  

Read More

Gratitude Day 4: Virtualization / Emulation

Fri 04 September 2026

I think I first heard about emulation in the early 1990s. Some kind of magical software could make your Mac pretend it was a PC, albeit quite slowly. It was very niche and expensive software, but it allowed folks to run software designed for a completely different architecture. Black magic …

Category: Tech
Tags: Computing   Gaming   Humor   Monthly themes   Non-religious post   Productivity   Retrocomputing   Translation  

Read More

Re: Praying to St Jude: counselling the re-Googlers

Sun 19 July 2026

Background/Reply

Kevin Boone wrote an excellent article about "de-googling," and how to counsel people who are encountering the "costs" of living the de-googled life.

I've been mostly de-googled since September 2021, and it of course hasn't been super easy. But I say "mostly de-googled" because I still have some …

Category: Ethics
Tags: Collaborations   Computing   Ethics   FOSS (Free and Open Source Software)   Monthly themes   Non-religious post   Productivity  

Read More

Vim Carnival Entry: "The Motion that Changed Everything."

Tue 02 June 2026

Fedifriend and fellow vim-addict Hyde is hosting what's called a "Vim Carnival", where someone sets a topic and encourages others to blog about the subject at hand concerning vim.

With permission, I'm going to slightly modify the subject to apply to nvi, but the option I will be explain also …

Category: Tech
Tags: ADHD   BSD   Collaborations   Computing   FOSS (Free and Open Source Software)   Linux   Non-religious post   Productivity   Retrocomputing   UNIX  

Read More
Page 1 of 7

Next »