MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //usr/share/doc/python-docs-2.4.3/html/lib/mixer-device-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<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>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<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>
</tr></table>
<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>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00161120000000000000000"></A><A NAME="mixer-device-objects"></A>
<BR>
14.11.2 Mixer Device Objects 
</H2>

<P>
The mixer object provides two file-like methods:

<P>
<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>
<dd>
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>

<P>
<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>
<dd>
Returns the file handle number of the open mixer device file.
</dl>

<P>
The remaining methods are specific to audio mixing:

<P>
<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>
<dd>
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
following Python code:

<P>
<div class="verbatim"><pre>
mixer=ossaudiodev.openmixer()
if mixer.controls() &amp; (1 &lt;&lt; ossaudiodev.SOUND_MIXER_PCM):
    # PCM is supported
    ... code ...
</pre></div>

<P>
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
exist.
</dl>

<P>
<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>
<dd>
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).

<P>
See the code example for the <tt class="method">controls()</tt> function for an example
of getting data from a bitmask.
</dl>

<P>
<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>
<dd>
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
reading from a bitmask.
</dl>

<P>
<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>
<dd>
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
the same.

<P>
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>

<P>
<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>
<dd>
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.

<P>
Raises <tt class="exception">OSSAudioError</tt> if an invalid mixer control was
specified, or if the specified volumes were out-of-range.
</dl>

<P>
<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>
<dd>
This method returns a bitmask indicating which control(s) are
currently being used as a recording source.
</dl>

<P>
<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>
<dd>
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:

<P>
<div class="verbatim"><pre>
mixer.setrecsrc (1 &lt;&lt; ossaudiodev.SOUND_MIXER_MIC)
</pre></div>
</dl>

<P>

<P>

<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<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>
</tr></table>
<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>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.3, documentation updated on 29 March 2006.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>