UNIFACE 8.1.01 Sound statement

 


Contents of this document.


The sound statement
Sound directory
Playing sound
Error handling
Download the sample
Running the sample


The sound statement.

In UNIFACE 8101 a new proc statement is added which allows you to play a sound file. The sound file itself can only be a wave file. In most cases the file name has the extension .WAV.

Statement:

sound'/'<option><soundfile>
<option> := play | loop | stop
<soundfile> := <filename> | '@'<filename>
 

The stop function does not require a soundfile.

Sound directory

The sound directory specifies where the sound files are located. It is not recommended to use hard coded path information in proc.  The sound directory can be specified in the usys.ini in the paths section.
 

[paths]
sounddir = e:\user\jasper\sound

For instance:
sound/play "e:\user\jasper\sound\hello.wav"

will work as long as the UNIFACE application is deployed on the same machine. It is better to use

sound/play "hello.wav"

In both cases the same file will be played.

When the sound file cannot be found, Windows NT itself does a retry on the C:\winnt\media directory. So when in our example the "hello.wav" cannot be found, Windows itself does a retry for "c:\winnt\media\hello.wav".

It is by the way not necessary to specify the file extension.  This means that sound/play "hello" will work as well.


Playing sound.

Playing a sound file is done asynchronous. This means that the execution of a UNIFACE trigger continues while the sound file is played. The playing ends when the file is completely played or when the sound/stop statement is issued. Be aware that a sound/loop statement needs a sound/stop to stop the playing of the sound.
When two sound/play statements are following each other directly, the first sound will be stopped as soon the second sound/play statement is issued.

Error handling.

The system will shortly beep when the sound file cannot be found.


Download the sample.

Download the sample into your IDF project directory.  Click on the following link to download the sample.
usound.exp

Running the sample.

Import the usound.exp and define in the usys.asn the following setting:
    $variation = system_library

Run the component/form "usound" in test mode.

Starting the sample shows a funny radio. In the front panel of the radio is an edit control wherein you can define the sound file to be played by this radio. By clicking on the adjacent button you can browse your disk to find a wave file. In most cases the c:\winnt\media directory contains some windows wave files which can be used to play a sound. The following picture gives an overview of the available options.