Sunday 19 October 2014

How lossy is mp3 format anyway




In order to listen to our music we are going to export our raw audio data to mp3 file. Such file is perfect media to listen to on a mp3 player. It is a small stereo file characterized by 48000 Hz sample rate and 256 bit rate, two parameters that define how much memory will computer use to remember the file.

During the process of making a mp3 file, a compression algorithm will apply smart techniques to downsize the file size (like ZIP format for example) but if necessary it will also discard some information (like JPG format for example). The resulting mp3 format is because of this possible information discard considered a "lossy" format.

How lossy is mp3 format compared to lossless FLAC format? And does it degrade music quality much? The question has to do with nature of the very compression algorithm. In comparison to similar algorithms, is it more like a lossy JPG or more like lossless ZIP.


Sample rate



After sampling down to 48 kHz, the first visible difference is noticeable only when picture is zoomed to 1 millisecond. Still both shapes of the curves representing sound are aligned sufficiently enough. Take into account that air pressure in the room where you listen to music is making more difference than these two signals, then we can safely say that FLAC format here is so far no different than mp3.



Bit rate


Bit rate refers to the number of bits, or the amount of data, that are processed over a certain amount of time. The higher the bit rate of a track, the more space it will take up on your computer. Generally, a raw audio will actually take up quite a bit of space, which is why it's become common practice to compress those files down so you can fit more on your hard drive. It is here where the argument over "lossless" and "lossy" audio comes in.

At this point, to ensure our mp3 file will be as good as possible we have to dedicate it some bit rate. Let's see how much bit rate is required for our amount of data.

Our raw format downsampled to 48000 samples per second at 32 bit depth, times 2 for 2 stereo channels equals

48000 sample/s * 32 bits/sample * 2 = 3.072 kbps

Meaning a second of our raw music is accurately defined by 3.072 bits. On hard disk that would be about 0,38 mega bytes. However, to compress the file into mp3 format, we will dedicate 256 kbps for it, twelve times less than required and hope that this rate can keep up the pace.



The experiment


The following test analyses the "lossiness" of mp3 format. The test is made by comparing the two formats.

The results show that although lossless FLAC format would in theory require 38 MB, the process can make 8,92 MB out of it. Our guess is this detailed curve can be without any loss further compressed 4,29 times, let's call this ratio harmless further compression.

File mp3 on the other hand comes out small, with a ratio that is about 3 times bigger that harmless compression. We can therefore imagine that 3 out of 4 samples has to been not discarded, but rather rounded to the nearest height, to make it to such compression ratio.



Conclusion


Judging by ear, when deciding weather one should keep his music in this or that format, we can all in all  claim that mp3 format, providing it is 48000 kHz 256 bps is still pretty close to original.

No comments:

Post a Comment