Audio on your web page – Basics

Requirements: a sound card with audio software on your computer to create a sound file, and a sound card on the user’s computer. Also, as for graphics, you need to consider file size, download/wait time, and you need to decide whether or not to give the user the option of hearing the sound file.
 

Creating a sound file – WAVE format -- examples

  1. Using a tape recorder, you can record voice or music.
  2. Then plug a cable into tape recorder line out (this is usually the plug used for the headphones) and plug the other end into the sound card line in.
  3. Open your audio application and select the recording source, e.g., tape or CD.
  4. Click Record while playing your tape or a CD. Then click Stop and save as *.wav.
  5. Open your Wave editor, edit your file, save.
  6. OR you can use a keyboard to produce music in MIDI format.
  7. OR you can download a freeware sound file from the Web.
Sound file properties -- Streaming or not
Streaming audio is used on sites where you listen to a radio station on the web. Find out if your web page server supports this, then do some research into what you need to buy to produce this.

When streaming audio is not available

  1. Formats and file size (these affect download/wait time): music MIDI files are very small but voice or music WAVE or AU or AIFF files (the most common formats) can be very large and should be compressed even when they last only a few seconds. Example: I recorded 13 seconds of sound in the ITC corridor, 16 bit stereo 44,100 hz: this is a 2.5 M file and definitely needs to be compressed. For voice, you need only 8 bit mono but the file size will still be big.
  2. The formats currently recognized by most browsers are WAVE, AU, AIFF, MIDI.
  3. Compress any sound file other than one in MIDI format, using software and choosing a “codec” (compression encoder and decoder) that works for all platforms desired: Recommended: IMA ADPCM (International Multimedia Association Adaptive Differential Pulse Code Modulation) providing high bit-rate low complexity compression for Windows 95 and NT, Unix, Macintosh Media Players. If you are using Netscape, you may want to download, install and use Netscape Media Converter to do this. Example: My 13 second 2.5 M 16 bit stereo WAVE file is now 155 K 4 bit stereo.
The sound file on your web page -- filename for this example is test.wav
You need to decide on one of the following options:
  1. embed it so that every time the user comes to that page he hears it – this can be annoying especially when repeated
  2. add an image or button for the user to click, to play the sound file or not
  3. make the sound player visible--giving the user a way to stop the sound.
Code for embedding a sound file, repeated again and again for the page, for option 1, or heard just once
  1. Embed: edit the source code for your page: for Netscape, place the following code right after the <body> tag, on a new line: <embed src=”test.wav” autostart=”true” hidden=”true” loop=”true”>, then press Enter – and on the next line, for Internet Explorer, type the following line: <bgsound.scr=”test.wav” loop=infinite”>. To hear the sound file just once, change loop=”true” to “false”.
  2. Code for embedding a sound file, with the player visible so the user can stop the sound: change hidden=”true” to hidden=”false”.
Giving the user the option of playing the sound file
Link a sound file to an image: Put an image on your web page and add instructions. Select the image, click Insert, Link, choose your sound file as the link.


No sound is heard
Make sure that your computer has a sound card and that your browser has a plug-in for playing the sound file. In Netscape, go to Edit, Preferences, Navigator, Applications, and check for the extension of your sound file (WAV in our example here).


Professor Ursula Hoffmann May 2001