Полезная информация

Special Edition Using HTML 4

Previous chapterNext chapterContents

- 23 -

by Mark R. Brown

Playing Audio Files

There are three different kinds of audio files your computer can play: digitized audio, music files, and text-to-speech. Text-to-speech is a technique for converting text files into (somewhat) recognizable speech by replacing the letters with phonemes. The Macintosh is particularly adept at this. Music files are like sheet music--they specify a sequence of notes and the "instruments" to play them. MIDI music files are the most popular format in this category. Digitized audio is sound that has been run through an analog-to-digital converter to turn it into data. Your PC's system sounds are WAV format files that are digitized audio.

NOTE: Audio CD tracks are also digitized audio files, but they are decoded and played directly by your CD player's circuitry. As you may have found out at one time or another, your computer can crash and potentially leave an audio CD playing happily away, blithely unaware of your system failure.

Audio plug-ins are available for all varieties of digitized sound files, as well as MIDI music and speech. When you want to add audio to an HTML document, you'll likely rely on one of these plug-ins to play your sounds. This chapter steps through many of the most popular audio plug-ins for browser programs, and tells you how to add plug-in-compatible sounds to your HTML documents.

Audio Hardware: What You Need

Back in the "good old days" of personal computing--when "PC" was always followed by "XT", processor numbers were only four digits long, and software ran directly off floppy disks--every PC shipped with a tinny little AM-radio quality speaker that beeped nastily at you any time you did something wrong. Some masochists (the kind who like to scrape their fingernails on blackboards) even wrote a few annoying DOS programs that played what they claimed to be digitized sounds on that little speaker. But no normal human being ever heard a single recognizable sound in the cacophonous din that emanated from a PC when those programs ran.

Now that we're in the high-tech age of multimedia computers--complete with 24-bit True Color animations, 16-bit stereo music soundtracks, and digitized CD-ROM voice-overs by the likes of Star Trek's Patrick Stewart--all PCs still ship with that same nasty, tinny little speaker.

To get real audio out of your PC, you need a sound card. If you bought your computer recently, or if you've spent a few bucks upgrading, the odds are good you already have a sound card. If you don't, you can pick one up for anywhere between $30 and $800, depending on what you want it to do.

A good 16-bit stereo Sound Blaster Pro (or compatible) sound card does just about everything the average person needs done audio-wise, and does it for under $100. If you haven't invested in a sound card yet, drop this book right now, scan a few computer magazine reviews and ads, run to your local computer store, buy a sound card, and plug it in. You'll need one for any sound player plug-in you might choose to use.


Because it ships with Netscape Navigator 3.0 and beyond, the LiveAudio plug-in is essentially the "official" Netscape audio player. Unlike many other audio plug-ins, LiveAudio doesn't use a proprietary sound-file format, but instead plays industry standard AIFF, .AU, MIDI, and .WAV files. LiveAudio features an easy-to-use console with play, pause, stop, and volume controls.

NOTE: Over 70 percent of the people surfing into your site will be using Netscape Navigator as their Web browser. About 25 percent will be using Microsoft Internet Explorer. Both handle most audio in the same way, via an audio player plug-in. "Netscape" plug-ins are 99.99 percent compatible with Internet Explorer, so what we say here about them applies to IE, as well.

As long as your system is equipped with a sound card, LiveAudio enables you to listen to audio tracks, sound effects, music, and voice files embedded in Web pages. You can also use LiveAudio to listen to stand-alone sound files on the Web, on a local area network, and on your own computer system.

LiveAudio is a huge improvement over the NAPlayer audio helper application that Netscape shipped with versions of Netscape Navigator prior to version 3.0. Where NAPlayer played only Sun/NeXT (.AU and .SND) and Mac/SGI (.AIF and .AIFF) sound files, LiveAudio automatically identifies and plays four of the most popular standard sound formats:

.AU files were once the Internet standard file format; .AIFF files are the Macintosh standard; and .WAV files are the Windows standard file; so LiveAudio can play a good percentage of the nonproprietary sound files that you're likely to encounter on the Web. Add its capability to play MIDI music, and LiveAudio proves itself a very good "Swiss Army Knife" plug-in for Web audio.

LiveAudio Controls

When you encounter a LiveAudio-compatible sound file embedded or linked into a Web page, LiveAudio creates the on-screen control console shown in Figure 23.1.

The LiveAudio plug-in works with both embedded sound files, like the two it encountered in Figure 23.1, and with stand-alone sound files. In the case of stand-alone files, a blank Netscape window displays only a LiveAudio console.

