|
Using MIDI on
the Web
Presented
by Peruvian Dreams by Waystein
(Stein Arne Rimehaug).
The
use of MIDI on Web pages has increased dramatically over the
past two years. Many of the better places to find MIDI music
are listed in the Net
Links . If you have been thinking about adding MIDI to
your personal home page, here is how to do it.
There are basically two ways a
MIDI file can be used on a Web page - as a hypertext link that
can be clicked on or as an embedded file (background music)
which plays automatically when the page is loaded (like on
this page). Embedded files are loaded along with the rest of
the page, so the MIDI file is downloaded to the user's
computer whether or not the user chooses to do so.
Therefore, there is some
controversy about using embedded files, with some people
arguing passionately against their use. Charles Kelley offers
such an argument in Many
MIDI File Lovers Hate Embedded MIDI Files and offers An
Alternative to Embedding MIDI Files (that is, using a
hypertext link).
I believe that embedded files
can be properly used in many circumstances. For example, the
music playing on this page now is from an embedded file. Most
people know that this weekly column usually features such
music, and they expect it. However, I avoid embedding very
large files (over about 40K) because they slow down the
loading of the page.
The following is a summary of
the HTML code used to add MIDI to your site. If you use a Web
page editor such as FrontPage or PageMill you may not deal
directly with HTML code. However, I strongly urge you to learn
the basics of it, since you can exert much more control over
your pages this way.
Using MIDI on the Web -
Here's the Code!
It
is relatively easy to add a hypertext link. The code is <A
HREF="filename.mid">. For example, a link to a
song entitled "Surfing" which has the file name
"surfing.mid" might look like this:
Here is my newest song,
entitled
<A HREF="surfing.mid">Surfing</A>.
(This assumes that surfing.mid is in the same
directory as your Web pages.)
To embed a MIDI file so that is
plays in the background, the basic HTML syntax is as follows.
This example, like the one given above, assumes that you have
uploaded the MIDI file to the same directory where you keep
your Web pages.
<EMBED SRC="surfing.mid"
WIDTH="142" HEIGHT="58" AUTOSTART="TRUE"
REPEAT="TRUE">
EMBED SRC="surfing.mid"
specifies the MIDI file. WIDTH and HEIGHT are the size of the
control panel that appears on the page. I like using the
values 142 and 58, but you can experiment with making the
panel larger or smaller.
You can hide the control panel
by setting WIDTH="0" HEIGHT="2" This way,
the music plays in the background but the viewer of the page
cannot stop or restart it.
AUTOSTART="TRUE" is
the default setting, causing playback to begin automatically
when you open that page. If you set AUTOSTART="FALSE"
playback will start only when the Play button in the control
panel is pressed.
REPEAT="TRUE" causes
playback to loop until the Stop button is pressed. If you set
REPEAT="FALSE" or leave this code off entirely, the
song will stop after it has played back once.
This will work on both Netscape
and Internet Explorer browsers. Internet Explorer also has a
tag called "background sound" which is very simple.
For example, you can use <BGSOUND="surfing.mid">
to play the file in the background without displaying a
control panel. However, this tag does not work with Netscape.
Therefore, I recommend using the EMBED=SRC method since it
works with both. Do not use both EMBED and BGSOUND tags.
This will cause Explorer to play the file twice at the same
time. If you are using FrontPage you must add this code
manually, because entering a file name in the "background
sound" dialogue box will use the Explorer-only code. (The
first time an Explorer user encounters an embedded file the
browser may indicate that a plug-in is needed. In this case I
recommend using Crescendo
or Beatnik.
Netscape really doesn't need a plug-in, but you can use either
of these).
To test your results, upload
the HTML file to your server, connect to your site and see if
the music plays correctly. Sometimes no problems are detected
when the file is tested locally but show up when accessing it
from a server. If you have a problem, especially if your
browser displays text instead of playing music, your server
may not be configured properly.
Unless you have your own
server, you will have to ask your administrator to check the
following settings. Just send an e-mail to your provider with
your request and include the following:
[Server settings]
MIME type = audio/midi or
audio/x-midi
action = binary
suffix = .mid
type = midi
|