Tuesday, January 18, 2011

What Are the Differences Between All Those Audio Formats?


Digital audio has been around a very long time so there’s bound to be a plethora of audio formats out there.  Here are some of the more common ones, what differentiates them, and what to use them for.
Before we talk about everyday audio formats, it’s important you understand the basics, and that means understanding PCM.  After that, we’ll tackle compressed formats.

PCM Audio: Where It All Starts

Pulse-Code Modulation was created back in 1937 and is the closest approximation of analog audio.  That is, an analog waveform is approximated in regular intervals.  PCM is characterized by two properties: sample rate and bit depth.  Sample rate measures how often (in times per second) the amplitude of the waveform is taken, and the bit depth measures the possible digital values.  In terms of audio formats, this is pretty much the foundation.
True sound, in the real world, is continuous.  In the digital world, it’s not.  Somehow this is more confusing with audio than with video, so let’s look at video as a point of comparison.  What we interpret to be “motion” or think of as “fluid” and constantly-moving is, in actuality, a series of still pictures.  In that same way, the amplitude of sound waves in a digital format isn’t “fluid” or constantly changing.  It’s changing based on certain criteria at pre-defined intervals.
Image from Wikipedia
I know there’s a lot here that may not be second-nature unless you’re an engineer, physicist, or an audiophile, so let’s pare it down further with an analogy.
Let’s say that the water flowing from an open faucet is your “analog” audio source.  The temperature of the water we can compare to the amplitude of an audio wave; it’s a property that needs to be measured so you can enjoy it properly.  Sampling is the number of times per second you dip your finger into the flowing water.  The more often you dip your finger into it, the more “continuous” the temperature changes become.  If you stick your finger into the running water 44,100 times per second, it’s almost like keeping your finger under there the whole time, right?  That’s the basic idea behind sampling.
Bit depth is a little trickier.  Instead of using your finger, let’s say you used a really crapper thermometer.  It basically said “Hot” for anything above room temperature and “Cold” for anything below.  Regardless of how many times you dipped it into the water, it wouldn’t really give you much useful information.  Now, if instead of just 2 options, let’s say the thermometer had 16 possible values which you could use to gauge the water temperature.  More useful, right?  Bit depth works the same way, in that higher values allow more dynamic changes in sound amplitude to be accurately portrayed.
As previously mentioned, PCM is the foundation for digital audio, along with its variants.  PCM attempts to model a waveform, in as much of its uncompressed glory as possible.  It’s special, it’s ready to be stuck in a digital signal processor, and it’s more or less universally playable.  Most other formats manipulate audio via algorithms, so they need to be decoded while playing.  PCM audio is considered “lossless,” it is uncompressed, and therefore, takes up a lot of hard drive space.

The Uncompressed Bunch: WAV, AIFF

Image by codepo8
Both WAV and AIFF are lossless audio container formats based on PCM, with some minor changes in data storage.  PCM audio, for most people, comes in these formats, depending on whether you use Windows or OS X, and they can be converted to and from each other without degradation of quality.  They are both also considered “lossless,” are uncompressed, and a stereo (2-channel) PCM audio file, sampled at 44.1 kHz (or 44100 times per second) at 16 bits (“CD quality”) amounts to roughly 10 MB per minute.  If you’re recording at home for the purposes of mixing, this is what you want to use because it’s full quality.
Image by CyboRoZ

Lossless Formats: FLAC, ALAC, APE

The Free Lossless Audio Codec, Apple Lossless Audio Codec, and Monkey’s Audio are all formats which compress audio, much in the same fashion that anything is compressed in digital world: using algorithms.  The difference between zipped files and FLAC files is that FLAC is designed specifically for audio, and so has better compression rates without any loss of data.  Typically, you’re seeing about half the size of WAVs.  That is, a FLAC file for stereo audio at “CD quality” runs roughly 5 MB per minute. 
The up-side is that if you want to do audio manipulation, you can convert back to a WAV without any loss of quality.  If you’re an audiophile and listen to a lot of music with dynamic ranges, these formats are for you.  If you’ve got a great set of speakers, cans, or earbuds, these formats will bring out the tones to showcase them.

Lossy Formats: MP3, AAC, WMA, Vorbis

Image by patrick h lauke
Most of the formats you see in day-to-day use are “lossy”; some degree of audio quality is sacrificed in exchange for a significant gain in file size.  An average “CD quality” MP3 runs about 1 MB per minute.  Big difference compared to PCM, no?  This is called compression, but unlike with lossless formats, you can’t really get that quality back once you strip it in lossy formats.  Different lossy formats use different algorithms to store data, and so they typically vary in file size for comparable quality.  Lossy formats also use bitrate to refer to audio quality, which usually looks like “192 kbit/s” or “192 kbps.”  Higher numbers means that more data is being pumped out, so there’s more preservation of detail.  Here are some details for the more popular formats.
  • MP3: MPEG 1 Audio Layer 3, the most common lossy audio codec today.  Despite a heap of patent issues, it’s still incredibly popular.  Who doesn’t have MP3s lying around?
  • Vorbis:  A free and open-source lossy format used more often in PC games such as Unreal Tournament 3.  FOSS fans, such as many Linux users, are bound to see plenty of this format.
  • AAC:  Advanced Audio Coding, a standardized format now used with MPEG4 video.  It’s heavily supported because of its compatibility with DRM (e.g. Apple’s FairPlay), its improvements over mp3, and because no license is needed in order to stream or distribute content in this format.  Apple fans will probably have plenty in AAC.
  • WMA:  Windows Media Audio, Microsoft’s lossy audio format.  It was developed and used to avoid licensing issues with the MP3 format, but because of major improvements and DRM compatibility, as well as a lossless implementation, it’s still around.  It was really popular before iTunes became champion of DRMed music.
Lossy formats are what you use for all of the stuff you listen to and store.  They’re designed to be an economy of hard drive space.  Which format you choose depends on what digital audio player you use, how much space you have, how big of a quality nitpicker you are, and a bunch of over variables.  Nowadays, computers will play anything, most audio players (except Apple’s, of course) will do multiple lossy formats, and more and more do FLAC and APE.  Apple sticks to MP3, ALAC, and AAC.

Isn’t Audio Quality Subjective?

Absolutely, it is.  Ultimately, it’s your ears that are consuming most of this stuff, but that’s more reason to think of quality seriously.  When I first started creating my digital music collection, I couldn’t really tell the difference between 128kbit MP3s and audio CDs.  To my ears, there was no noticeable difference.  Over time, however, I noticed that 256 kbit sounded much better, and after I got a really nice (and expensive!) set of headphones, I went back to audio CDs full time!  It also depends on the genre of music. 
Image by jonchoo
There are a LOT of variables here, folks, make no mistake about that.  It took a while before I settled on using FLAC for some music and 320kbps MP3 for the rest.  The point I’m trying to make is that you should experiment to see what works best for you and your music, but be aware that as your tastes change, your perceptions, your equipment, and the importance of quality will, too.
And all of this stuff get even trickier when you’re not just talking about music, but about voice tracks, sound effects, white and brown noise, etc.  There’s a whole world of sound out there, so don’t get discouraged!  By learning what you can and listening for yourself, you can use this info to your advantage in your future audio projects.  I’ll leave you with some of the best advice I’ve ever gotten: “do what just plain sounds good.

No comments: