Sound

(Engine-Level Function)

Description: Plays a multimedia sound file as installed in the operating system.
Returns: Nothing
Usage: Script Only.
Function Groups: Speech and Sound
Related to: Beep | ModemDev | Play
Format: Sound(File, Option [, DevID])
Parameters:  
File
Required. Any text expression giving the file name to play. If the extension is omitted, the default extension ".WAV" is added. If an empty string is provided here, then any currently playing sound is stopped.
Option
Required. Any numeric expression, which indicates how to play the file. Option is found by adding together numbers from the following table.

Option 

Bit No. 

How to play file

1

0

Play asynchronously (don't wait)

2

1

Don't use default sound if file missing

4

2

Reserved for future use

8

3

Loop the sound until next Sound function executed

16

4

Don't stop any currently playing sound

If Option is 0, VTScada will halt all execution until the sound is finished (this isn't recommended). Add 1 to avoid this.

DevID
An optional parameter. This parameter is required when it is desired to play a sound through other than the system default audio device. The function ModemDev can return the identifier of the wave device for a voice modem. If it is required to stop a sound playing through a specific DevID, then the value returned by the Sound function when the sound was started must be given here.
Comments: This statement may only appear in a script.
When a sound is started using the DevID parameter, only option value 8 is significant.
If a sound is started using the DevID parameter, then the return value from the function is required to stop that sound.

Examples:

Sound("TRAIN", 1);

This statement plays the sound file TRAIN.WAV on the system default audio device.

Sound("", 1);

This statement stops any sound currently playing on the system default audio device.

SoundHandle = Sound("Irritating Music", 8, ModemDev(MStream));

This statement plays the sound file IRRITATING MUSIC.WAV through the audio channel of the modem whose open stream is MStream. The sound will play until stopped.

Sound("", 0, SoundHandle);

This example stops the Irritating Music sound started by the previous example