Sound a tone or play a WAV file

Version 1

    Verified Product Versions

    CETerm 5.7

    This sample script shows how you can sound tones and play a WAV file. You can use this functionality as part of any other script or web web application to provide an audible notification. This sample is implemented as a web application. However you can use the script functions as part of any other event handler.


    The script shows how you can play beeps, tones or WAV files. If playing WAV files, you must make sure and copy the WAV file to the device path being referenced.


    To download the attached...PlaySound.htm


    Here are the different ways to play / sound tones:


    To play a standard message beep, you can use the IDA command


    function doIDABeepOK()


        external.CETerm.PostIDA("IDA_BEEP_OK", 0);



    To play a loud beep, you can use the IDA command


    function doIDABeepLoud()


        external.CETerm.PostIDA("IDA_BEEP_LOUD", 0);



    To sound a tone, you can use the Playtone interface of the OS object and provide volume, frequency and duration as input parameters. The same interface can be sequenced with variations in the input parameters to sound complex tones. For the Playtone interface

         * volume is 00 -10 (0 is off, 10 is loudest)

         * frequency is in Hz.

    duration is in milliseconds.


    function doOSPlayTone()


        external.OS.PlayTone(10, 783, 200);

        external.OS.PlayTone(10, 880, 200);

        external.OS.PlayTone(10, 987, 200);

        external.OS.PlayTone(10, 1046, 200);

        external.OS.PlayTone(10, 1174, 200);

        external.OS.PlayTone(10, 1318, 200);

        external.OS.PlayTone(10, 1396, 200);

        external.OS.PlayTone(10, 1566, 200);

        external.OS.PlayTone(10, 1760, 200);

        external.OS.PlayTone(10, 1974, 200);

        external.OS.PlayTone(10, 2092, 400);


    To play a WAV file, you can use Paysound interface. The default folder is the \Windows directory. if the WAV file is in some other folder on the device, then you must use the absolute path to it.

    function doOSPlaySound()


        external.OS.PlaySound( "infbeg.wav", 0);

        external.OS.PlaySound( "infend.wav", 0);