So, You Want A Sound/Embed, Huh?

By Joe Burns

Use these to jump around or read it all...

[Helper Applications]
[Offering A Sound]
[Embedding A Sound]
[What's A Plug-In?]
[How Do I Do It?]
[MIDI?]
[More About Embedding]




Push Play for Charlie Brown

     Sounds on the Net are a great thing. If you have a computer equipped with a sound card and a few shareware programs, you can hear as much as you care to download. Van Halen is my favorite musical group. Before their greatest hits album came out, I was able to download the sound files of the two new songs and enjoy them through my RealAudio players. I still bought the CD, of course.
     The following will cover two ways of offering sounds over the Internet: helper applications and embedding the sounds.

     Right up front, I should point out that the EMBED command is not "standard" HTML. That means it is not one of the commands the W3 has proclaimed is good for all browsers. EMBED is a command that is understood by the Netscape Navigator browser alone.
     If you use EMBED, you should always follow it with the BGSOUND="----" command, placing the sound file name where I have the "----". That's Internet Explorer's method of playing a background sound.
     Use both. Then all browsers will be able to play the sound.


Helper Applications

     When the World Wide Web first got started, back when Mosaic was the browser and this new thing called Netscape 1.0 came out, sounds were available, but they were played with the use of a helper application.
     Helper applications were programs that attached to the Netscape browser. (You can still do it all this way -- don't get me wrong -- but plug-ins, covered later, are making helper applications a bit of an endangered species.) You're using helper applications right now! Look at the top of your browser. See that thing called Options? Click on it. Choose Preferences, then choose Helper Applications. There they all are. Roll down the list. You'll see a lot of extra applications and a lot of "Ask User" statements. In order to play a sound file, like .wav, .au, or .aiff, you will need to attach an application that the browser can use to play the sound.
     I used (and still use) a program called WHAM. It's great and it plays a great many types of sound files.

What happens is this:

  • The browser gets the sound file and downloads the entire thing.
  • Once the download is complete, the helper application is launched.
  • The browser loads the sound file into the application.
  • The application plays the sound.
     I always thought it was a pretty good system. Yeah, it took a bit of time, especially using a 14.4 or 28.8 modem, but it always worked. At least it always worked for me.

Offering A Sound Via Helper Application

     If you have a sound you'd like to offer, follow this format:

<A HREF="http://www.yoursite.com/filename.wav"> Click Here</A>

     Notice it's nothing more than a simple link pointing to the sound file. Place the sound file in the same directory as the page that calls for it and the browser will take it from there. You just sit back and watch it happen. Just be sure to FTP transfer the sound file to your site as "binary" or "raw data," as any other way can corrupt it.

     I should also say here that by making this hypertext link to a sound file you are taking the chance that the person viewing the page on your site has an appropriate helper application. Anymore, that's not a bad bet. A browser is now pretty well equipped for sound as soon as the user installs it.


Embedding A Sound

     Embedding a sound on a page means that you include the sound commands in your HTML document and use a plug-in to run it.

What's A Plug-In?

     Plug-ins are programs that help your browser perform at a higher level. A sound plug-in does basically the same thing the helper application does, except it works inside the Netscape Navigator window rather than starting up as a whole other program. Instead of WHAM popping up and Netscape being pushed to the back while the sound runs, a sound plug-in works inside of Netscape Navigator allowing you to continue playing with the page while the sound is running.
     If you head to the Netscape Home Page or Yahoo and enter "plug ins", you'll be able to scan a ton of little programs that cover everything from sound to video to 3-D VRML. They all have specific requirements for browser types and platforms. Be sure to read the instructions before downloading. The four that I've installed have all worked right away.
     If you're using a later version of Netscape Navigator, you might have run into a page that requires a plug-in and had a little window pop up that asks if you'd like to get the appropriate plug-in. If you answer "yes" it takes you to the Netscape plug-in page and you download what you need.

     If you've taken the time to download version 4.0 or higher of either Navigator or Internet Explorer, you may have noticed that the download offered you the ability to install a large run of plug-ins right off the bat.


How Do I Do It?

     I'm going to show this to you using a MIDI file. In fact, if you have the ability to play midi files, you probably clicked above and have listened to a midi of the Peanuts theme. I believe the actual name of the melody is "Linus and Lucy." I like it.

MIDI?

     Yeah, midi. It's an acronym that stands for Musical Instrument Digital Interface. That's a program that acts as a go-between for an instrument and something that creates the sound. Sort of like running a guitar through a computer and then out a speaker.
     A midi file over the Web works as a program that runs the sound card. The midi file is not simply read and reproduced like a .wav or an .au file. The midi file sort of "plays" the sound card. It tells the sound card what note to produce and for what duration. Put enough of these notes together and it sounds like music. Most of the midi music you hear sounds like a bad little Casio keyboard. Probably because that's the level at which your sound card can reproduce the sounds. Higher level sound cards can reproduce the MIDI just as clear as any instrument could. It's really amazing when you hear it.

The Format For An Embed:

<EMBED SRC="peanuts.mid" AUTOSTART=FALSE LOOP=FALSE WIDTH=145 HEIGHT=55 ALIGN="CENTER">
</EMBED>


Here's What's Happening:

  • EMBED tells the browser an embed sound is here -- go get the plug-in. Remember, embed commands are associated with plug-ins.
    Note: If no plug-in is available, the browser will do one of three things:
    1. Do nothing. This is true of very early level browsers or browsers other than Netscape.
    2. Put up a dialogue box asking you how you want to handle the file.
    3. Tell you a plug-in is needed and ask you if you'd like to go get it.
  • HEIGHT/WIDTH deals with the plug-ins control panel size on the page. The control panel at the top of the page was giving a size of 145 pixels wide by 55 pixels high.
    You can't very well embed a sound, so to have the browser understand what the thing is, it is offered as if it is almost an image. (Note the image of the control panel popped up.) If you do not want a panel, add the command HIDDEN="yes" or set the height and width to zero.
  • SRC stands for "source." It tells the browser where to go to get the audio file.
  • AUTOSTART deals with whether you want the sound to play by itself or by the viewer starting the file after the plug-in box pops up. "True" starts the file straight away, "false" prompts the viewer. Note I used "false" above. "True" would have started the file straightaway upon load.
  • LOOP works the same way. "True" loops the sound so it plays forever. Make the loop "false" if you only want it played once.

More About Embedding

  1. You can embed just about any type of sound file as long as the person using your page has the ability to read it. My plug-in will play just about any file except RealAudio (spelled correctly).
  2. RealAudio still works as a helper application. What's great about RealAudio is that it plays the sound as it is being downloaded. The play is almost instantaneous. Great invention.
  3. Download time with an embed is not sped up or slowed. The entire file must download before the plug-in plays it. What is different (and better) about this is that an embed starts the download process without anyone clicking on blue words. Also, you can play with the page while the download is occurring, rather than just sitting and waiting like you have to do with helper applications.

    That's about it. Try embedding a few midi files and see what kind of response you get. I have one here and there. No one has complained yet.

    [Helper Applications]
    [Offering A Sound]
    [Embedding A Sound]
    [What's A Plug-In?]
    [How Do I Do It?]
    [MIDI?]

    [More About Embedding]

    Enjoy!



Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
  •  
  •