<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"prev" href=
"ossaudio-device-objects.html" />
<link rel=
"parent" href=
"module-ossaudiodev.html" />
<link rel=
"next" href=
"crypto.html" />
<meta name='aesop' content='information'
/>
<title>14.11.2 Mixer Device Objects
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"14.11.1 Audio Device Objects"
href=
"ossaudio-device-objects.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"14.11 ossaudiodev "
href=
"module-ossaudiodev.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"15. Cryptographic Services"
href=
"crypto.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"ossaudio-device-objects.html">14.11.1 Audio Device Objects
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-ossaudiodev.html">14.11 ossaudiodev
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"crypto.html">15. Cryptographic Services
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION00161120000000000000000"></A><A NAME=
"mixer-device-objects"></A>
14.11.2 Mixer Device Objects
The mixer object provides two file-like methods:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4792' xml:id='l2h-
4792'
class=
"method">close
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
This method closes the open mixer device file. Any further attempts to
use the mixer after this file is closed will raise an IOError.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4793' xml:id='l2h-
4793'
class=
"method">fileno
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Returns the file handle number of the open mixer device file.
The remaining methods are specific to audio mixing:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4794' xml:id='l2h-
4794'
class=
"method">controls
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
This method returns a bitmask specifying the available mixer controls
(``Control'' being a specific mixable ``channel'', such as
<tt class=
"constant">SOUND_MIXER_PCM
</tt> or
<tt class=
"constant">SOUND_MIXER_SYNTH
</tt>). This
bitmask indicates a subset of all available mixer controls--the
<tt class=
"constant">SOUND_MIXER_*
</tt> constants defined at module level. To determine if,
for example, the current mixer object supports a PCM mixer, use the
<div class=
"verbatim"><pre>
mixer=ossaudiodev.openmixer()
if mixer.controls()
& (
1 << ossaudiodev.SOUND_MIXER_PCM):
For most purposes, the
<tt class=
"constant">SOUND_MIXER_VOLUME
</tt> (master volume) and
<tt class=
"constant">SOUND_MIXER_PCM
</tt> controls should suffice--but code that uses the
mixer should be flexible when it comes to choosing mixer controls. On
the Gravis Ultrasound, for example,
<tt class=
"constant">SOUND_MIXER_VOLUME
</tt> does not
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4795' xml:id='l2h-
4795'
class=
"method">stereocontrols
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Returns a bitmask indicating stereo mixer controls. If a bit is set,
the corresponding control is stereo; if it is unset, the control is
either monophonic or not supported by the mixer (use in combination with
<tt class=
"method">controls()
</tt> to determine which).
See the code example for the
<tt class=
"method">controls()
</tt> function for an example
of getting data from a bitmask.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4796' xml:id='l2h-
4796'
class=
"method">reccontrols
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Returns a bitmask specifying the mixer controls that may be used to
record. See the code example for
<tt class=
"method">controls()
</tt> for an example of
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4797' xml:id='l2h-
4797'
class=
"method">get
</tt></b>(
</nobr></td>
<td><var>control
</var>)
</td></tr></table></dt>
Returns the volume of a given mixer control. The returned volume is a
2-tuple
<code>(left_volume,right_volume)
</code>. Volumes are specified as
numbers from
0 (silent) to
100 (full volume). If the control is
monophonic, a
2-tuple is still returned, but both volumes are
Raises
<tt class=
"exception">OSSAudioError
</tt> if an invalid control was is specified,
or
<tt class=
"exception">IOError
</tt> if an unsupported control is specified.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4798' xml:id='l2h-
4798'
class=
"method">set
</tt></b>(
</nobr></td>
<td><var>control, (left, right)
</var>)
</td></tr></table></dt>
Sets the volume for a given mixer control to
<code>(left,right)
</code>.
<code>left
</code> and
<code>right
</code> must be ints and between
0 (silent) and
100
(full volume). On success, the new volume is returned as a
2-tuple.
Note that this may not be exactly the same as the volume specified,
because of the limited resolution of some soundcard's mixers.
Raises
<tt class=
"exception">OSSAudioError
</tt> if an invalid mixer control was
specified, or if the specified volumes were out-of-range.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4799' xml:id='l2h-
4799'
class=
"method">get_recsrc
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
This method returns a bitmask indicating which control(s) are
currently being used as a recording source.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4800' xml:id='l2h-
4800'
class=
"method">set_recsrc
</tt></b>(
</nobr></td>
<td><var>bitmask
</var>)
</td></tr></table></dt>
Call this function to specify a recording source. Returns a bitmask
indicating the new recording source (or sources) if successful; raises
<tt class=
"exception">IOError
</tt> if an invalid source was specified. To set the current
recording source to the microphone input:
<div class=
"verbatim"><pre>
mixer.setrecsrc (
1 << ossaudiodev.SOUND_MIXER_MIC)
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"14.11.1 Audio Device Objects"
href=
"ossaudio-device-objects.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"14.11 ossaudiodev "
href=
"module-ossaudiodev.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"15. Cryptographic Services"
href=
"crypto.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"ossaudio-device-objects.html">14.11.1 Audio Device Objects
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-ossaudiodev.html">14.11 ossaudiodev
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"crypto.html">15. Cryptographic Services
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.