Audio compression and codecs

a primer on Digital Audio for streaming music to a device such as a mobile phone or wireless headphone. It is intended for the digital producer and the interested consumer.

Audio compression and codecs
Balloon being uncompressed.

This article is a primer on Digital Audio for streaming music to a device such as a mobile phone or wireless headphone. It is intended for the digital producer and the interested consumer.

Uncompressed digital audio files are large. Compare it to a full balloon. To squeeze the size of  the data for audio in smaller files, it needs compression while being transported (streaming).

There is compression that is lossless (great for portability) and lossy (for standard playing and streaming). The lossless compression will not touch the recorded audio, while lossy will alter it slightly. So if you need to do further work on audio, save it uncompressed or compress it lossless.

So here are three categories of digital audio files:

  1. Uncompressed (WAV, AIFF, AU, PCM)
  2. Lossless compression (FLAC, ALAC)
  3. Lossy compression (MP3, AAC, WMA, OGG)

The codec is software that compresses an audio file. The word derives from Coding and Decoding. There are different types of codecs. Some examples: AAC, MP3, WAV, WMA. If the process of encoding or decoding needs to scale up or speed up, there are dedicated hardware solutions.

Here is an overview to give an impression on how much a stream can be compacted with different codec and bitrate:

Codec Bitrate Filesize
AAC 160 kbps 16.3 KB
AAC 256 kbps 21.8 KB
MP3 128 kbps 13.4 KB
MP3 256 kbps 26.8 KB
FLAC 432 kbps 53KB
WAV 1411 kbps 155KB
AIFF 2 mbps 250 KB

Wireless headphones and compression

In order to go from source to wireless headphone, the audio also needs to be compressed. That is good to keep in mind if you have fine ears and stream uncompressed audio. Knowing which codecs are supported on your devices will help create an optimal wireless audio experience.

At a minimum, make sure your Bluetooth audio devices support AAC as that will give you a solid experience across the biggest range of devices.

Apple only supports SBC and AAC on its devices. Everything purchased or streamed via iTunes or Apple Music is encoded over AAC. The only exception is the Mac, which supports aptX.

To illustrate the point of Digital to Analogue conversion

By the way, headphones that use a Lightning cable or Bluetooth have a Digital to Analogue Converter (DAC) inside the headphones. These include Apple's AirPods and EarPods (the wired ones with the lightning plug). It means that audio comes out of the device as a digital stream and is converted to analogue waves in the headphones.

Further reading

In an article on audio ecosystems, I show how well tuned components can deliver a consistent and high quality audio experience:

Audio ecosystem examples
Examples of audio ecosystems. The interconnected parts and the type of hardware and compression in the flow from digital stream to ear.

If you want to get a basic understanding of how digital audio actually works, I wrote this primer where I get creative with a physical metaphor of stacks of paper:

Digital audio explained with stacks of paper
Different aspects of Digital Audio explained and demo’ed.