Sound

Basic sound functions

SYNOPSIS

package require twapi_multimedia
beep ?options?
play_sound NAME ?options?
stop_sound

DESCRIPTION

This package provides commands for playing sounds on Windows platforms.

Overview

The commands beep, play_sound and stop_sound provide basic functions for generating sound. For more sophisticated needs, there are other Tcl extensions available, such as the Snack Sound Toolkit.

Commands

beep ?options?
Generates a sound on the system speaker. The following options may be specified:
-frequency FREQUENCY The frequency of the sound to be produced (default 1000 Hz).
-duration MILLISECONDS The duration of the sound to be produced (default 100 milliseconds).
-type SOUNDIDENTIFIER Specifies the type of sound to produce. SOUNDIDENTIFIER may be one of ok, hand, question, exclamation or asterisk. These will produce the corresponding sounds configured in the Windows control panel. If this option is specified, the options -duration and -frequency are ignored.
play_sound NAME ?options?
Plays a sound on the system audio device. The sound may either be a WAV file or a system defined sound (if the -alias option is specified). The command returns 1 if successful else 0.

The following options may be specified to control the sound:
-alias By default, NAME is assumed to be the path of a WAV file. If -alias is specified, NAME is assumed to be the name of a system sound. The following system defined sounds are guaranteed to be present on all systems: SystemAsterisk, SystemExclamation, SystemExit, SystemHand, SystemQuestion and SystemStart. Other system defined names can be located under the HKEY_CURRENT_USER\AppEvents\EventLabels registry key. Note that a sound will only be played if a WAV file has been associated with it through the control panel.
-async If specified, the sound is played asynchronously and command will return immediately. By default, the command will return only after the sound has completed playing.
-loop Specification of this option causes the sound to be played repeatedly until stopped through a stop_sound command. This option also automatically enables the -async option.
-nodefault If the system cannot find the specified sound, it plays a default sound file. If this option is specified, the command will return without playing any sound if the specified sound file is not found.
-nostop Normally, the audio device is playing some other file, the command will attempt to stop the currently playing sound. If -nostop is specified, the command will return immediately without attempting to stop the current sound.
-wait If the audio driver is busy, the command will return right away. If this option is specified, the command will wait for the driver to become available.
stop_sound
Stops all currently playing sounds that have been started by the current task. Returns 1 if successful, else 0.

COPYRIGHT

Copyright © 2003, Ashok P. Nadkarni

Tcl Windows API 5.0