NOTE: An embedded file is one that appears inline in an HTML document. A stand-alone file is one you load by itself, either from the Internet or from your own system.

FIG. 23.1
The LiveAudio plug-in appears as a minimalist inline audio-player control console.

The LiveAudio console controls are intuitive and easy to use (see Figure 23.1). The Stop, Play, and Pause buttons work just as they do on a tape or CD player. You click the Play button to play the sound, the Stop button to stop it, and the Pause button to pause audio playback. If you click the Pause button a second time, play resumes from the point at which you paused the sound.

Click to the right or left of the Volume slider knob to increase or decrease volume. The volume can be jumped only in increments of 20 percent--you can't slide the volume smoothly from 0 percent to 100 percent. The light-emitting diode (LED) bar graph below the Volume slider indicates the current volume level. The dark green LEDs are for the 0-40 percent range; light green LEDs take over for 40-100 percent.

Right-clicking the LiveAudio console displays the pop-up menu shown in Figure 23.1. This menu includes selections that duplicate the Play, Stop, and Pause buttons. The menu also provides a selection to display the program's About dialog box and a final nonselectable menu item that tells you the volume level as a percentage of the maximum.

The LiveAudio player has a single keyboard hot key: the spacebar. Pressing the spacebar reactivates whichever button you pressed last (Stop, Play, or Pause). Restopping an already stopped playback is of limited use, but if you last pressed Pause, the spacebar becomes an unpause/repause toggle. If you last pressed Play, the spacebar becomes a handy replay key.

Using the <EMBED> Tag with LiveAudio

The <EMBED> tag is used to embed plug-in content on an HTML page, and the way in which a page designer uses the <EMBED> tag often determines how plug-in content is displayed.

For example, the <EMBED> tag's attributes control several different aspects of the LiveAudio plug-in's functionality. Here's a typical example:

<EMBED SRC="audio.aif" WIDTH=144 HEIGHT=60 AUTOSTART=false VOLUME=100

This example plays the Macintosh format sound file AUDIO.AIF (SRC="audio.aif") only when the user presses the Play button (AUTOSTART=false). The LiveAudio control window is 144 pixels wide (WIDTH=144) and 60 pixels high (HEIGHT=60) and contains a complete control console (CONTROLS=Console).

Table 23.1 lists all the attributes associated with the <EMBED> tag for the LiveAudio plug-in, as well as their legal values. All attributes are optional except for SRC, WIDTH, and HEIGHT, which are generally required when embedding plug-in content.

Table 23.1  <EMBED> Tag Attributes for the LiveAudio Plug-In

Attribute Values
SRC="filename" A file name with an extension associated with a MIME type assigned to be played by LiveAudio (.AU, .AIFF, .AIF, .WAV, .MIDI, or .MID). Required.
WIDTH=integer The control console width in pixels. Required.
HEIGHT=integer The control console height in pixels. Required.
AUTOSTART=TRUE|FALSE If True, the sound clip plays automatically. The default is False.
AUTOLOAD=TRUE|FALSE If False, the sound clip does not automatically load. The default is True.
STARTTIME="mm:ss" The start time in minutes and seconds from the start of the clip. The default is 00:00.
ENDTIME="mm:ss" The end time in minutes and seconds from the start of the clip. The default is the end of the clip.
VOLUME=percentage Playback volume expressed as a percentage of the maximum. The default is the last previously set volume.
ALIGN="value" The point at which to align the control panel with respect to adjoining text. The possible values are CENTER, BASELINE, TOP, LEFT, and RIGHT. BASELINE is the default.
CONTROLS="value" The controls to include on the control panel. The values can be CONSOLE, SMALLCONSOLE, PLAYBUTTON, PAUSEBUTTON, STOPBUTTON, or VOLUMELEVER. The remainder of this table describes the sets of controls associated with each of these values. The default is CONSOLE.
CONSOLE A full set of controls: Play, Pause, Stop, and Volume.
SMALLCONSOLE A reduced set of controls consisting of Play, Stop, and Volume. AUTOSTART defaults to True.
PLAYBUTTON The Play button only.
PAUSEBUTTON The Pause button only.
STOPBUTTON The Stop button. Also, the sound file unloads.
VOLUMELEVER The Volume control only.
CONSOLE="name" A combination of controls that enables you to include multiple sound clips on a page. For example, you could specify CONSOLE="MySetup" as an attribute on two <EMBED> lines on a single HTML page; then each line would use the controls defined by the other as well as its own.

