Implementation hints and Cool Crescendo Tricks for web authors!

How to Make a Frame-based Crescendo Jukebox
JavaScript for "Follow Around Sound"
- makes Crescendo come up in a separate window
JavaScript that *randomly* selects a MIDI file
CGI script that *randomly* selects a MIDI file


How to play music while your page is loading

Music playing while a web page is loading is nice. To get your music playing soonest, place your Crescendo HTML tags at the top of your document, like this one.


Use type 0 MIDI files for fastest playing with Crescendo PLUS

A type 0 MIDI file has the notes time-ordered in the file. Thus, when you use this type of MIDI file in your web pages, Crescendo PLUS users will hear the music start faster than with Type 1 MIDI files.



Java Script that *randomly* selects a MIDI file

Seen at http://www.midwest.net/scribers/mccoy
Written by David McCoy.
Email comments and questions to mccoy@midwest.net


This is an updated version of the script, sent by David McCoy on 10/14/96:

<SCRIPT>
<!-- close your eyes
// David McCoy;   mccoy@midwest.net     URL: http://www.midwest.net/scribers/mccoy/
// This is my random midi picker (v3.0);  If use a variant of this in your page, then
// please email me :)  You may also have to alter the links in the EMBED line so your
// browser can "find" your MIDI files.  such as:  document.write('<EMBED SRC= 
// "http://www.server.com/page/' + midi + '" WIDTH=200 HEIGHT=60 AUTOSTART=TRUE>')
// var nummidi  is the number of MIDIs you will be using

var nummidi = 5
day = new Date()
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*nummidi + 1,10)

if (ran == (1))    
midi=("midi1.mid") 
if (ran == (2))
midi=("midi2.mid") 
if (ran == (3))
midi=("midi3.mid")  
if (ran == (4))
midi=("midi4.mid")  
if (ran == (5))       
midi=("midi5.mid")  

document.write('<EMBED SRC= "' + midi + '" WIDTH=144 HEIGHT=60 AUTOSTART=TRUE>')
document.write('<BGSOUND SRC= "' + midi + '"  loop=infinite AUTOSTART=TRUE>')

// open your eyes -->
</SCRIPT>



CGI Script that *randomly* selects a MIDI file

Seen at http://isis.infinet.com/koolkat/
Written by Wm. Todd Horch.
Email comments and questions to whorch@ee.net

(A message from Todd: mention that since the src="..." can be any valid http based URL, it is entirely possible to use a CGI script to liven things up a bit. I've added a very simple script to one of my pages that returns a random MIDI song each time the page is first pointed to with Netscape. (i.e. the first time you point at a page after opening Netscape. Subsequent reloads in the same session will not load a new song unless you clear your cache or have Verify Documents set to Every Time on the Network Preferences page))


The embed structure for this is: <embed src="http://www.yourserver.com/cgi-bin/randmidi.pl" width=200 height=55>

and the script is:
###############################################################################
# randmidi.pl - deliver random MIDI file to WWW page
###############################################################################

#!/usr/local/bin/perl

@songlist=("Song1.mid","Song2.mid","Song3.mid","Song4.mid","Song5.mid");
$song="/path/to/midi/files/$songlist[rand(@songlist)-1]";

open(MIDIFILE, $song);
print "Content-type: audio/midi\n\n";
while (read(MIDIFILE, $buf, 16384))
{print $buf;}

###############################################################################

Of course, this script could be expanded to allow something like: <embed src="http://www.yourserver.com/cgi-bin/randmidi.pl/path/to/midi/files" width=200 height=55> to be used to read the directory at the selected path and pick a random song from there.



JavaScript for "Follow Around Sound"

Had it with Crescendo blanking your web page when you click on a link to a MIDI file? Here's the solution: a simple HTML JavaScript that launches Crescendo or Crescendo PLUS in a separate window, where it will continue to play music while you surf!

Works on both Netscape and Microsoft!

Here's our example code - simple, isn't it?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Follow-Around Sound example</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function PlaySong(SongURL) // Copyright (C) 1996 LiveUpdate division of LABTECH
                                                  // Permission for use granted to all music lovers on the net
{
PopUp = window.open (SongURL, "Crescendo", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,width=200,height=30")
}
//-->
</SCRIPT>
</HEAD>
<BODY>

<P>LiveUpdate Crescendo Javascript for "Follow-Around Sound"</P>

<P>Note: This script works on both Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0</P>

<P>Web authors - examine and make free use of this simple script!</P>

<A HREF="javascript: PlaySong('midi/xliveup1.mid')">Play MIDI file by Peter Vantine<A><BR>
<A HREF="javascript: PlaySong('midi/xliveup3.mid')">Play a different MIDI file by Peter Vantine<A><BR>
<A HREF="javascript: PlaySong('midi/xliveup4.mid')">Play yet another MIDI file by Peter Vantine<A><BR>

</BODY>
</HTML>


Special thanks to Raymond Bissonnette, who created the first version of this example, in VBScript.

Here's a link to a page so you can operate the sample code. Go to town!



How to Make a Frame-based Crescendo Jukebox

by Daniel James Bell

Have you ever tried to use a "midi jukebox" that blanked out your screen, or even created a whole new Netscape or Internet Explorer window? Finally, here is an alternative way to make a real, totally functional jukebox that anyone can code! No scripting or Java applets are involved. Just real, easy to use HTML programming.

All you need is Crescendo, and a page with one tiny frame. Here's how to do it:

First, write the code to format a page with a small frame at the top, like this:


<HTML>
<html><head><title>My Homepage</title></head>               
<frameset rows="5,*">                                       {A}
<frame name="_spanel" src="Panel.html" scrolling="off">     {B}
<frame name="_main" src="Main.html" scrolling="auto">       {C} 
</frameset>
<NOFRAMES>
Sorry, you need a frame viewer for full jukebox support.<BR>     {D}
Click here to <A HREF="Main.html"> see the page </A> with no frames.
</HTML>


This file should be given the default file name for your html server. It's usually something like "welcome.html," or you may be able to set the name yourself. Make sure you rename your main page's file so you don't accidentally overwrite it with this one. Here's an explanation of the above frame-making code:
A) This makes a tiny panel for your Jukebox as a pull-down box. You can increase the size to about 65 (in place of the 5) if you want to see the controls at startup. You can also enter a figure as a percentage of the screen (like "20%, *"), to equal a certain percentage of the screen.
B) Remeber that we named it "_spanel." Create a Panel.html file in the same folder the above program. "Panel.html" should either be empty HTML code, or should have an "embed" and "bgsound" statement for your default start up music. See http://www.liveupdate.com/embed.html for more details.
C) The "src" statement should equal the new name of your main page.
D) This is a message for people who do not support frames. People with no frame support can select to see your main page without the top frame. Under these circumstances, Following a music link with no frames available will result in a download. Now all you have to do is add music, which will be directed to your frame from your main page (Main.html), like this:

Choose your background music here!<BR>
<A HREF="midi/xliveup1.mid" target="_spanel">Play MIDI file by Peter Vantine</A><BR> 
<A HREF="midi/xliveup3.mid" target="_spanel">Choose another!</A><BR> 
<A HREF="midi/xliveup4.mid" target="_spanel">Or try this one!</A><BR>


There are a lot of benefits to using the HTML frame jukeboxes over the Javascript version, including speed, ease of use, and no messy windows. For a good example of the capabilities of this programing technique, and a more in-depth explanation (complete with a troubleshooting section), please download the latest version of Crescendo and see Daniel's Multimedia Homepage.

A working frame jukebox example to study and copy

Copyright 2023 Crescendo. All rights reserved.