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  


Mocking-up Photo Sharing over SMS

Sat 18 April 2026

Background

I've been catching up on one of my favorite podcasts, recently: Tuxjam, and I just finished listening to Episode 120: Tunnels & Texts.

In this episode, they were reviewing a FOSS app called Deku SMS which initially seemed to promise the ability to send photos by SMS (not MMS!), but …

Category: Tech
Tags: Computing   FOSS (Free and Open Source Software)   Hobbies   Non-religious post   Personal favorites   Podcasts   Productivity  

Read More

How I Watch YouTube

Fri 06 December 2024

I was listening to one of my favorite podcasts, TuxJam the other day, and they were discussing ways to watch YouTube without the annoyances that Google has added to the experience, namely ads and the inability to download videos for later viewing (also, YouTube stopped letting you listen to videos …

Category: Tech
Tags: Computing   Entertainment   Ethics   FOSS (Free and Open Source Software)   Linux   Non-religious post   PeerTube   Podcasts   Productivity   UNIX   Unix Tips   Video  

Read More

My Every Day Carry, Part V: What's on My Phone?

Sun 24 November 2024

In Part IV, I discussed wristwatches. In this article, I'm jumping back into my pocket, so to speak, with a look at what's on my phone itself.

This was a rather exhausting article to write, because I have a lot of apps on my phone. I have even been ridiculed …

Category: Tech
Tags: Computing   Ethics   Federated Services   FOSS (Free and Open Source Software)   Non-religious post   PeerTube   Podcasts   Productivity   Translation   WritingMonth  

Read More
Page 1 of 1