You can choose from several different types of sound files and formats, and you can add sound to a Web page in various ways. Some factors to consider before deciding on a format and method for adding sound are its purpose, your audience, the file size, the quality of sound quality you want, and differences in browsers.
Note: Sound files are handled very differently and inconsistently by different browsers. To improve consistency, you may want to save sound files as SWFs.
About audio file formats
The following list describes the more common audio file formats and some of the advantages and disadvantages of each for Web design. Some audio formats require that visitors to your site download and install a helper application or plug-in such as QuickTime, Windows Media Player, or RealPlayer.
The MIDI or MID (Musical Instrument Digital Interface) format is for instrumental music. MIDI files are supported by many browsers and don't require a plug-in. Although their sound quality can be very good, this 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. Use this format if you want background sounds to play when pages open up.
WAV (Waveform Extension) format 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.
The AIF (Audio Interchange File Format, or AIFF) format like WAV files, also 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 limits the length of sound clips that you can use on your Web pages.
The MP3 (Motion Picture Experts Group Audio, or MPEG-Audio Layer-3) format is a compressed format that makes sound files substantially smaller. You can use MP3 to convert large stereo WAV/AIFF files to a more manageable format without compromising on the sound quality, which is very good: if an MP3 file is recorded and compressed properly, it can rival a CD. You can 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 a whole song could still take quite a while to download over a normal phone line connection. To play MP3 files, visitors must download and install a helper application or plug-in such as QuickTime, Windows Media Player, or RealPlayer.
The RA, RAM, RPM, or Real Audio format has a very high degree of compression with smaller file sizes than MP3. Whole 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. The sound quality is poorer than that of MP3 files, but new players and encoders have improved quality considerably. Visitors must download and install the RealPlayer helper application or plug-in in order to play these files.
The AU, SND, or Sun or Java format is similar to the WAV and AIFF formats, but the compression is more flexible. This format is used exclusively for Java applets and applications and therefore is compatible across platforms. It is also very popular on SUN/Unix machines.