How MP3 Files Work

The MP3 Format

If you've read How CDs Work, then you know something about how CDs store music. A CD stores a song as digital information. The data on a CD uses an uncompressed, high-resolution format. Here's what happens when a CD is created:

  • Music is sampled 44,100 times per second. The samples are 2 bytes (16 bits) long.
  • Separate samples are taken for the left and right speakers in a stereo system.

So a CD stores a huge number of bits for each second of music:

Let's break that down: 1.4 million bits per second equals 176,000 bytes per second. If an average song is three minutes long, then the average song on a CD consumes about 32 million bytes (or 32 megabytes) of space. Even with a high-speed cable or DSL modem, it can take several minutes to download just one song. Over a 56K dial-up modem, it would take close to two hours.

The MP3 format is a compression system for music. The goal of using MP3 is to compress a CD-quality song by a factor of 10 to 14 without noticeably affecting the CD-quality sound. With MP3, a 32-megabyte song on a CD compresses down to about 3 MB. This lets you download a song much more quickly, and store hundreds of songs on your computer's hard disk.

Is it possible to compress a song without hurting its quality? We use compression algorithms for images all the time. For example, a .gif file is a compressed image. So is a .jpg file. We create .zip files to compress text. So we're familiar with compression algorithms for images and words and we know they work. To make a good compression algorithm for sound, a technique called perceptual noise shaping is used. It's "perceptual" partly because the MP3 format uses characteristics of the human ear to design the compression algorithm. For example:

  • There are certain sounds that the human ear cannot hear.
  • There are certain sounds that the human ear hears much better than others.
  • If there are two sounds playing simultaneously, we hear the louder one but cannot hear the softer one.

Using facts like these, certain parts of a song can be eliminated without significantly hurting the quality of the song for the listener. Compressing the rest of the song with well-known compression techniques shrinks the song considerably -- by a factor of 10 at least. When you're done creating an MP3 file, what you have is a "near-CD-quality" song. The MP3 version of the song does not sound exactly the same as the original CD song because some of it has been removed.

Not all MP3 files are equal. Let's take a look at the different ends of the MP3 spectrum in the next section.