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

Sound files come in a variety of formats:
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.

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