110 lines
4.0 KiB
HTML
110 lines
4.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Basic sound functions</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
|
|
<!--START-->
|
|
|
|
<h3>Basic sound functions</h3>
|
|
|
|
<p>
|
|
There are five basic functions related to sounds, two to play a sound,
|
|
one to check whether a sound is playing, and two to stop sounds. Most take
|
|
the index of the sound as argument. The name of the sound represents its
|
|
index. But you can also store the index in a variable, and use that.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>sound_play(index)</b></tt>
|
|
Plays the indicates sound once. If the sound is background music the current
|
|
background music is stopped.<br>
|
|
<tt><b>sound_loop(index)</b></tt>
|
|
Plays the indicates sound, looping continuously. If the sound is background music the current
|
|
background music is stopped.<br>
|
|
<tt><b>sound_stop(index)</b></tt>
|
|
Stops the indicates sound. If there are multiple sounds with this index playing
|
|
simultaneously, all will be stopped.<br>
|
|
<tt><b>sound_stop_all()</b></tt>
|
|
Stops all sounds.<br>
|
|
<tt><b>sound_isplaying(index)</b></tt>
|
|
Returns whether (a copy of) the indicated sound is playing. Note that this functions
|
|
returns true when the sound actually plays through the speakers. After you call the
|
|
function to play a sound it does not immediately reach the speakers so the function
|
|
might still return false for a while. Similar, when the sound is stopped you still hear
|
|
it for a while (e.g. because of echo) and the function will still return true.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
It is possible to use further sound effects. In particular you can
|
|
change the volume and the pan, that is, whether the sound comes from the
|
|
left or right speaker. In all these cases the volume can only be reduced.
|
|
These functions do not work for files that play through the media player
|
|
(like mp3 files).
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>sound_volume(index,value)</b></tt>
|
|
Changes the volume for the indicated sound (0 = low, 1 = high).<br>
|
|
<tt><b>sound_global_volume(value)</b></tt>
|
|
Changes the global volume for all sounds (0 = low, 1 = high).<br>
|
|
<tt><b>sound_fade(index,value,time)</b></tt>
|
|
Changes the volume for the indicated sound to the new value(0 = low, 1 = high)
|
|
during the indicated time (in milliseconds). This can be used to fade out or
|
|
fade in music.<br>
|
|
<tt><b>sound_pan(index,value)</b></tt>
|
|
Changes the pan for the indicated sound (-1 = left, 0 = center, 1 = right).<br>
|
|
<tt><b>sound_background_tempo(factor)</b></tt>
|
|
Changes the tempo of the background music (if it is a midi file). <tt>factor</tt>
|
|
indicates the factor with which to multiply the tempo. So a value of 1 corresponds
|
|
to the normal tempo. Larger values correspond to a faster tempo, smaller values
|
|
to a slower tempo. Must lie between 0.01 and 100.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
Besides midi and wave files (and mp3 file) there is actually a fourth type of file
|
|
that can be played: direct music files. These have the extension .sgt. Such files
|
|
though often refer to other files describing e.g. band or style information. To
|
|
find these files, the sound system must know where they are located. To this end
|
|
you can use the following functions to set the search directory for files. Note though
|
|
that you must add the files yourself. <i>Game Maker</i> does not automatically include
|
|
such additional files.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>sound_set_search_directory(dir)</b></tt>
|
|
Sets the directory in which direct music files are to be found. The dir string
|
|
should not incluce the final backslash.<br>
|
|
</blockquote>
|
|
|
|
|
|
<!--END-->
|
|
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
sound functions
|
|
playing sounds
|
|
music
|
|
stopping sounds
|
|
panning sounds
|
|
fading sounds
|
|
volume
|
|
direct music
|
|
|
|
sound_play()
|
|
sound_loop()
|
|
sound_stop()
|
|
sound_stop_all()
|
|
sound_isplaying()
|
|
sound_volume()
|
|
sound_global_volume()
|
|
sound_fade()
|
|
sound_pan()
|
|
sound_background_tempo()
|
|
sound_set_search_directory()
|
|
--> |