How Does Audio Compression Work?
The goal in audio compression is to reduce the number of bits required to accurately reproduce an analog sound. The first process we’ll look at is called “lossy.” Lossy compression is a one-way technique that throws away non-critical data to save space. These techniques are the most common methods used to compress audio files, showing up in MP3, AAC and WMA files alike. There are two places that lossy codecs look to save bits: bit rate and psychoacoustics.
Bit Rate
Bit rate measures the amount of bits used to encode a single second of audio. For example, if we use low-quality, 8 kilobit-per-second (kbps) encoding, our algorithm is limited to using only 8 kilobits of data to describe each second of audio. That’s like trying to describe a full-color photograph with only a few hundred pixels. You might get the broad strokes right, but overall you’ll be looking at a severely degraded image. If we use a higher-quality bit rate like 192 kbps, we have plenty of room to cover nuanced details. To return to our photographic example, we now have enough pixels to describe the various lights, darks and colors in an image. A high bit rate doesn’t determine the quality of a recording on its own, but a low bit rate can severely limit output quality.
Psychoacoustics
Psychoacoustics is the science of how the brain understands sounds. By manipulating known quirks in the way humans perceive sound, compression algorithms can cleverly remove details that most human ears won’t miss. The goal is to “round off” information that won’t change the perceived audio quality of a track, judiciously removing only unimportant information. For example, you might know the typical range of human hearing is between 20Hz and 20kHz. Obviously, sounds outside that range can be removed. Furthermore, the most detailed range of human hearing is between 100Hz and 4kHz, and removing quiet sounds outside those frequency ranges does minimal damage to the quality of a recording. We can do a similar trick with highly contrasting sounds. If a very loud sound and a very quiet sound play at the same time, the quiet sound is much harder to perceive than it would be on its own. Encoders take advantage of this “sound masking” to remove the quiet sound, saving bits in the process. Frequency can also impact how well we perceive sounds. For example, a persistent, low-frequency drum beat tends to drown out the more delicate, higher-frequency harmonics of melodic instruments. And sound masking is especially effective above 15kHz, where human hearing is typically less sensitive to begin with. Common audio compression schemes like MP3 take advantage of the full range of compression possibilities while attempting to remain as faithful to the original recording as possible. Of course, some folks feel like removing these frequencies does serious damage to the recording. That’s why lossless compression standards exist.
What Is “Lossless” Audio?
Lossless audio compression’s goal is to reduce file size while leaving the original audio untouched. These codecs don’t use any of the permanent compression techniques above, focusing instead on fully-reversible data compression methods. They use lossless compression techniques borrowed from file-compression algorithms like ZIP to remove redundant data while preserving the integrity of the underlying information. Two popular lossless audio codecs – FLAC and Apple Lossless (ALAC) – both use schemes based on ZIP compression. Focusing on data compression only means preserving many of the details that MP3 and other lossy standards would obliterate. If you have sharp ears and a high-quality listening setup, the difference can be palpable. Lossless compression isn’t only good for listening, though: it’s also a great storage tool. Just like you wouldn’t want a 72dpi JPG to be the sole digital copy of Ansel Adam’s photographs, we don’t want only 128kbps MP3s of “Kind of Blue.” Lossless standards like FLAC allow us to store audio efficiently without throwing away potentially valuable data. They also make remastering and redistributing that audio easier, since starting with uncompromised masters means a higher quality finished product.
Conclusion: Can You Tell the Difference?
Lossless audio formats allow for better sounding recordings. But sometimes the differences between a high-quality MP3 and a lossless file are nearly imperceptible, especially to the untrained ear. If you want to see if your headphones (and ears) are keen enough to tell the difference, NPR has a fun test; just keep in mind that cheap headphones and laptop speakers won’t be able to reproduce the subtle differences between lossless audio and MP3s. For a more serious analysis of codecs, check out SoundExpert’s encoder ratings.