You can add sound to a web page. There are several different types of sound files and formats, including .wav, .midi, and .mp3. Some factors to consider before deciding on a format and method for adding sound are its purpose, your audience, file size, sound quality, and differences in browsers.
Sound files are handled very differently and inconsistently by different browsers. You may want to add a sound file to a SWF file and then embed the SWF file to improve consistency.
The following list describes the more common audio file formats along with some of the advantages and disadvantages of each for web design.
.midi or .mid (Musical Instrument Digital Interface)
This format is for instrumental music. MIDI files are supported by many browsers and don’t require a plug‑in. Although their sound quality is very good, it can vary depending on a visitor’s sound card. A small MIDI file can provide a long sound clip. MIDI files cannot be recorded and must be synthesized on a computer with special hardware and software.
.wav (Waveform Extension)
These files have good sound quality, are supported by many browsers, and don’t require a plug‑in. You can record your own WAV files from a CD, tape, microphone, and so on. However, the large file size severely limits the length of sound clips that you can use on your web pages.
.aif (Audio Interchange File Format, or AIFF)
The AIFF format, like WAV format, has good sound quality, can be played by most browsers, and doesn’t require a plug‑in; you can also record AIFF files from a CD, tape, microphone, and so on. However, the large file size severely limits the length of sound clips that you can use on your web pages.
.mp3 (Motion Picture Experts Group Audio, or MPEG-Audio Layer‑3)
A compressed format that makes sound files substantially smaller. The sound quality is very good: if an mp3 file is recorded and compressed properly, its quality can rival that of a CD. mp3 technology lets you “stream” the file so that a visitor doesn’t have to wait for the entire file to download before hearing it. However, the file size is larger than a Real Audio file, so an entire song could still take quite a while to download over a typical dial‑up (telephone line) modem connection. To play mp3 files, visitors must download and install a helper application or plug‑in, such as QuickTime, Windows Media Player or RealPlayer.
.ra, .ram, .rpm, or Real Audio
This format has a high degree of compression, with smaller file sizes than mp3. Entire song files can be downloaded in a reasonable amount of time. Because the files can be “streamed” from a normal web server, visitors can begin listening to the sound before the file has completely downloaded. Visitors must download and install the RealPlayer helper application or plug‑in to play these files.
.qt, .qtm, .mov or QuickTime
This format is both an audio and video format developed by Apple Computer. QuickTime is included with Apple Macintosh operating systems, and is used by most Macintosh applications that use audio, video, or animation. PCs can also play files in QuickTime format, but require a special QuickTime driver. QuickTime supports most encoding formats, including Cinepak, JPEG, and MPEG.
In addition to the more common formats listed above, there are many different audio and video file formats available for use on the web. If you encounter a media file format that you are unfamiliar with, locate the creator of the format for information on how best to use and deploy it.
Linking to an audio file is a simple and effective way to add sound to a web page. This method of incorporating sound files lets visitors choose whether they want to listen to the file, and makes the file available to the widest audience.
Embedding audio incorporates the sound directly into the page, but the sound only plays if visitors to your site have the appropriate plug‑in for the chosen sound file. Embed files if you want to use the sound as background music, or if you want to control the volume, the way the player looks on the page, or the beginning and ending points of the sound file.
When incorporating sound files in your web pages, carefully consider their appropriate use in your web site, and how visitors to your site use these media resources. Always provide a control to either enable or disable the playing of the sound, in the event that visitors don’t want to listen to the audio content.