NOTE: If you specify the settings CONTROLS="VolumeLever" and CONSOLE="_MASTERVOLUME", the user changes the system's master volume (not just the sound clip's volume) by manipulating the volume slider.

If you need to set up a Web server to deliver LiveAudio-compatible content, you first must set up the proper MIME types. How you do so varies with the specific server software; check your server documentation or ask your system administrator to set up the following MIME types, shown in Table 23.2, with associated filename extensions:

Table 23.2  MIME Types for LiveAudio

MIME Type Extensions
audio/basic .AU
audio/x-aiff .AIF, .AIFF
audio/aiff .AIF, .AIFF
audio/x-wav .WAV
audio/wav .WAV
audio/x-midi .MID, .MIDI
audio/midi .MID, .MIDI
The <EMBED> tag works similarly with other plug-ins, though they may specify their own attributes.

Other Audio Plug-Ins

Though LiveAudio is bundled with Netscape Navigator, there are many, many more audio plug-ins available for delivering audio content in your HTML documents. This section takes a quick look at a few of the most popular.

NOTE: The latest version of Macromedia's Shockwave for Director plug-in--originally just for playing multimedia presentations--now includes the ability to play streaming audio in real time--that is, you don't have to download an audio file completely before beginning to play it. Macromedia is now enthusiastically promoting Shockwave as a viable alternative to an audio-only delivery medium. You might want to check it out, especially if you intend on delivering multimedia content in your documents, as well as audio. Macromedia's Web site is at


If nothing else, TrueSpeech is convenient. If you're using Windows 3.1 or Windows 95, the supplied Sound Recorder program can digitize sound files and convert them to TrueSpeech format. You can then use the TrueSpeech player to listen to them on the Web in real time. Despite its name, TrueSpeech can be used for any type of audio file. You don't need a special server. You can download TrueSpeech players for Windows 3.1, Windows 95, Windows NT, Macintosh, and PowerMac from the DSP Group's home page at http://www.dspg.com.

Crescendo and Crescendo Plus

Most sound cards go a step beyond merely digitizing and playing back sounds. They can also generate their own sounds. If your sound card is MIDI-compatible (as most are), you have more than a passive record-and-playback system--you have a full-fledged music synthesizer. With a MIDI plug-in, you can experience Web sites with a full music soundtrack.

LiveUpdate's Crescendo plug-in enables Navigator to play inline MIDI music embedded in Web pages. With a MIDI-capable browser, you can create Web pages that have their own background music soundtracks. Because MIDI instruments can be sampled sounds, you can also create sound-effects tracks.

Crescendo requires an MPC (MIDI-capable) sound card and Navigator version 2.0 or above. The plug-in launches automatically and invisibly and is a fun addition to Web browsing.

Crescendo is available for Windows 95 and Windows NT, Windows 3.1, and Macintosh. You can download Crescendo at http://www.liveupdate.com/midi.html.

An enhanced version, Crescendo Plus, adds on-screen controls and live streaming. With the live streaming feature, you don't have to wait for a MIDI file to download completely before it starts playing. You can purchase Crescendo Plus also from LiveUpdate's Web site.


If all you need is speech, three kinds of speech plug-ins are available for Navigator:

ToolVox provides audio compression ratios of up to 53:1, which creates very small files that transfer quickly over the Internet. Speech can be delivered in real time even over 9,600-baud modems. One unique feature is you can slow down playback to improve comprehension, or speed it up to shorten listening times without changing voice pitch.

Like the higher-fidelity RealAudio (which is discussed in the Chapter 27, "Streaming Audio"), ToolVox streams audio in real time, so you don't have to wait for a file to download before you can listen to it.

ToolVox doesn't need special server software to deliver audio content from your Web server. The player, in the form of a Navigator plug-in, controls buffering and playback. As a result, any standard HTML server can act as a streaming media server. Even the encoder is free. It compresses a speech file from .WAV format to an 8kHz, 2,400 bits-per-second (bps) VOX file.

Voxware has also announced plans to release ToolVox Gold, an enhanced version of ToolVox.

ToolVox Navigator plug-ins are available for Windows 3.1 and Windows 95. Voxware also promises Macintosh and PowerMac versions. You can download these plug-ins from the Voxware site at http://www.voxware.com/download.htm.


