blob: 762acb766dae139e097fb48dc0c3a1d448fd973f [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 Ward33bcd982003-03-09 23:57:34 +0000169soundcard. On a typical Linux system, these formats 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}
183 {Unsigned, 16-bit audio, little-endian byte order (as used by
184 Intel processors)}
185\lineii{AFMT_S16_BE}
186 {Unsigned, 16-bit audio, big-endian byte order (as used by 68k,
187 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}
191 {Signed, 16-bit little-endian audio}
192\lineii{AFMT_U16_BE}
193 {Signed, 16-bit big-endian audio}
194\end{tableii}
Greg Ward33bcd982003-03-09 23:57:34 +0000195Most systems support only a subset of these formats. Many devices only
Greg Ward3e34f592003-03-10 02:09:51 +0000196support \constant{AFMT_U8}; the most common format used today is
197\constant{AFMT_S16_LE}.
Greg Ward620e3432003-03-09 23:34:52 +0000198\end{methoddesc}
199
200\begin{methoddesc}[audio device]{setfmt}{format}
Greg Wardc316d0d2003-05-23 02:44:46 +0000201Try to set the current audio format to \var{format}---see
Greg Ward451a7662003-05-26 01:51:33 +0000202\method{getfmts()} for a list. Returns the audio format that the device
Greg Wardc316d0d2003-05-23 02:44:46 +0000203was set to, which may not be the requested format. May also be used to
204return the current audio format---do this by passing an ``audio format''
205of
206\constant{AFMT_QUERY}.
Greg Ward620e3432003-03-09 23:34:52 +0000207\end{methoddesc}
208
Greg Wardfb1b5a12003-05-29 01:39:32 +0000209\begin{methoddesc}[audio device]{channels}{nchannels}
210Set the number of output channels to \var{nchannels}. A value of 1
Greg Ward33bcd982003-03-09 23:57:34 +0000211indicates monophonic sound, 2 stereophonic. Some devices may have more
212than 2 channels, and some high-end devices may not support mono.
213Returns the number of channels the device was set to.
Greg Ward620e3432003-03-09 23:34:52 +0000214\end{methoddesc}
215
216\begin{methoddesc}[audio device]{speed}{samplerate}
Greg Wardc316d0d2003-05-23 02:44:46 +0000217Try to set the audio sampling rate to \var{samplerate} samples per
218second. Returns the rate actually set. Most sound devices don't
219support arbitrary sampling rates. Common rates are:
220\begin{tableii}{l|l}{textrm}{Rate}{Description}
221\lineii{8000}{default rate for \filenq{/dev/audio}}
222\lineii{11025}{speech recording}
223\lineii{22050}{}
224\lineii{44100}{CD quality audio (at 16 bits/sample and 2 channels)}
225\lineii{96000}{DVD quality audio (at 24 bits/sample)}
226\end{tableii}
Greg Ward620e3432003-03-09 23:34:52 +0000227\end{methoddesc}
228
Greg Wardc316d0d2003-05-23 02:44:46 +0000229\begin{methoddesc}[audio device]{sync}{}
Greg Ward451a7662003-05-26 01:51:33 +0000230Wait until the sound device has played every byte in its buffer. (This
231happens implicitly when the device is closed.) The OSS documentation
232recommends closing and re-opening the device rather than using
233\method{sync()}.
Greg Ward620e3432003-03-09 23:34:52 +0000234\end{methoddesc}
235
Greg Wardc316d0d2003-05-23 02:44:46 +0000236\begin{methoddesc}[audio device]{reset}{}
Greg Ward451a7662003-05-26 01:51:33 +0000237Immediately stop playing or recording and return the device to a
Greg Ward33bcd982003-03-09 23:57:34 +0000238state where it can accept commands. The OSS documentation recommends
Greg Ward3e34f592003-03-10 02:09:51 +0000239closing and re-opening the device after calling \method{reset()}.
Greg Ward620e3432003-03-09 23:34:52 +0000240\end{methoddesc}
241
Greg Wardc316d0d2003-05-23 02:44:46 +0000242\begin{methoddesc}[audio device]{post}{}
Greg Ward451a7662003-05-26 01:51:33 +0000243Tell the driver that there is likely to be a pause in the output, making
244it possible for the device to handle the pause more intelligently. You
245might use this after playing a spot sound effect, before waiting for
246user input, or before doing disk I/O.
Greg Ward620e3432003-03-09 23:34:52 +0000247\end{methoddesc}
248
Greg Wardfb1b5a12003-05-29 01:39:32 +0000249The following convenience methods combine several ioctls, or one ioctl
250and some simple calculations.
Greg Ward620e3432003-03-09 23:34:52 +0000251
Greg Wardfb1b5a12003-05-29 01:39:32 +0000252\begin{methoddesc}[audio device]{setparameters}
253 {format, nchannels, samplerate \optional{, strict=False}}
254
255Set the key audio sampling parameters---sample format, number of
256channels, and sampling rate---in one method call. \var{format},
257\var{nchannels}, and \var{samplerate} should be as specified in the
258\method{setfmt()}, \method{channels()}, and \method{speed()}
259methods. If \var{strict} is true, \method{setparameters()} checks to
260see if each parameter was actually set to the requested value, and
261raises \exception{OSSAudioError} if not. Returns a tuple (\var{format},
262\var{nchannels}, \var{samplerate}) indicating the parameter values that
263were actually set by the device driver (i.e., the same as the return
Raymond Hettinger68804312005-01-01 00:28:46 +0000264values of \method{setfmt()}, \method{channels()}, and \method{speed()}).
Greg Wardfb1b5a12003-05-29 01:39:32 +0000265
266For example,
267\begin{verbatim}
268 (fmt, channels, rate) = dsp.setparameters(fmt, channels, rate)
269\end{verbatim}
270is equivalent to
271\begin{verbatim}
272 fmt = dsp.setfmt(fmt)
273 channels = dsp.channels(channels)
274 rate = dsp.rate(channels)
275\end{verbatim}
Greg Ward620e3432003-03-09 23:34:52 +0000276\end{methoddesc}
277
278\begin{methoddesc}[audio device]{bufsize}{}
279Returns the size of the hardware buffer, in samples.
280\end{methoddesc}
281
282\begin{methoddesc}[audio device]{obufcount}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000283Returns the number of samples that are in the hardware buffer yet to be
284played.
Greg Ward620e3432003-03-09 23:34:52 +0000285\end{methoddesc}
286
287\begin{methoddesc}[audio device]{obuffree}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000288Returns the number of samples that could be queued into the hardware
289buffer to be played without blocking.
Greg Ward620e3432003-03-09 23:34:52 +0000290\end{methoddesc}
291
Greg Ward50682d02005-03-07 01:41:11 +0000292Audio device objects also support several read-only attributes:
293
294\begin{memberdesc}[audio device]{closed}{}
295Boolean indicating whether the device has been closed.
296\end{memberdesc}
297
298\begin{memberdesc}[audio device]{name}{}
299String containing the name of the device file.
300\end{memberdesc}
301
302\begin{memberdesc}[audio device]{mode}{}
303The I/O mode for the file, either \code{"r"}, \code{"rw"}, or \code{"w"}.
304\end{memberdesc}
305
306
Greg Ward620e3432003-03-09 23:34:52 +0000307\subsection{Mixer Device Objects \label{mixer-device-objects}}
308
Greg Ward4fe97ca2004-05-05 01:36:16 +0000309The mixer object provides two file-like methods:
Greg Ward620e3432003-03-09 23:34:52 +0000310
311\begin{methoddesc}[mixer device]{close}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000312This method closes the open mixer device file. Any further attempts to
313use the mixer after this file is closed will raise an IOError.
Greg Ward620e3432003-03-09 23:34:52 +0000314\end{methoddesc}
315
316\begin{methoddesc}[mixer device]{fileno}{}
317Returns the file handle number of the open mixer device file.
318\end{methoddesc}
319
Greg Ward4fe97ca2004-05-05 01:36:16 +0000320The remaining methods are specific to audio mixing:
Greg Ward620e3432003-03-09 23:34:52 +0000321
322\begin{methoddesc}[mixer device]{controls}{}
323This method returns a bitmask specifying the available mixer controls
324(``Control'' being a specific mixable ``channel'', such as
Greg Ward3e34f592003-03-10 02:09:51 +0000325\constant{SOUND_MIXER_PCM} or \constant{SOUND_MIXER_SYNTH}). This
Greg Ward4fe97ca2004-05-05 01:36:16 +0000326bitmask indicates a subset of all available mixer controls---the
Greg Ward3e34f592003-03-10 02:09:51 +0000327\constant{SOUND_MIXER_*} constants defined at module level. To determine if,
Greg Ward620e3432003-03-09 23:34:52 +0000328for example, the current mixer object supports a PCM mixer, use the
329following Python code:
330
331\begin{verbatim}
332mixer=ossaudiodev.openmixer()
Greg Ward4fe97ca2004-05-05 01:36:16 +0000333if mixer.controls() & (1 << ossaudiodev.SOUND_MIXER_PCM):
334 # PCM is supported
335 ... code ...
Greg Ward620e3432003-03-09 23:34:52 +0000336\end{verbatim}
337
Greg Ward4fe97ca2004-05-05 01:36:16 +0000338For most purposes, the \constant{SOUND_MIXER_VOLUME} (master volume) and
339\constant{SOUND_MIXER_PCM} controls should suffice---but code that uses the
340mixer should be flexible when it comes to choosing mixer controls. On
Greg Ward3e34f592003-03-10 02:09:51 +0000341the Gravis Ultrasound, for example, \constant{SOUND_MIXER_VOLUME} does not
Greg Ward33bcd982003-03-09 23:57:34 +0000342exist.
Greg Ward620e3432003-03-09 23:34:52 +0000343\end{methoddesc}
344
345\begin{methoddesc}[mixer device]{stereocontrols}{}
Greg Ward4fe97ca2004-05-05 01:36:16 +0000346Returns a bitmask indicating stereo mixer controls. If a bit is set,
347the corresponding control is stereo; if it is unset, the control is
Greg Ward33bcd982003-03-09 23:57:34 +0000348either monophonic or not supported by the mixer (use in combination with
Greg Ward4fe97ca2004-05-05 01:36:16 +0000349\method{controls()} to determine which).
Greg Ward620e3432003-03-09 23:34:52 +0000350
Greg Ward4fe97ca2004-05-05 01:36:16 +0000351See the code example for the \method{controls()} function for an example
Greg Ward33bcd982003-03-09 23:57:34 +0000352of getting data from a bitmask.
Greg Ward620e3432003-03-09 23:34:52 +0000353\end{methoddesc}
354
355\begin{methoddesc}[mixer device]{reccontrols}{}
Greg Ward33bcd982003-03-09 23:57:34 +0000356Returns a bitmask specifying the mixer controls that may be used to
Greg Ward3e34f592003-03-10 02:09:51 +0000357record. See the code example for \method{controls()} for an example of
Greg Ward33bcd982003-03-09 23:57:34 +0000358reading from a bitmask.
Greg Ward620e3432003-03-09 23:34:52 +0000359\end{methoddesc}
360
Greg Ward4fe97ca2004-05-05 01:36:16 +0000361\begin{methoddesc}[mixer device]{get}{control}
362Returns the volume of a given mixer control. The returned volume is a
Greg Ward3e34f592003-03-10 02:09:51 +00003632-tuple \code{(left_volume,right_volume)}. Volumes are specified as
Greg Ward4fe97ca2004-05-05 01:36:16 +0000364numbers from 0 (silent) to 100 (full volume). If the control is
365monophonic, a 2-tuple is still returned, but both volumes are
Greg Ward33bcd982003-03-09 23:57:34 +0000366the same.
Greg Ward620e3432003-03-09 23:34:52 +0000367
Greg Ward4fe97ca2004-05-05 01:36:16 +0000368Raises \exception{OSSAudioError} if an invalid control was is specified,
369or \exception{IOError} if an unsupported control is specified.
Greg Ward620e3432003-03-09 23:34:52 +0000370\end{methoddesc}
371
Greg Ward4fe97ca2004-05-05 01:36:16 +0000372\begin{methoddesc}[mixer device]{set}{control, (left, right)}
373Sets the volume for a given mixer control to \code{(left,right)}.
Greg Ward620e3432003-03-09 23:34:52 +0000374\code{left} and \code{right} must be ints and between 0 (silent) and 100
Greg Ward33bcd982003-03-09 23:57:34 +0000375(full volume). On success, the new volume is returned as a 2-tuple.
376Note that this may not be exactly the same as the volume specified,
377because of the limited resolution of some soundcard's mixers.
Greg Ward620e3432003-03-09 23:34:52 +0000378
Greg Ward4fe97ca2004-05-05 01:36:16 +0000379Raises \exception{OSSAudioError} if an invalid mixer control was
380specified, or if the specified volumes were out-of-range.
Greg Ward620e3432003-03-09 23:34:52 +0000381\end{methoddesc}
382
383\begin{methoddesc}[mixer device]{get_recsrc}{}
Greg Ward4fe97ca2004-05-05 01:36:16 +0000384This method returns a bitmask indicating which control(s) are
Greg Ward620e3432003-03-09 23:34:52 +0000385currently being used as a recording source.
386\end{methoddesc}
387
388\begin{methoddesc}[mixer device]{set_recsrc}{bitmask}
Greg Ward33bcd982003-03-09 23:57:34 +0000389Call this function to specify a recording source. Returns a bitmask
Greg Ward620e3432003-03-09 23:34:52 +0000390indicating the new recording source (or sources) if successful; raises
Greg Ward33bcd982003-03-09 23:57:34 +0000391\exception{IOError} if an invalid source was specified. To set the current
Greg Ward620e3432003-03-09 23:34:52 +0000392recording source to the microphone input:
393
394\begin{verbatim}
395mixer.setrecsrc (1 << ossaudiodev.SOUND_MIXER_MIC)
396\end{verbatim}
397\end{methoddesc}
398
399
400