blob: 589658f3bcc2897bdd9c758c1f97d6b5ae08112c [file] [log] [blame]
Fred Drakec7b72db1999-02-16 19:18:38 +00001\section{\module{winsound} ---
2 Sound-playing interface for Windows}
3
4\declaremodule{builtin}{winsound}
Fred Drakef6863c11999-03-02 16:37:17 +00005 \platform{Windows}
Fred Drakec7b72db1999-02-16 19:18:38 +00006\modulesynopsis{Access to the sound-playing machinery for Windows.}
7\moduleauthor{Toby Dickenson}{htrd90@zepler.org}
8\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
9
Fred Drakef6346341999-02-19 15:46:38 +000010\versionadded{1.5.2}
Fred Drakec7b72db1999-02-16 19:18:38 +000011
12The \module{winsound} module provides access to the basic
Fred Drake714fd261999-10-22 21:08:56 +000013sound-playing machinery provided by Windows platforms. It includes
14two functions and several constants.
Fred Drakec7b72db1999-02-16 19:18:38 +000015
16
Fred Drake714fd261999-10-22 21:08:56 +000017\begin{funcdesc}{Beep}{frequency, duration}
18 Beep the PC's speaker.
19 The \var{frequency} parameter specifies frequency, in hertz, of the
20 sound, and must be in the range 37 through 32,767 (\code{0x25}
21 through \code{0x7fff}). The \var{duration} parameter specifies the
22 number of milliseconds the sound should last. If the system is not
23 able to beep the speaker, \exception{RuntimeError} is raised.
Fred Drake29052482001-01-25 17:29:18 +000024 \strong{Note:} Under Windows 95 and 98, the arguments are ignored;
Tim Peters517ce232001-01-25 09:33:48 +000025 if the system has a sound card, the system default sound is played
Fred Drake29052482001-01-25 17:29:18 +000026 (typically \file{ding.wav}, or whatever is registered as the default
27 sound via Control Panel -> Sounds); else (no sound card) the
28 standard system beep.
29 \versionadded{1.6}
Fred Drake714fd261999-10-22 21:08:56 +000030\end{funcdesc}
31
Fred Drakec7b72db1999-02-16 19:18:38 +000032\begin{funcdesc}{PlaySound}{sound, flags}
33 Call the underlying \cfunction{PlaySound()} function from the
34 Platform API. The \var{sound} parameter may be a filename, audio
35 data as a string, or \code{None}. Its interpretation depends on the
36 value of \var{flags}, which can be a bit-wise ORed combination of
37 the constants described below. If the system indicates an error,
38 \exception{RuntimeError} is raised.
39\end{funcdesc}
40
41
42\begin{datadesc}{SND_FILENAME}
43 The \var{sound} parameter is the name of a WAV file.
44\end{datadesc}
45
46\begin{datadesc}{SND_ALIAS}
47 The \var{sound} parameter should be interpreted as a control panel
48 sound association name.
49\end{datadesc}
50
51\begin{datadesc}{SND_LOOP}
52 Play the sound repeatedly. The \constant{SND_ASYNC} flag must also
53 be used to avoid blocking.
54\end{datadesc}
55
56\begin{datadesc}{SND_MEMORY}
57 The \var{sound} parameter to \function{PlaySound()} is a memory
58 image of a WAV file.
59
60 \strong{Note:} This module does not support playing from a memory
Thomas Woutersf8316632000-07-16 19:01:10 +000061 image asynchronously, so a combination of this flag and
Fred Drakec7b72db1999-02-16 19:18:38 +000062 \constant{SND_ASYNC} will raise a \exception{RuntimeError}.
63\end{datadesc}
64
65\begin{datadesc}{SND_PURGE}
66 Stop playing all instances of the specified sound.
67\end{datadesc}
68
69\begin{datadesc}{SND_ASYNC}
70 Return immediately, allowing sounds to play asynchronously.
71\end{datadesc}
72
73\begin{datadesc}{SND_NODEFAULT}
74 If the specified sound cannot be found, do not play a default beep.
75\end{datadesc}
76
77\begin{datadesc}{SND_NOSTOP}
78 Do not interrupt sounds currently playing.
79\end{datadesc}
80
81\begin{datadesc}{SND_NOWAIT}
82 Return immediately if the sound driver is busy.
83\end{datadesc}