Chapter 2. How MP3 Works: Inside the Codec

So what’s the trick? How does the MP3 format accomplish its radical feats of compression and decompression, while still managing to maintain an acceptable level of fidelity to the original source material? The process may seem like magic, but it isn’t. The entire MP3 phenomenon is made possible by the confluence of several distinct but interrelated elements: A few simple insights into the nature of human psychoacoustics, a whole lot of number crunching, and conformance to a tightly specified format for encoding and decoding audio into compact bitstreams. In this chapter, we’ll take a look at these elements in detail in order to understand exactly what’s going on behind the scenes of MP3 encoding and decoding software, as well as some of the chicanery that takes place between your ears.

Note that this chapter goes fairly deeply behind the scenes of MP3, and is somewhat technical in nature. You can skip this chapter if you’re not interested in learning how MP3 works. If you just want to get started creating and playing MP3 audio, you can skip ahead to Chapter 3, Chapter 4, and Chapter 5.

A “Perceptual” Codec

Well-encoded MP3 files can sound pretty darn good, considering how small they are. As mentioned in Chapter 1, your typical MP3 file is around one-tenth the size of the corresponding uncompressed audio source. How is this accomplished? That’s a somewhat complex topic, so we’ve devoted this entire chapter to explaining the process.

MPEG ...

Get MP3: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.