To begin with, this is, admittedly, not very scientific, but it is neat.
Being an audiophile, I have found that audiophiles are much like economists: You put two of us together and you will get three opinions. I’ll cop to it: I’m usually the one with more than one opinion — it is a matter of adapting the medium to the situation. For example, FM radio sounds great. It also sucks. It really depends on what you are comparing it to, and what evil things the broadcast engineer has done with a compressor.
Anyway, the idea occurred to me the other day to try taking an excerpt of music and encoding it with different audio codecs and bit rates and see what sort of sound quality you get out of each. Given what was readily at my disposal, I chose the ubiquitous MP3, AC3, also known as A5/2, also known as Dolby Digital, of movie, television and DVD fame, and the open-source undedog, Ogg Vorbis.
But where to get some music that I can distribute? Well, I took a moment to speak with a friend of mine who is the front-man for a local blues band, Nite Train. With his kind permission, I bring you an excerpt of Short and Sweet from their album Best Man, which you can buy at CD Baby or on iTunes. In fact, I’d encourage you to buy it, because you’re going to fall in love with it from the 30-second excerpts below.
So let’s take a moment and talk about the codecs.
MP3 is now well over a decade old. Its primary advantage over other codecs is its ubiquity: everything plays it. There are even CD players that can play it. As such, if you have something you want to go everywhere, MP3 will get it there. Given a high enough bitrate, it sounds pretty good. Its major shortcoming is that it only supports monaural or stereo sound, no surround. As such, if you have what one of my friends has referred to as a fetish for surround sound (as I do), then this is going to be limiting for you. I used LAME to encode the MP3 samples.
AC3 is of a similar vintage to MP3, being the default codec on DVDs. It is also the codec used for the audio portion of digital TV programming in the US. It can be played by any DVD player, and software to play it is available for all computer platforms that have the ability to play video. It is not quite as wide-spread in acceptance as MP3, but it supports additional channel configurations, including monaural, stereo, three-channel stereo, three-channel surround, quadraphonic, four-channel surround and five-channel surround, plus all of the “point 1″ configurations of these, the most popular of which is 5.1. It has the additional advantage of being able to encode in threads if you have a multi-core or a hyperthreaded processor. There is a multithreaded MP3 encoder, but I have heard that its sound quality is pretty bad. I used Aften to encode the AC3 samples.
Ogg Vorbis (and the other members of the Ogg family: FLAC and Speex) is different from MP3 and AC3 in that it is entirely open-source. There are no secrets. It supports up to 48 channels, so surround sound is no issue. Its main drawback? It is only available on computers for the most part, few portable devices or other dedicated media players can play it.
I parenthetically mentioned Ogg FLAC and Ogg Speex a moment ago. I didn’t test these two codecs for specific reasons. FLAC is lossless already, so there would be no transformation on the audio. There is also no chance whatsoever that it would get the audio compressed down into the 96-192kbit/sec range, tending more towards rates like 350k at best. Speex is not intended for high-fidelity, and so would be out of its league, even at its highest quality settings; it is intended for voice only, much like the codecs used on cell phones (think about how wretched on-hold music sounds on a cell phone).
There are other codecs, too, AAC, for instance. This was a sort of a smash-and-grab operation, so I only used what I had on hand. As far as I know, I don’t have an AAC coder, and I certainly don’t have a WMA coder (I own no Microsoft products), so these were not tested.
For each codec, I encoded the stream at 96, and again at 192kbit/sec. All were done in stereo. Why 96? Basically, I wanted to give the codecs a difficult situation to deal with. Any codec can sound good at a high bitrate, but 96k is pretty low.
After encoding, I then decoded each back into wav files so that they can be heard by all web visitors without having to deal with compatibility issues. Below is the result, which is kind of surprising in some ways.
All three codecs sounded really good at 192k, but 96k was a different story. As such, I’m presenting the 96k versions here.
Short and Sweet excerpt - PCM (i.e. as it came off of the CD)
Short and Sweet excerpt - Ogg Vorbis
At 192k, all three codecs performed nicely. At 96k, however, notice how both AC3 and MP3 squash the cymbals behind the saxophone? Listen again. It sounds sort of like there is a slow fan flapping in front of the speakers in time to the music. No sign of that from Vorbis at 96, though, or if there is a sign, it is too slight for me to detect.
Being a computer geek, I should probably also mention software performance. Here, AC3 is the clear winner. Aften was able to encode the audio to AC3 in about 0.2 seconds, with Ogg posting a distant second place at 4 seconds, and MP3 bringing up the rear at 5 seconds. All of this encoding was done on an 1.6 GHz, dual-core Intel Atom processor. This processor is hyperthreaded as well as dual-core (and so Linux reports it as quad core), so I ran four threads with Aften; neither LAME nor the reference Ogg Vorbis coder support multithreading.
So, the next time someone asks me what codec is best, I’ll say Ogg Vorbis. Or maybe not. It depends on the medium. Regardless, maybe there is something to this whole “open source” thing, hmmm?