Adding sound to your web page

Sound can be added to web pages in two basic formats:

  • Sound or wave files are digital representations of sound, of the same sort as the tracks on an audio CD.
  • MIDI (Musical Instrument Digital Interface) files contain no sound at all. Instead they are instructions to a music synthesizer (such as the one in your sound card) telling it which notes to play, which instrument sounds to use, and other effects.

wave
Sound Files

Sound files come in a variety of formats:

  • Uncompressed sound files (sometimes called wave files). This category includes Windows wave (.wav), Macintosh AIFF (.aif), and Sun audio (.au) (which was the original web sound format). You can click these links to see how well your browser and computer handle the different formats. Ideally all should load in the same way and sound identical. Realistically all should at least sound. I've found that Macintosh AIFF is the format most likely to work on both older and newer browsers on both Mac and Windows computers. Windows wave files, on the other hand, often don't work with older Macintosh browsers.

    The size of a wave file depends on the duration of the sound, the number of bits (8 or 16) used to encode the data, the sampling rate in Hz, and whether the sound is monophonic or stereophonic. CD-quality stereo, sampled at 16 bits and 44,100 Hz, takes megabytes for just a minute or two. Recording in mono cuts the size in half, as does 8-bit encoding or 22,050 Hz sampling; all three would make a file one-eighth the size. Sampling at 11,025 Hz cuts it in half again; voice sounds good at that sampling rate, and music sounds "acceptable".

    Most of these options are not available with the primitive sound tools that come with Windows or Mac, but most PC sound cards come with a sound editor, and free- and shareware programs are available for Mac (see Dave Grasmick's Almost Everything You’ve Always Wanted to Know about Sound) and Windows (a few select programs at Tucows, even more at Winsite, and GoldWave, the program I use) that do even more.

  • MP3 stands for MPEG Channel 3 (and MPEG stands for Motion Picture Experts Group). It is the separate compressed audio track of an MPEG movie. MP3 can deliver CD-quality audio in smaller files than the uncompressed wave formats (although they are still huge). It is currently controversial, because it has been used to illegally distribute commercial CD tracks, but it is currently the best method of distributing CD-quality audio, because programs that play it are common. Here is a snippet of the Medieval carol Tempus adest floridum, courtesy of Tapia's Gold.

  • Streaming audio (the first, and perhaps still best, version was RealAudio) relies on a player (usually a browser plug-in) that plays the sound as it is received, rather than waiting for the entire file to download. CD-quality streaming audio does not work acceptably with a modem connection, so that the medium is most suitable for speech, which can be sent at a lower quality and still sound good. Streaming audio works best with a special server program. ITAC is currently able to stream RealAudio.

midi
MIDI Files

The sound of a midi file is produced by the sound synthesizer in your computer; even a well-made midi can sound terrible on a bad sound card. More important, even good sound cards can sound different, so that midi is not suitable if you want your audience to hear subtle differences in timbre.

Midi also cannot reproduce sounds that are not built into the synthesizer, such as spoken or sung words, unusual musical instruments, and most non-instrumental sounds. There is a file format called ".mod" that combines sounds and midi instructions; we won't consider it further here.

Here is an example of a midi file, Io non compro più speranza, by the Italian Renaissance composer Marco Cara. It is a simple hyperlink, but to a midi file rather than a web page. If you click it, and your browser and computer are capable of playing midi files, you should hear it.

It is possible to "embed" a midi or sound file so that it will play automatically when a page is loaded. Here is an example. This is not necessarily as good an idea as it might seem. Some browsers choke on embedded files, especially if there are javascripts on the same page. Not all of your audience will want to listen to your page every time, and the controls to turn the music off (if you choose to include them) will either look obtrusive at the top of the page, or be hard to find at the bottom. If you choose to embed music, make sure you have considered these things.

Space for this page is provided by California State Polytechnic University, Pomona. Although it is intended to further the educational mission of the University, the opinions expressed here are those of Curtis Clark, and do not represent official policy of the University.

© 1999, 2001 by Curtis Clark
jcclark@csupomona.edu

Midi files courtesy of
The Internet Renaissance Band