EchoSpeech compresses speech at a ratio of 18.5:1. Therefore, 16-bit speech sampled at 11,025Hz is compressed to 9,600bps. Even users with 14.4kbps modems can listen to real-time EchoSpeech audio streams. Because EchoSpeech is designed to code speech sampled at 1,1025Hz rather than 8,000Hz, EchoSpeech files sound better than ToolVox.

Real-time decoding of 11kHz speech requires only 30 percent of a 486SX-33 CPU's time. EchoSpeech plug-ins are also small--40-50K when decompressed.

No server software is required to deliver EchoSpeech content; your Internet service provider (ISP) or server administrator need only declare a new MIME type and pay a one-time $99 license fee. To add EchoSpeech files to your Web pages, you compress them with the EchoSpeech Speech Coder (available for evaluation with free downloading) and then use the HTML <EMBED> tag to include the files in your documents.

EchoSpeech is available for Windows 3.1, Windows 95, and Macintosh. You can get EchoSpeech at http://www.echospeech.com.

Talker and Other Macintosh Speech Plug-Ins

MVP Solutions' Talker plug-in is just for the Macintosh. The plug-in uses the Macintosh's built-in PlainTalk speech-synthesis technology to create text-to-speech voice messages--in other words, Talker reads text files to you out loud. This plug-in uses much less bandwidth than recorded audio, and you can change the words that your Web page speaks by editing a text file.

Speech capability is one area in which Macintosh owners can claim a considerable edge over Windows and Windows 95 Navigator users--this plug-in will simply never work on those platforms because they lack the speech-synthesis technology of the Macintosh. You can find Talker at http://www.mvpsolutions.com/PlugInSite/Talker.html.

If you haven't yet installed Apple's English Text-to-Speech software on your Macintosh, you can download a copy of the software's installer from Apple's site at ftp://ftp.info.apple.com/Apple.Support.Area/Apple.Software.Updates/US/Macintosh/System/Speech/PlainTalk_1.4.1/.

William H. Tudor's Speech Plug-In for the Macintosh and PowerMac does essentially the same thing as Talker. You can get Tudor's plug-in at http://www.albany.net/~wtudor/.

Macintosh plug-ins aren't limited only to talking to you--they can also listen to you and understand what you're saying!

Bill Noon's ListenUp is for the Power Macintosh running System 7.5 or above. The plug-in also requires the PlainTalk Speech Recognition v1.5 program. You can find out all the details and download the plug-in at http://snow.cit.cornell.edu/noon/ListenUp.html.

Digital Dream's ShockTalk speech recognition plug-in isn't a Navigator plug-in at all; it's a plug-in for the Shockwave for Director plug-in. ShockTalk is available for Macintosh and PowerMac. You can find the plug-in at http://www.surftalk.com/.

More Sound Plug-Ins

If you can't get enough of listening to sound, this section describes a few more Navigator sound plug-ins.

Arnaud Masson's MIDI plug-in is for the Macintosh and PowerMac only. You can get it at http://www.planete.net/~amasson/

Another Macintosh-only plug-in for MIDI files is GRAME's MidiShare. You can find this plug-in at http://www.grame.fr/english/MidiShare.html

Do you prefer the sound of the orient? Sseyo's Koan might better suite your taste. It plays real-time, computer-generated Japanese Koan music on Windows 3.1 and Windows 95 versions of Navigator. You can find Koan at http://www.sseyo.com/

DBA from Delta Beta (http://www.deltabeta.com) for Windows 95 is a player for audio files compressed in Delta Beta's .DBA format. (The compressor is freely downloadable.)

DSM Plug-in by Dmitry Boldyrev (http://www.spilk.org/dsm/) for Mac Power PC lets you play ScreamTracker 3 (S3M), Oktalyzer, ProTracker, FastTracker (MOD), TakeTracker, MultiTracker (MTM), Farandole Tracker (FAR), Composer 669 (669), MIDI, and other computer music files.

Pixound from Hologramophone Research (http://www.pixound.com/) for Mac Power PC, Macintosh, and Windows 95 is truly strange; it translates pictures into sound as you move the mouse cursor over an image on a Pixound-enabled Web page.

Virtual Sound Canvas from Roland (http://www.rolandcorp.com/vsc/vscd.html) for Mac Power PC, Macintosh, Windows 95, Windows 3.1, and UNIX, is a software emulation of a Roland SC77 sound module. Ultra-cool.

Yamaha XG MIDPlug from Yamaha (http://www.yamaha.co.jp/english/xg/html/midhm.html) for Mac Power PC, Windows 95, and Windows 3.1 is a software Yamaha synthesizer.

Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.