blob: ec79e9e003da87712e517509e26423544f2e254d [file] [log] [blame]
Greg Ward620e3432003-03-09 23:34:52 +00001\section{\module{ossaudiodev} ---
Greg Ward3e34f592003-03-10 02:09:51 +00002 Access to OSS-compatible audio devices}
Greg Ward620e3432003-03-09 23:34:52 +00003
4\declaremodule{builtin}{ossaudiodev}
Greg Ward4fe97ca2004-05-05 01:36:16 +00005\platform{Linux, FreeBSD}
Greg Ward3e34f592003-03-10 02:09:51 +00006\modulesynopsis{Access to OSS-compatible audio devices.}
Greg Ward620e3432003-03-09 23:34:52 +00007
Greg Ward4fe97ca2004-05-05 01:36:16 +00008\versionadded{2.3}
9
Greg Ward3e34f592003-03-10 02:09:51 +000010This module allows you to access the OSS (Open Sound System) audio
11interface. OSS is available for a wide range of open-source and
Greg Wardc50b0882003-05-03 19:45:47 +000012commercial Unices, and is the standard audio interface for Linux and
13recent versions of FreeBSD.
14
15% Things will get more complicated for future Linux versions, since
16% ALSA is in the standard kernel as of 2.5.x. Presumably if you
17% use ALSA, you'll have to make sure its OSS compatibility layer
18% is active to use ossaudiodev, but you're gonna need it for the vast
19% majority of Linux audio apps anyways.
20%
21% Sounds like things are also complicated for other BSDs. In response
22% to my python-dev query, Thomas Wouters said:
23%
24% > Likewise, googling shows OpenBSD also uses OSS/Free -- the commercial
25% > OSS installation manual tells you to remove references to OSS/Free from the
26% > kernel :)
27%
28% but Aleksander Piotrowsk actually has an OpenBSD box, and he quotes
29% from its <soundcard.h>:
30% > * WARNING! WARNING!
31% > * This is an OSS (Linux) audio emulator.
32% > * Use the Native NetBSD API for developing new code, and this
33% > * only for compiling Linux programs.
34%
35% There's also an ossaudio manpage on OpenBSD that explains things
36% further. Presumably NetBSD and OpenBSD have a different standard
37% audio interface. That's the great thing about standards, there are so
38% many to choose from ... ;-)
39%
40% This probably all warrants a footnote or two, but I don't understand
41% things well enough right now to write it! --GPW
Greg Ward620e3432003-03-09 23:34:52 +000042
Greg Ward3e34f592003-03-10 02:09:51 +000043\begin{seealso}
44\seetitle[http://www.opensound.com/pguide/oss.pdf]
Greg Wardc50b0882003-05-03 19:45:47 +000045 {Open Sound System Programmer's Guide} {the official
46 documentation for the OSS C API}
Greg Ward3e34f592003-03-10 02:09:51 +000047\seetext{The module defines a large number of constants supplied by
Greg Wardc316d0d2003-05-23 02:44:46 +000048 the OSS device driver; see \code{<sys/soundcard.h>} on either
Greg Ward3e34f592003-03-10 02:09:51 +000049 Linux or FreeBSD for a listing .}
50\end{seealso}
Greg Ward620e3432003-03-09 23:34:52 +000051
Greg Ward3e34f592003-03-10 02:09:51 +000052\module{ossaudiodev} defines the following variables and functions:
Greg Ward620e3432003-03-09 23:34:52 +000053
Greg Wardfb1b5a12003-05-29 01:39:32 +000054\begin{excdesc}{OSSAudioError}
Greg Wardf882c772003-03-10 03:05:21 +000055This exception is raised on certain errors. The argument is a string
56describing what went wrong.
57
58(If \module{ossaudiodev} receives an error from a system call such as
59\cfunction{open()}, \cfunction{write()}, or \cfunction{ioctl()}, it
60raises \exception{IOError}. Errors detected directly by
Greg Wardfb1b5a12003-05-29 01:39:32 +000061\module{ossaudiodev} result in \exception{OSSAudioError}.)
62
63(For backwards compatibility, the exception class is also available as
64\code{ossaudiodev.error}.)
Greg Ward620e3432003-03-09 23:34:52 +000065\end{excdesc}
66
67\begin{funcdesc}{open}{\optional{device, }mode}
Greg Wardf882c772003-03-10 03:05:21 +000068Open an audio device and return an OSS audio device object. This
69object supports many file-like methods, such as \method{read()},
70\method{write()}, and \method{fileno()} (although there are subtle
71differences between conventional Unix read/write semantics and those of
72OSS audio devices). It also supports a number of audio-specific
73methods; see below for the complete list of methods.
Greg Ward620e3432003-03-09 23:34:52 +000074
Greg Wardf882c772003-03-10 03:05:21 +000075\var{device} is the audio device filename to use. If it is not
76specified, this module first looks in the environment variable
77\envvar{AUDIODEV} for a device to use. If not found, it falls back to
78\file{/dev/dsp}.
79
80\var{mode} is one of \code{'r'} for read-only (record) access,
81\code{'w'} for write-only (playback) access and \code{'rw'} for both.
Greg Ward451a7662003-05-26 01:51:33 +000082Since many sound cards only allow one process to have the recorder or
83player open at a time, it is a good idea to open the device only for the
84activity needed. Further, some sound cards are half-duplex: they can be
Greg Wardf882c772003-03-10 03:05:21 +000085opened for reading or writing, but not both at once.
Greg Wardc316d0d2003-05-23 02:44:46 +000086
87Note the unusual calling syntax: the \emph{first} argument is optional,
88and the second is required. This is a historical artifact for
89compatibility with the older \module{linuxaudiodev} module which
90\module{ossaudiodev} supersedes. % XXX it might also be motivated
91% by my unfounded-but-still-possibly-true belief that the default
92% audio device varies unpredictably across operating systems. -GW
Greg Ward620e3432003-03-09 23:34:52 +000093\end{funcdesc}
94
Greg Wardcd930f52003-03-10 03:18:19 +000095\begin{funcdesc}{openmixer}{\optional{device}}
Greg Wardf882c772003-03-10 03:05:21 +000096Open a mixer device and return an OSS mixer device object.
97\var{device} is the mixer device filename to use. If it is
Greg Ward33bcd982003-03-09 23:57:34 +000098not specified, this module first looks in the environment variable
Greg Ward3e34f592003-03-10 02:09:51 +000099\envvar{MIXERDEV} for a device to use. If not found, it falls back to
Greg Wardcd930f52003-03-10 03:18:19 +0000100\file{/dev/mixer}.
Greg Wardf882c772003-03-10 03:05:21 +0000101
Greg Ward620e3432003-03-09 23:34:52 +0000102\end{funcdesc}
103
104\subsection{Audio Device Objects \label{ossaudio-device-objects}}
105
Greg Wardc316d0d2003-05-23 02:44:46 +0000106Before you can write to or read from an audio device, you must call
107three methods in the correct order:
Greg Ward074472b2003-03-10 00:24:42 +0000108\begin{enumerate}
Greg Wardc316d0d2003-05-23 02:44:46 +0000109\item \method{setfmt()} to set the output format
110\item \method{channels()} to set the number of channels
111\item \method{speed()} to set the sample rate
Greg Ward074472b2003-03-10 00:24:42 +0000112\end{enumerate}
Greg Wardc316d0d2003-05-23 02:44:46 +0000113Alternately, you can use the \method{setparameters()} method to set all
114three audio parameters at once. This is more convenient, but may not be
115as flexible in all cases.
Greg Ward620e3432003-03-09 23:34:52 +0000116
Greg Ward451a7662003-05-26 01:51:33 +0000117The audio device objects returned by \function{open()} define the
Greg Ward50682d02005-03-07 01:41:11 +0000118following methods and (read-only) attributes:
Greg Ward620e3432003-03-09 23:34:52 +0000119
120\begin{methoddesc}[audio device]{close}{}
Greg Wardc316d0d2003-05-23 02:44:46 +0000121Explicitly close the audio device. When you are done writing to or
122reading from an audio device, you should explicitly close it. A closed
123device cannot be used again.
Greg Ward620e3432003-03-09 23:34:52 +0000124\end{methoddesc}
125
126\begin{methoddesc}[audio device]{fileno}{}
Greg Wardc316d0d2003-05-23 02:44:46 +0000127Return the file descriptor associated with the device.
Greg Ward620e3432003-03-09 23:34:52 +0000128\end{methoddesc}
129
130\begin{methoddesc}[audio device]{read}{size}
Greg Wardc316d0d2003-05-23 02:44:46 +0000131Read \var{size} bytes from the audio input and return them as a Python
132string. Unlike most \UNIX{} device drivers, OSS audio devices in
133blocking mode (the default) will block \function{read()} until the
134entire requested amount of data is available.
Greg Ward620e3432003-03-09 23:34:52 +0000135\end{methoddesc}
136
137\begin{methoddesc}[audio device]{write}{data}
Greg Wardc316d0d2003-05-23 02:44:46 +0000138Write the Python string \var{data} to the audio device and return the
139number of bytes written. If the audio device is in blocking mode (the
140default), the entire string is always written (again, this is different
141from usual \UNIX{} device semantics). If the device is in non-blocking
142mode, some data may not be written---see \method{writeall()}.
Greg Ward620e3432003-03-09 23:34:52 +0000143\end{methoddesc}
144
145\begin{methoddesc}[audio device]{writeall}{data}
Greg Ward451a7662003-05-26 01:51:33 +0000146Write the entire Python string \var{data} to the audio device: waits
147until the audio device is able to accept data, writes as much data as it
148will accept, and repeats until \var{data} has been completely written.
149If the device is in blocking mode (the default), this has the same
150effect as \method{write()}; \method{writeall()} is only useful in
151non-blocking mode. Has no return value, since the amount of data
152written is always equal to the amount of data supplied.
Greg Ward620e3432003-03-09 23:34:52 +0000153\end{methoddesc}
154
Greg Wardc316d0d2003-05-23 02:44:46 +0000155The following methods each map to exactly one
Greg Ward451a7662003-05-26 01:51:33 +0000156\function{ioctl()} system call. The correspondence is obvious: for
157example, \method{setfmt()} corresponds to the \code{SNDCTL_DSP_SETFMT}
158ioctl, and \method{sync()} to \code{SNDCTL_DSP_SYNC} (this can be useful
159when consulting the OSS documentation). If the underlying
160\function{ioctl()} fails, they all raise \exception{IOError}.
Greg Ward620e3432003-03-09 23:34:52 +0000161
162\begin{methoddesc}[audio device]{nonblock}{}
Greg Wardc316d0d2003-05-23 02:44:46 +0000163Put the device into non-blocking mode. Once in non-blocking mode, there
164is no way to return it to blocking mode.
Greg Ward620e3432003-03-09 23:34:52 +0000165\end{methoddesc}
166
167\begin{methoddesc}[audio device]{getfmts}{}
Greg Wardc316d0d2003-05-23 02:44:46 +0000168Return a bitmask of the audio output formats supported by the
Greg Warda17fa892005-03-28 02:34:59 +0000169soundcard. Some of the formats supported by OSS are:
Greg Ward620e3432003-03-09 23:34:52 +0000170
Greg Ward074472b2003-03-10 00:24:42 +0000171\begin{tableii}{l|l}{constant}{Format}{Description}
172\lineii{AFMT_MU_LAW}
Greg Wardc316d0d2003-05-23 02:44:46 +0000173 {a logarithmic encoding (used by Sun \code{.au} files and
174 \filenq{/dev/audio})}
Greg Ward074472b2003-03-10 00:24:42 +0000175\lineii{AFMT_A_LAW}
176 {a logarithmic encoding}
177\lineii{AFMT_IMA_ADPCM}
178 {a 4:1 compressed format defined by the Interactive Multimedia
Greg Wardc316d0d2003-05-23 02:44:46 +0000179 Association}
Greg Ward074472b2003-03-10 00:24:42 +0000180\lineii{AFMT_U8}
Greg Wardc316d0d2003-05-23 02:44:46 +0000181 {Unsigned, 8-bit audio}
Greg Ward074472b2003-03-10 00:24:42 +0000182\lineii{AFMT_S16_LE}
Greg Warda17fa892005-03-28 02:34:59 +0000183 {Signed, 16-bit audio, little-endian byte order (as used by
Greg Ward074472b2003-03-10 00:24:42 +0000184 Intel processors)}
185\lineii{AFMT_S16_BE}
Greg Warda17fa892005-03-28 02:34:59 +0000186 {Signed, 16-bit audio, big-endian byte order (as used by 68k,
Greg Ward074472b2003-03-10 00:24:42 +0000187 PowerPC, Sparc)}
188\lineii{AFMT_S8}
Greg Wardc316d0d2003-05-23 02:44:46 +0000189 {Signed, 8 bit audio}
Greg Ward074472b2003-03-10 00:24:42 +0000190\lineii{AFMT_U16_LE}
Greg Warda17fa892005-03-28 02:34:59 +0000191 {Unsigned, 16-bit little-endian audio}
Greg Ward074472b2003-03-10 00:24:42 +0000192\lineii{AFMT_U16_BE}
Greg Warda17fa892005-03-28 02:34:59 +0000193 {Unsigned, 16-bit big-endian audio}
Greg Ward074472b2003-03-10 00:24:42 +0000194\end{tableii}
Greg Warda17fa892005-03-28 02:34:59 +0000195Consult the OSS documentation for a full list of audio formats, and note
196that most devices support only a subset of these formats. Some older
197devices only support \constant{AFMT_U8}; the most common format used
198today is \constant{AFMT_S16_LE}.
Greg Ward620e3432003-03-09 23:34:52 +0000199\end{methoddesc}
200
201\begin{methoddesc}[audio device]{setfmt}{format}
Greg Wardc316d0d2003-05-23 02:44:46 +0000202Try to set the current audio format to \var{format}---see
Greg Ward451a7662003-05-26 01:51:33 +0000203\method{getfmts()} for a list. Returns the audio format that the device
Greg Wardc316d0d2003-05-23 02:44:46 +0000204was set to, which may not be the requested format. May also be used to
205return the current audio format---do this by passing an ``audio format''
206of
207\constant{AFMT_QUERY}.
Greg Ward620e3432003-03-09 23:34:52 +0000208\end{methoddesc}
209
Greg Wardfb1b5a12003-05-29 01:39:32 +0000210\begin{methoddesc}[audio device]{channels}{nchannels}
211Set the number of output channels to \var{nchannels}. A value of 1
Greg Ward33bcd982003-03-09 23:57:34 +0000212indicates monophonic sound, 2 stereophonic. Some devices may have more
213than 2 channels, and some high-end devices may not support mono.
214Returns the number of channels the device was set to.
Greg Ward620e3432003-03-09 23:34:52 +0000215\end{methoddesc}
216
217\begin{methoddesc}[audio device]{speed}{samplerate}
Greg Wardc316d0d2003-05-23 02:44:46 +0000218Try to set the audio sampling rate to \var{samplerate} samples per
219second. Returns the rate actually set. Most sound devices don't
220support arbitrary sampling rates. Common rates are:
221\begin{tableii}{l|l}{textrm}{Rate}{Description}
222\lineii{8000}{default rate for \filenq{/dev/audio}}
223\lineii{11025}{speech recording}
224\lineii{22050}{}
225\lineii{44100}{CD quality audio (at 16 bits/sample and 2 channels)}
226\lineii{96000}{DVD quality audio (at 24 bits/sample)}
227\end{tableii}
Greg Ward620e3432003-03-09 23:34:52 +0000228\end{methoddesc}
229
Greg Wardc316d0d2003-05-23 02:44:46 +0000230\begin{methoddesc}[audio device]{sync}{}
Greg Ward451a7662003-05-26 01:51:33 +0000231Wait until the sound device has played every byte in its buffer. (This
232happens implicitly when the device is closed.) The OSS documentation
233recommends closing and re-opening the device rather than using
234\method{sync()}.
Greg Ward620e3432003-03-09 23:34:52 +0000235\end{methoddesc}
236
Greg Wardc316d0d2003-05-23 02:44:46 +0000237\begin{methoddesc}[audio device]{reset}{}
Greg Ward451a7662003-05-26 01:51:33 +0000238Immediately stop playing or recording and return the device to a
Greg Ward33bcd982003-03-09 23:57:34 +0000239state where it can accept commands. The OSS documentation recommends
Greg Ward3e34f592003-03-10 02:09:51 +0000240closing and re-opening the device after calling \method{reset()}.
Greg Ward620e3432003-03-09 23:34:52 +0000241\end{methoddesc}
242
Greg Wardc316d0d2003-05-23 02:44:46 +0000243\begin{methoddesc}[audio device]{post}{}
Greg Ward451a7662003-05-26 01:51:33 +0000244Tell the driver that there is likely to be a pause in the output, making
245it possible for the device to handle the pause more intelligently. You
246might use this after playing a spot sound effect, before waiting for
247user input, or before doing disk I/O.
Greg Ward620e3432003-03-09 23:34:52 +0000248\end{methoddesc}
249
Greg Wardfb1b5a12003-05-29 01:39:32 +0000250The following convenience methods combine several ioctls, or one ioctl
251and some simple calculations.
Greg Ward620e3432003-03-09 23:34:52 +0000252
Greg Wardfb1b5a12003-05-29 01:39:32 +0000253\begin{methoddesc}[audio device]{setparameters}
254 {format, nchannels, samplerate \optional{, strict=False}}
255
256Set the key audio sampling parameters---sample format, number of
257channels, and sampling rate---in one method call. \var{format},
258\var{nchannels}, and \var{samplerate} should be as specified in the
259\method{setfmt()}, \method{channels()}, and \method{speed()}
260methods. If \var{strict} is true, \method{setparameters()} checks to
261see if each parameter was actually set to the requested value, and
262raises \exception{OSSAudioError} if not. Returns a tuple (\var{format},
263\var{nchannels}, \var{samplerate}) indicating the parameter values that
264were actually set by the device driver (i.e., the same as the return
Raymond Hettinger68804312005-01-01 00:28:46 +0000265values of \method{setfmt()}, \method{channels()}, and \method{speed()}).
Greg Wardfb1b5a12003-05-29 01:39:32 +0000266
267For example,
268\begin{verbatim}
269 (fmt, channels, rate) = dsp.setparameters(fmt, channels, rate)
270\end{verbatim}
271is equivalent to
272\begin{verbatim}
273 fmt = dsp.setfmt(fmt)
274 channels = dsp.channels(channels)
275 rate = dsp.rate(channels)
276\end{verbatim}
Greg Ward620e3432003-03-09 23:34:52 +0000277\end{methoddesc}
278
279\begin{methoddesc}[audio device]{bufsize}{}
280Returns the size of the hardware buffer, in samples.
281\end{methoddesc}
282
283\begin{methoddesc}[audio device]{obufcount}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000284Returns the number of samples that are in the hardware buffer yet to be
285played.
Greg Ward620e3432003-03-09 23:34:52 +0000286\end{methoddesc}
287
288\begin{methoddesc}[audio device]{obuffree}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000289Returns the number of samples that could be queued into the hardware
290buffer to be played without blocking.
Greg Ward620e3432003-03-09 23:34:52 +0000291\end{methoddesc}
292
Greg Ward50682d02005-03-07 01:41:11 +0000293Audio device objects also support several read-only attributes:
294
295\begin{memberdesc}[audio device]{closed}{}
296Boolean indicating whether the device has been closed.
297\end{memberdesc}
298
299\begin{memberdesc}[audio device]{name}{}
300String containing the name of the device file.
301\end{memberdesc}
302
303\begin{memberdesc}[audio device]{mode}{}
304The I/O mode for the file, either \code{"r"}, \code{"rw"}, or \code{"w"}.
305\end{memberdesc}
306
307
Greg Ward620e3432003-03-09 23:34:52 +0000308\subsection{Mixer Device Objects \label{mixer-device-objects}}
309
Greg Ward4fe97ca2004-05-05 01:36:16 +0000310The mixer object provides two file-like methods:
Greg Ward620e3432003-03-09 23:34:52 +0000311
312\begin{methoddesc}[mixer device]{close}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000313This method closes the open mixer device file. Any further attempts to
314use the mixer after this file is closed will raise an IOError.
Greg Ward620e3432003-03-09 23:34:52 +0000315\end{methoddesc}
316
317\begin{methoddesc}[mixer device]{fileno}{}
318Returns the file handle number of the open mixer device file.
319\end{methoddesc}
320
Greg Ward4fe97ca2004-05-05 01:36:16 +0000321The remaining methods are specific to audio mixing:
Greg Ward620e3432003-03-09 23:34:52 +0000322
323\begin{methoddesc}[mixer device]{controls}{}
324This method returns a bitmask specifying the available mixer controls
325(``Control'' being a specific mixable ``channel'', such as
Greg Ward3e34f592003-03-10 02:09:51 +0000326\constant{SOUND_MIXER_PCM} or \constant{SOUND_MIXER_SYNTH}). This
Greg Ward4fe97ca2004-05-05 01:36:16 +0000327bitmask indicates a subset of all available mixer controls---the
Greg Ward3e34f592003-03-10 02:09:51 +0000328\constant{SOUND_MIXER_*} constants defined at module level. To determine if,
Greg Ward620e3432003-03-09 23:34:52 +0000329for example, the current mixer object supports a PCM mixer, use the
330following Python code:
331
332\begin{verbatim}
333mixer=ossaudiodev.openmixer()
Greg Ward4fe97ca2004-05-05 01:36:16 +0000334if mixer.controls() & (1 << ossaudiodev.SOUND_MIXER_PCM):
335 # PCM is supported
336 ... code ...
Greg Ward620e3432003-03-09 23:34:52 +0000337\end{verbatim}
338
Greg Ward4fe97ca2004-05-05 01:36:16 +0000339For most purposes, the \constant{SOUND_MIXER_VOLUME} (master volume) and
340\constant{SOUND_MIXER_PCM} controls should suffice---but code that uses the
341mixer should be flexible when it comes to choosing mixer controls. On
Greg Ward3e34f592003-03-10 02:09:51 +0000342the Gravis Ultrasound, for example, \constant{SOUND_MIXER_VOLUME} does not
Greg Ward33bcd982003-03-09 23:57:34 +0000343exist.
Greg Ward620e3432003-03-09 23:34:52 +0000344\end{methoddesc}
345
346\begin{methoddesc}[mixer device]{stereocontrols}{}
Greg Ward4fe97ca2004-05-05 01:36:16 +0000347Returns a bitmask indicating stereo mixer controls. If a bit is set,
348the corresponding control is stereo; if it is unset, the control is
Greg Ward33bcd982003-03-09 23:57:34 +0000349either monophonic or not supported by the mixer (use in combination with
Greg Ward4fe97ca2004-05-05 01:36:16 +0000350\method{controls()} to determine which).
Greg Ward620e3432003-03-09 23:34:52 +0000351
Greg Ward4fe97ca2004-05-05 01:36:16 +0000352See the code example for the \method{controls()} function for an example
Greg Ward33bcd982003-03-09 23:57:34 +0000353of getting data from a bitmask.
Greg Ward620e3432003-03-09 23:34:52 +0000354\end{methoddesc}
355
356\begin{methoddesc}[mixer device]{reccontrols}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000357Returns a bitmask specifying the mixer controls that may be used to
Greg Ward3e34f592003-03-10 02:09:51 +0000358record. See the code example for \method{controls()} for an example of
Greg Ward33bcd982003-03-09 23:57:34 +0000359reading from a bitmask.
Greg Ward620e3432003-03-09 23:34:52 +0000360\end{methoddesc}
361
Greg Ward4fe97ca2004-05-05 01:36:16 +0000362\begin{methoddesc}[mixer device]{get}{control}
363Returns the volume of a given mixer control. The returned volume is a
Greg Ward3e34f592003-03-10 02:09:51 +00003642-tuple \code{(left_volume,right_volume)}. Volumes are specified as
Greg Ward4fe97ca2004-05-05 01:36:16 +0000365numbers from 0 (silent) to 100 (full volume). If the control is
366monophonic, a 2-tuple is still returned, but both volumes are
Greg Ward33bcd982003-03-09 23:57:34 +0000367the same.
Greg Ward620e3432003-03-09 23:34:52 +0000368
Greg Ward4fe97ca2004-05-05 01:36:16 +0000369Raises \exception{OSSAudioError} if an invalid control was is specified,
370or \exception{IOError} if an unsupported control is specified.
Greg Ward620e3432003-03-09 23:34:52 +0000371\end{methoddesc}
372
Greg Ward4fe97ca2004-05-05 01:36:16 +0000373\begin{methoddesc}[mixer device]{set}{control, (left, right)}
374Sets the volume for a given mixer control to \code{(left,right)}.
Greg Ward620e3432003-03-09 23:34:52 +0000375\code{left} and \code{right} must be ints and between 0 (silent) and 100
Greg Ward33bcd982003-03-09 23:57:34 +0000376(full volume). On success, the new volume is returned as a 2-tuple.
377Note that this may not be exactly the same as the volume specified,
378because of the limited resolution of some soundcard's mixers.
Greg Ward620e3432003-03-09 23:34:52 +0000379
Greg Ward4fe97ca2004-05-05 01:36:16 +0000380Raises \exception{OSSAudioError} if an invalid mixer control was
381specified, or if the specified volumes were out-of-range.
Greg Ward620e3432003-03-09 23:34:52 +0000382\end{methoddesc}
383
384\begin{methoddesc}[mixer device]{get_recsrc}{}
Greg Ward4fe97ca2004-05-05 01:36:16 +0000385This method returns a bitmask indicating which control(s) are
Greg Ward620e3432003-03-09 23:34:52 +0000386currently being used as a recording source.
387\end{methoddesc}
388
389\begin{methoddesc}[mixer device]{set_recsrc}{bitmask}
Greg Ward33bcd982003-03-09 23:57:34 +0000390Call this function to specify a recording source. Returns a bitmask
Greg Ward620e3432003-03-09 23:34:52 +0000391indicating the new recording source (or sources) if successful; raises
Greg Ward33bcd982003-03-09 23:57:34 +0000392\exception{IOError} if an invalid source was specified. To set the current
Greg Ward620e3432003-03-09 23:34:52 +0000393recording source to the microphone input:
394
395\begin{verbatim}
396mixer.setrecsrc (1 << ossaudiodev.SOUND_MIXER_MIC)
397\end{verbatim}
398\end{methoddesc}
399
400
401