Playing a sound file

playsound()

Play a sound file


SYNTAX

playsound(filename, flags)

Plays a sound file (.wav extension). Sounds may be played synchronously (program execution is suspended while the sound plays) or asynchronously (program execution continues).

The filename is the name of the sound file to be played.

The flags, which are defined in $SCULPTOR/include/sculptor.h, are as follows:

SND_SYNC

Play the sound synchronously (default).

SND_ASYNC

Play the sound asynchronously.

SND_NODEFAULT

If sound not found, don’t play the default sound.

SND_LOOP

Repeat the sound until stopped.

SND_NOSTOP

Don’t stop the currently playing sound.

SND_PURGE

Stop sound events for this task.

SND_APPLICATION

Use application specific association.

SND_NOWAIT

Don’t wait if the driver is busy.

SND_ALIAS

The filename is a registry alias.

SND_ALIAS_ID

The filename is a pre-defined sound identifier.

SND_FILENAME

The filename is the name of a .wav file.

If more than one flag is required they must be separated by the | character.

The following flag combinations are predefined:

SND_FILE_WAIT

SND_NODEFAULT | SND_FILENAME

SND_FILE_NOWAIT

SND_ASYNC | SND_NODEFAULT | SND_FILENAME

SND_FILE_REPEAT

SND_ASYNC | SND_NODEFAULT | SND_FILENAME | SND_LOOP

The stopsound command can be used to stop an asynchronous sound from playing.


EXAMPLES

playsound("/sounds/scream3.wav,SND_ASYNC | SND_NOWAIT | SND_NOSTOP)
playsound("$SCULPTOR/sndfiles/applause.wav", SND_FILE_REPEAT)