New Lossy Audio Codec 2003-10-11 22:29:19

While studying for a Fourier Analysis test some of my flatmates and I were discussing how well JPEG would encode music. Since both lossy audio codecs (MP3, Vorbis, etc) and JPEG operate on the same basic idea (discarding unimportant data in the frequency domain) we decided it would be an interesting thing to test.



So I wrote a shell script which does the following:

1) Takes a 10 second sample of an MP3 and converts it to 8bit 44100Hz raw PCM

2) Arranges the data into a square image and Jpegs it

3) Unjpegs it and converts back to raw PCM data

4) Creates a WAV from the raw sound



I used imagemagick and sox to perform all the necessary conversions.



Looking just at compression, JPEG performs very poorly compared to MP3. Obviously changing the JPEG quality factor made a big difference, but even at terrible quality the images were pretty large compared to the MP3.



We sat down, whipped out the abx program from the LAME source and very quickly decided that JPEG is not a great audio codec. At 95% quality the music was alright - similar quality to a 64kbps MP3. The music degraded quickly as we increased the compression. At 75% the music started sounding really horrible - with wierd artifacts unlike anything I had heard before. The samples were more or less recognisable up till about 20% quality factor, any less and we couldn't tell Al Dimeola from Springbok Nude Girls.



Several conclusions can be drawn from this test:

- Procrastination leads people to do all sorts of insane things

- MP3, Vorbis and the rest do all sorts of magic unrelated to just dumping data

- JPEG's habit of dividing an image into 9x9 pixel blocks produces some very strange artifacts, including what sounded like pre- and post-echos with up to a second delay



At this point some of the involved parties started blaming the fact that we were transcoding for the bad quality of the sound. Another student blamed my speaker cables. It was an interesting experiment. I was very surprised that the sound didn't come out completely mangled.