Book HomeWeb Design in a NutshellSearch this book

Chapter 24. Audio on the Web

Contents:

Basic Digital Audio Concepts
Using Existing Audio
Preparing Your Own Audio
Streaming Audio
Web Audio Formats
Choosing an Audio Format
Adding Audio to a Web Page
For Further Reading

Simple audio files found their way onto the Web in its earliest days when they could be linked to and downloaded like any other file. The drawback to this technique is that traditional audio files are generally quite large and may take a prohibitively long time to download. As the Web evolved, we've seen some major breakthroughs in web audio. First, streaming audio (files that play as they download) made long-playing audio and even live broadcasts possible. Then the MP3 format exploded into popularity around 1999. MP3's ability to crunch audio files to one-tenth their original size while maintaining very good quality made it a perfect solution for sharing music over the Internet.

Obviously, audio, even specialized for the Web, is a rich and complex topic that cannot be thoroughly treated in a single chapter of a Nutshell reference book. If you are interested in learning about all the ins and outs of creating professional-quality audio for a web site, I recommend starting with Designing Web Audio by Josh Beggs and Dylan Thede (O'Reilly, 2001). It contains information on recording, editing, and optimizing audio content, as well as in-depth discussions of popular web audio formats.

This chapter introduces general audio concepts and a number of popular web audio file formats, including WAV, AIFF, MP3, QuickTime, MIDI, RealAudio, Windows Media, Liquid Audio, Flash audio, and Beatnik's Rich Media Format. It also discusses the many options for adding audio to a web site. It begins with an introduction to basic audio terminology that will be useful to know when it comes time to create and optimize sound files.

24.1. Basic Digital Audio Concepts

In order to distribute recorded speech or music over the Internet, an analog signal must be converted to digital information (described by bits and bytes). This process is called encoding . It is analogous to scanning a photograph to a digital bitmap format, and many of the same concepts regarding quality and file size apply. Some audio file formats (such as MPEG) are compressed in size during encoding using a specialized audio compression algorithm to save disk space. In the encoding process, you may be asked to provide settings for the following aspects of the audio file.

Sampling rate

To convert an analog sound wave into a digital description of that wave, samples of the wave are taken at timed intervals (see Figure 24-1). The number of samples taken per second is called the sampling rate. The more samples taken per second, the more accurately the digital description can recreate the original shape of the sound wave, and therefore the better the quality of the digital audio. In this respect, sampling rate is similar to image resolution for digital images.

Sample rates are typically measured in kilohertz (KHz). On the high end, CD-quality audio has a sampling rate of 44.1 KHz (or 44,100 samples per second). On the low end, 8 KHz produces a thin sound quality that is equivalent to a transistor radio. Standard sampling rates include 8 KHz, 11.025 KHz, 11.127 KHz, 22.05 KHz, 44.1 KHz, and 48 KHz. The new emerging high-end standard is 96K, which may be seen in DVD audio but is not applicable to the Web. The higher the sampling rate, the more information is contained in the file, and therefore the larger the file size.

Figure 24-1

Figure 24-1. Audio wave after lowering sample rate and bit depth

Bit depth

Like images, audio files are also measured in terms of their bit depth (also called sampling resolution or word length). The bit depth corresponds to the resolution of the amplitude (or volume) of the sound file. The more bits, the better the quality of the audio, and of course, the larger the resulting audio file. This is similar to bit depth in images -- the more bits, the more colors the image can contain.

Some common bit depths are 8-bit (which sounds thin or tinny, like a telephone signal) and 16-bit, which is required to describe music of CD quality. High end digital audio is now capable of 20-, 24-, 32-, and 48-bit depths.

Channels

Audio files can support from one to six separate channels of audio information. The most familiar of these are mono (one channel) and stereo (two channels), but some formats can support three-, four-, or six-channel (also referred to as 5.1-channel) surround sound. Most file formats support only mono and stereo, but we will be seeing a lot more support for multichannel surround formats in the coming years.

Bit rate

Audio files are also measured in terms of bit rate, the number of bits per second devoted to storing audio data. Bit rate is a function of the file's bit depth and sampling rate, so you reduce the bit rate by reducing a combination of those settings. Bit rate is measured in kilobits per second (Kbps) and can be calculated by dividing the file size by the length of the audio clip in seconds. In general, it is advisable for the bit rate of streaming audio files to be lower than the bit rate of the user's connection to the Internet to ensure smooth playback.

It stands to reason that before you can put your own audio files on the Web, you first need to create them. Your options are to find existing audio resources (such as from a royalty-free CD) or to record them yourself.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.