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 6: Music

Sun 06 September 2026

I wrote about personal music libraries on Day 2, but I'm just talking about music in general now.

I think music is so commonplace and accessible that we often forget what a strange miracle it is. How would you explain music to a completely alien being that had no concept …

Category: Life
Tags: Beauty   Entertainment   Humor   Language   Life   Monthly themes   Music   Non-religious post   Non-technical post   Personal favorites   Philosophy   Prose  

Read More

Gratitude Day 2: Personal Music Libraries

Wed 02 September 2026

Over the past few years, I've been on a journey of migrating from streaming services to personal music libraries. I haven't yet made the jump from streaming video services to personal video libraries, but it's definitely on my radar.

I got an Apple Music account right about when it first …

Category: Entertainment
Tags: Beauty   Entertainment   Life   Monthly themes   Music   Non-religious post   Non-technical post  

Read More

The Mad, Joyful Chaos of the Creative Process

Thu 15 January 2026

After yesterday's unhinged, painfully cathartic threnody of a post, I really wanted to post something short, light and enjoyable. I was considering writing down my thoughts on my favorite TV show, The Good Place, but that would have taken altogether much too long, so that is going to remain a …

Category: Entertainment
Tags: ADHD   Beauty   Entertainment   Humor   Music   Non-religious post   Non-technical post   The Good Place   Writing  

Read More

Songs to Improve Your Mental Health

Wed 23 July 2025

Background

I'd be fooling myself to think that I could be the first person on the earth to note music's incredible ability to heal and salve the tormented human soul. My own journey with music is, well, unsurprisingly, about as old as I am. Most everyone on one side of …

Category: Life
Tags: 100DaysToOffload   Beauty   Entertainment   Personal favorites   Life   Music   Non-religious post   Non-technical post   Philosophy   Prose   Video  

Read More

Anker SoundCore P30i mini-review

Tue 22 July 2025

Time for another little hardware review.

Background

I've been getting complaints that the small, inexpensive bluetooth earbuds (Skullcandy Dime XT/XT2) I had been carrying around for the past five years have pretty poor audio quality during phone calls (likely no microphone noise cancellation), so I started looking around again …

Category: Tech
Tags: 100DaysToOffload   Entertainment   FOSS (Free and Open Source Software)   Music   Non-religious post   Non-technical post   Polemic   Productivity  

Read More

Magical Moments

Fri 01 November 2024

This article is written based on a prompt I shared with a friend a couple weeks ago. You can my article from that "round-robin" prompt exercise here.

Since neither of my fedifriends have written their prompts yet, I'm actually borrowing the idea I gave Amin to write:

I'm going to …

Category: Life
Tags: Beauty   Computing   Entertainment   Hobbies   Life   Music   Non-religious post   Non-technical post   Philosophy   Prose   Retrocomputing   WritingMonth  

Read More
Page 1 of 2

Next »