Older music format like LP records or cassette tapes used analog technology, where music was stored as a physical or magnetic representation of the original sound. CDs or MP3 files are digital, which means that the music is stored in a form of numbers. While CD uses an uncompressed, high-resolution format, the goal of MP3 is to compress audio while retaining a sound comparable to CD.

MP3 uses lossy data compression, or simply put, it throws away an audio information to reduce the file size. So what information is thrown away?

Psychoacoustics

Mostly the sounds with frequencies that human ear cannot hear. Or if there is some louder sound playing at the same time as softer ones, the algorithm ignores them. This technique is called perceptual coding or psychoacoustics. We can achieve reduction in size by a factor of 10. A 33-megabytes song on a CD can be compressed to about 3 megabytes.

Bitrate

Thanks to bitrate, which is the number of bits per second, it is possible to create tow different MP3 files with different sound quality and file sizes from the same input. Bitrate can usually range from 32 to 320 kilobits per seconds. With higher bitrate we get higher quality of the recording and vice versa. A bitrate of 128 kbps is probably the most common and usually results in a sound quality you would hear on the radio.

MP3 file structure

Let’s take a look at the structure of the MP3 file. The MP3 file consists of smaller parts called frames. each frame contains a header and a data block. MP3 header starts with a sync word, which is used to identify the beginning of a valid frame and is followed by information such as a bitrate, frequency or channel mode. The MP3 data block contains the actual audio information in terms of frequencies and amplitudes. Most MP3 files also contain the ID3 metadata, which store details of the track like a title, artist genre and so on.