Sound-playing interface for Windows
===================================
Access to the sound-playing machinery for Windows. This module was
written by Toby Dickenson <htrd90@zepler.org>.
This manual section was written by Fred L. Drake, Jr. <fdrake@acm.org>.
_Added in Python version 1.5.2_
The `winsound' module provides access to the basic sound-playing
machinery provided by Windows platforms. It includes two functions and
several constants.
`Beep(frequency, duration)'
Beep the PC's speaker. The FREQUENCY parameter specifies
frequency, in hertz, of the sound, and must be in the range 37
through 32,767. The DURATION parameter specifies the number of
milliseconds the sound should last. If the system is not able to
beep the speaker, `RuntimeError' is raised. *Note:* Under
Windows 95 and 98, the Windows `Beep()' function exists but is
useless (it ignores its arguments). In that case Python simulates
it via direct port manipulation (added in version 2.1). It's
unknown whether that will work on all systems. _Added in Python
version 1.6_
`PlaySound(sound, flags)'
Call the underlying `PlaySound()' function from the Platform API.
The SOUND parameter may be a filename, audio data as a string, or
`None'. Its interpretation depends on the value of FLAGS, which
can be a bit-wise ORed combination of the constants described
below. If the system indicates an error, `RuntimeError' is raised.
`SND_FILENAME'
The SOUND parameter is the name of a WAV file. Do not use with
`SND_ALIAS'.
`SND_ALIAS'
The SOUND parameter is a sound association name from the registry.
If the registry contains no such name, play the system default
sound unless `SND_NODEFAULT' is also specified. If no default
sound is registered, raise `RuntimeError'. Do not use with
`SND_FILENAME'.
All Win32 systems support at least the following; most systems
support many more:
`PlaySound()' NAME Corresponding Control Panel Sound
name
------ -----
'SystemAsterisk' Asterisk
'SystemExclamation' Exclamation
'SystemExit' Exit Windows
'SystemHand' Critical Stop
'SystemQuestion' Question
For example:
import winsound
# Play Windows exit sound.
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
# Probably play Windows default sound, if any is registered (because
# "*" probably isn't the registered name of any sound).
winsound.PlaySound("*", winsound.SND_ALIAS)
`SND_LOOP'
Play the sound repeatedly. The `SND_ASYNC' flag must also be used
to avoid blocking. Cannot be used with `SND_MEMORY'.
`SND_MEMORY'
The SOUND parameter to `PlaySound()' is a memory image of a WAV
file, as a string.
*Note:* This module does not support playing from a memory image
asynchronously, so a combination of this flag and `SND_ASYNC' will
raise `RuntimeError'.
`SND_PURGE'
Stop playing all instances of the specified sound.
`SND_ASYNC'
Return immediately, allowing sounds to play asynchronously.
`SND_NODEFAULT'
If the specified sound cannot be found, do not play the system
default sound.
`SND_NOSTOP'
Do not interrupt sounds currently playing.
`SND_NOWAIT'
Return immediately if the sound driver is busy.