SOUND <snd>
Syntax
SOUND soundIDstring$
SOUND %resIDNumber
SOUND &soundHandle&
Description
This statement plays a synthesized sound which is in the "snd" format. The soundIDstring$
parameter identifies the sound you want to play; you can construct this string in any of the following ways:
- By resource name: Set
soundIDstring$
to the name of an "snd
" resource in a currently open resource file. Don't use a resource name that begins with "%" or with "&", or it will be confused with the other forms discussed below. - By resource ID number: If
%myResID
is the resource ID number of an "snd
" resource in a currently open resource file, you can prefix the number with a percent sign:
SOUND %myResID
- By "
snd
" handle: If&mySoundHandle&
is a handle to a sound in "snd
" format, you can construct thesoundIDstring$
parameter as follows:
SOUND &mySoundHandle&
If FB needs to load a resource to play the sound, it does not automatically release the resource after the sound stops. In this case, you should either use purgeable "snd
" resources, or you should execute the SOUND END
statement to force the resource to be released.
Sounds played using the SOUND <snd>
statement are always played asynchronously; that is, your program continues to the next statement immediately, while the sound is playing in the background. However, if you execute a second SOUND <snd>
statement while a previous sound is still playing in the background, the new sound won't start playing until the first sound finishes.
Example
If you want your program to "wait" until a sound finishes before continuing, you can use the function:
"reallyLongSound"
'(stays in this loop until sound finishes)
See Also
SOUND%; SOUND <frequency>; SOUND END