Monday, June 2, 2008

How does MP3 Compression work ?

An MP3 CD contains more than a hundred songs while an audio CD holds around only fifteen songs.Find out how MP3 compression works in 4 simple steps:
1.Uncompressed audio present in audioCD:

The audio stream of an audio CD stores more data than your brain can actually perceive. For example,if two similar notes are played simultaneously, your brain can perceive only one of them. If two sounds are different but one is louder than the other, your brain may never perceive the quieter signal. This effect is called “Masking”.Humans cannot hear frequencies below 20 Hz or above 20 KHz.While hearing capacities vary among individuals, humans perceive midrange frequencies more strongly than high and low frequencies. The human hearing patterns have been researched and the entire process has been translated into mathematical models and can be represented in tables and charts.These reference tables and charts are built into the MP3 codec.
2.Identification Frames and Bitrate:

When you click on the “Rip” or “Grab” button after inserting an audio disc into your optical drive, the audio signals are broken into fragments called “frames”.Next, the encoder calculates the number of bits to be distributed to best account for the audio stream to be encoded. The reason being, the different portions of the frequency spectrum are encoded most efficiently using slight variants of the same encoding algorithm for optimal results.

Before moving on to compression, the MP3 codec takes into consideration the encoding bitrate specified by the user. This step determines how much of the available audio data will be stored, and how much will be dropped. Bitrate refers to the number of bits which are played per second. It is comparable to the resolution of an image—the higher the resolution, the better the quality of the image. Similarly, in an MP3 file, it is the bitrate which determines the audio resolution—the higher the bitrate, the greater the audio resolution.While you cannot control the degree of loss, you can control the number of bits per second to be devoted to data storage, which has a similar net result.
3.Discarding Redundant Frequencies not audible to humans:

The audio frequency for each frame is compared to the mathematical models of psychoacoustics which are stored as reference tables in the MP3 codec. From these reference tables, it can be determined which frequencies need to be rendered accurately, since they’ll be perceptible to humans. In addition to this,the codec also decides which frequencies need to be dropped or allocated fewer bits, since we wouldn’t be able to hear them anyway.The codec takes the bitrate into consideration as it writes each frame to the bitstream. If the bitrate is low, the redundancy criteria will be measured strictly,resulting in a lower-quality output as greater number of frequencies is dropped. If the bitrate is high, the codec will be lenient, and the end result will sound better.
4.Final Compression to shrunk in size:

The serial bitstream of frames is run through the process of “Huffman Coding”, which compresses the information throughout the sample. The Huffman coding does not work with the psychoacoustic model, but achieves additional compression. Thus,the entire process of MP3 encoding is a two-pass system:

1. The redundant data is discarded.
2. The relevant data is further shrunk,
resulting in an audio file that is 10 times smaller!

No comments: