20.3 winsound -- Sound-playing interface for Windows

Availability: Windows.

New in 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 (0x25 through 0x7fff). 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. New in version 1.5.3.

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.

The sound parameter is the name of a WAV file.

The sound parameter should be interpreted as a control panel sound association name.

Play the sound repeatedly. The SND_ASYNC flag must also be used to avoid blocking.

The sound parameter to PlaySound() is a memory image of a WAV file.

Note: This module does not support playing from a memory image asynchronously, so a combination of this flag and SND_ASYNC will raise a RuntimeError.

Stop playing all instances of the specified sound.

Return immediately, allowing sounds to play asynchronously.

If the specified sound cannot be found, do not play a default beep.

Do not interrupt sounds currently playing.

Return immediately if the sound driver is busy.

See About this document... for information on suggesting changes.