42
The audio codec specifies how to do #3—decoding the audio stream and turning it into
digital waveforms that your speakers then turn into sound. As with video codecs, there
are all sorts of tricks to minimize the amount of information stored in the audio stream.
And since we’re talking about lossy audio codecs, information is being lost during the
recording→encoding→decoding→listening lifecycle. Different audio codecs throw away
different things, but they all have the same purpose: to trick your ears into not noticing
the parts that are missing.
One concept that audio has that video does not is channels. We’re sending sound to
your speakers, right? Well, how many speakers do you have? If you’re sitting at your
computer, you may only have two: one on the left and one on the right. My desktop
has three: left, right, and one more on the floor. So-called “surround sound” systems
can have six or more speakers, strategically placed around the room. Each speaker is
fed a particular channel of the original recording. The theory is that you can sit in the
middle of the six speakers, literally surrounded by six separate channels of sound, and
your brain synthesizes them and makes you feel like you’re in the middle of the action.
Does it work? A multi-billion-dollar industry seems to think so.
Most general-purpose audio codecs can handle two channels of sound. During record-
ing, the sound is split into left and right channels; during encoding, both channels are
stored in the same audio stream; and during decoding, both channels are decoded and
each is sent to the appropriate speaker. Some audio codecs can handle more than two
channels, and they keep track of which channel is which so your player can send the
right sound to the right speaker.
There are lots of audio codecs. Did I say there were lots of video codecs? Forget that.
There are gobs and gobs of audio codecs, but on the Web, there are really only three
you need to know about: MP3, AAC, and Vorbis.
MPEG-1 Audio Layer 3
MPEG-1 Audio Layer 3 is colloquially known as “MP3.” If you haven’t heard of MP3s,
I don’t know what to do with you. Walmart sells portable music players and calls them
“MP3 players.” Walmart. Anyway...
MP3s can contain up to two channels of sound. They can be encoded at different
bitrates: 64 kbps, 128 kbps, 192 kbps, and a variety of others, from 32 to 320. Higher
bitrates mean larger file sizes and better-quality audio, although the ratio of audio
quality to bitrate is not linear. (128 kbps sounds more than twice as good as 64 kbps,
but 256 kbps doesn’t sound twice as good as 128 kbps.) Furthermore, the MP3 format
(standardized in 1991) allows for variable bitrate encoding, which means that some
parts of the encoded stream are compressed more than others. For example, silence
between notes can be encoded at a very low bitrate, then the bitrate can spike up a
moment later when multiple instruments start playing a complex chord. MP3s can also
be encoded with a constant bitrate, which, unsurprisingly, is called constant bitrate
encoding.
86 | Chapter 5: Video on the Web
Download from Library of Wow! eBook <www.wowebook.com>