Sound Module (last update 01/11/00)

Description:

This module adds sound capabilities to gamelib. It is currently the least developed of all the modules in gamelib, and as such it will only work with Explorer 5+ on Mac and PC platforms. On other browsers it will not cause errors, but it will not make any sound either! Mozilla support will be added as soon as possible.

To use:

The code can be linked in to your script by adding this line to the <HEAD> section of your document:

<script language="Javascript" src="gamelib_sound.js"></script>

For each sound you wish to trigger, you must create a new sound object as follows:

mysound=new Sd_add_sound("sound/canyon.midi");

List of methods for Sound module

play
stop
setBalance
setLoop
setVolume

Descriptions of methods

MethodParametersDescription
play(none)Start the sound object playing. If the object is already playing, it will rewind, and restart
stop(none)Stop the sound object from playing
setBalanceNumericSets the stereo balance for the sound. This ranges from -10000 for extreme left to 10000 for extreme right.
setBalance Numeric Sets the number of times the sound should loop once it has started playing. EG, 1 means play through just once.
setVolumeNumericSets the volume for the sound. This ranges from 0 for silent to 100 for maximum. Be aware that this is not a linear scale. On my machine I can't hear any sound that's been set below 60. So I'm guessing that's the safe lower end value...