Lossy and Lossless Compression

MP3 v FLAC - whats the difference?

(and how to baffle your friends with science)


Lossless is a horrible word - it wouldn't be my choice - but it's the L in FLAC (Free Lossless Audio Compression). It's a double negative - so that that's a positive - but it comes across as two bits of bad news.

A better word would have been reversible. You can convert a piece of music to FLAC and back again and it's the same. You can do it a million times - still the same.

But FLAC makes the music smaller how is that possible?

Well it's just like Morse code. Sam Morse gave common letters shorter codes.

So e is “.” and t is “-” and they just happen to be the most frequent letters in English. Typical English messages are shorter in Morse code because of this.

That's it. It's called entropy coding and it's one of a couple of tricks FLAC uses to compress music reversibly. Music compresses to about 60% with FLAC.


So what’s MP3 and Lossy compression?

Here’s a simple example of lossy compression.

Th Qck Brwn Fx Jmpd vr th lzy Dg

I’ve made the message shorter but it remains intelligible.

That's it. That's the heart of lossy compression - throw away stuff that leaves the message intelligible.

MP3 is one of a handful lossy compression formats that work in the same way - notably AAC from Apple. You may not realise it but Bluetooth and most streaming internet services like Internet Radio, Spotify, iTunes all use lossy compression.

Lossy compression throws away information that our brains either do not notice or can fill in. You can compress sixfold and get OK sounding music. Generally there is a trade off. You can compress more and the sound gets increasingly distorted and unpleasant. There are always artefacts though and particular sounds always cause difficulties - Wikipedia.

MP3 is history.

MP3 came to prominence in the early days of the internet when we used those squawking modems and hard disks were measured in megabytes. It just so happened that MP3 could compress music enough that you could listen to low quality music with a modem. That gave rise to internet piracy, Napster, MP3 players, the iPod and the collapse of the music industry

The thing is internet speeds and hard disk capacities have increased so much - there is now no real argument for us listening to MP3 or AAC - apart from profit. Poorer sound quality means less data which means more profit for streaming services.

Over the years I’ve written three MP3 decoders and two MP3 encoders on different microprocessors and digital signal processors. They use a bunch of impressive sounding techniques - predictive coders, cosine transforms, power laws, quantisation and the wonderful sounding psycho acoustic masking - but at their core it's basically Morse code and throwing away the vowels.