Files
sw_pyalsaaudio/libalsaaudio.html
2024-05-30 23:19:19 +02:00

1232 lines
103 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>alsaaudio &#8212; alsaaudio documentation 0.11.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=cb25574f" />
<script src="_static/documentation_options.js?v=f3b36f1a"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="PCM Terminology and Concepts" href="terminology.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-alsaaudio">
<span id="alsaaudio"></span><h1><a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a><a class="headerlink" href="#module-alsaaudio" title="Link to this heading"></a></h1>
<p>The <a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a> module defines functions and classes for using ALSA.</p>
<dl class="py function">
<dt class="sig sig-object py" id="alsaaudio.pcms">
<span class="sig-prename descclassname"><span class="pre">alsaaudio.</span></span><span class="sig-name descname"><span class="pre">pcms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pcmtype</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">PCM_PLAYBACK</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.pcms" title="Link to this definition"></a></dt>
<dd><p>List available PCM devices by name.</p>
<p>Arguments are:</p>
<ul class="simple">
<li><p><em>pcmtype</em> - can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>
(default).</p></li>
</ul>
<p><strong>Note:</strong></p>
<p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>, the list of device names should be equivalent
to the list of device names that <code class="docutils literal notranslate"><span class="pre">aplay</span> <span class="pre">-L</span></code> displays on the commandline:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ aplay -L
</pre></div>
</div>
<p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>, the list of device names should be equivalent
to the list of device names that <code class="docutils literal notranslate"><span class="pre">arecord</span> <span class="pre">-L</span></code> displays on the
commandline:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ arecord -L
</pre></div>
</div>
<p><em>New in 0.8</em></p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="alsaaudio.cards">
<span class="sig-prename descclassname"><span class="pre">alsaaudio.</span></span><span class="sig-name descname"><span class="pre">cards</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.cards" title="Link to this definition"></a></dt>
<dd><p>List the available ALSA cards by name. This function is only moderately
useful. If you want to see a list of available PCM devices, use <a class="reference internal" href="#alsaaudio.pcms" title="alsaaudio.pcms"><code class="xref py py-func docutils literal notranslate"><span class="pre">pcms()</span></code></a>
instead.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="alsaaudio.mixers">
<span class="sig-prename descclassname"><span class="pre">alsaaudio.</span></span><span class="sig-name descname"><span class="pre">mixers</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cardindex</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'default'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.mixers" title="Link to this definition"></a></dt>
<dd><p>List the available mixers. The arguments are:</p>
<ul>
<li><p><em>cardindex</em> - the card index. If this argument is given, the device name
is constructed as: hw:<em>cardindex</em> and
the <cite>device</cite> keyword argument is ignored. <code class="docutils literal notranslate"><span class="pre">0</span></code> is the first hardware sound
card.</p>
<p><strong>Note:</strong> This should not be used, as it bypasses most of ALSAs configuration.</p>
</li>
<li><p><em>device</em> - the name of the device on which the mixer resides. The default
is <code class="docutils literal notranslate"><span class="pre">'default'</span></code>.</p></li>
</ul>
<p><strong>Note:</strong> For a list of available controls, you can also use <code class="docutils literal notranslate"><span class="pre">amixer</span></code> on
the commandline:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ amixer
</pre></div>
</div>
<p>To elaborate the example, calling <a class="reference internal" href="#alsaaudio.mixers" title="alsaaudio.mixers"><code class="xref py py-func docutils literal notranslate"><span class="pre">mixers()</span></code></a> with the argument
<code class="docutils literal notranslate"><span class="pre">cardindex=0</span></code> should give the same list of Mixer controls as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ amixer -c 0
</pre></div>
</div>
<p>And calling <a class="reference internal" href="#alsaaudio.mixers" title="alsaaudio.mixers"><code class="xref py py-func docutils literal notranslate"><span class="pre">mixers()</span></code></a> with the argument <code class="docutils literal notranslate"><span class="pre">device='foo'</span></code> should give
the same list of Mixer controls as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ amixer -D foo
</pre></div>
</div>
<p><em>Changed in 0.8</em>:</p>
<ul class="simple">
<li><p>The keyword argument <cite>device</cite> is new and can be used to
select virtual devices. As a result, the default behaviour has subtly
changed. Since 0.8, this functions returns the mixers for the default
device, not the mixers for the first card.</p></li>
</ul>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="alsaaudio.asoundlib_version">
<span class="sig-prename descclassname"><span class="pre">alsaaudio.</span></span><span class="sig-name descname"><span class="pre">asoundlib_version</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#alsaaudio.asoundlib_version" title="Link to this definition"></a></dt>
<dd><p>Return a Python string containing the ALSA version found.</p>
</dd></dl>
<section id="pcm-objects">
<span id="id1"></span><h2>PCM Objects<a class="headerlink" href="#pcm-objects" title="Link to this heading"></a></h2>
<p>PCM objects in <a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a> can play or capture (record) PCM
sound through speakers or a microphone. The PCM constructor takes the
following arguments:</p>
<dl class="py class">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">PCM(type:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">PCM_PLAYBACK,</span> <span class="pre">mode:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">PCM_NORMAL,</span> <span class="pre">rate:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">44100,</span> <span class="pre">channels:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">2,</span></span></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">format:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">PCM_FORMAT_S16_LE,</span> <span class="pre">periodsize:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">32,</span> <span class="pre">periods:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">4,</span></span></dt>
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">device:</span> <span class="pre">str</span> <span class="pre">=</span> <span class="pre">'default',</span> <span class="pre">cardindex:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">-1)</span> <span class="pre">-&gt;</span> <span class="pre">PCM</span></span></dt>
<dd><p>This class is used to represent a PCM device (either for playback or
recording). The constructors arguments are:</p>
<ul class="simple">
<li><p><em>type</em> - can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>
(default).</p></li>
<li><p><em>mode</em> - can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code>
(default).</p></li>
<li><p><em>rate</em> - the sampling rate in Hz. Typical values are <code class="docutils literal notranslate"><span class="pre">8000</span></code> (mainly used for telephony), <code class="docutils literal notranslate"><span class="pre">16000</span></code>, <code class="docutils literal notranslate"><span class="pre">44100</span></code> (default), <code class="docutils literal notranslate"><span class="pre">48000</span></code> and <code class="docutils literal notranslate"><span class="pre">96000</span></code>.</p></li>
<li><p><em>channels</em> - the number of channels. The default value is 2 (stereo).</p></li>
<li><p><em>format</em> - the data format. This controls how the PCM device interprets data for playback, and how data is encoded in captures.
The default value is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_FORMAT_S16_LE</span></code>.</p></li>
</ul>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Format</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S8</span></code></p></td>
<td><p>Signed 8 bit samples for each channel</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U8</span></code></p></td>
<td><p>Unsigned 8 bit samples for each channel</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S16_LE</span></code></p></td>
<td><p>Signed 16 bit samples for each channel Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S16_BE</span></code></p></td>
<td><p>Signed 16 bit samples for each channel (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U16_LE</span></code></p></td>
<td><p>Unsigned 16 bit samples for each channel (Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U16_BE</span></code></p></td>
<td><p>Unsigned 16 bit samples for each channel (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S24_LE</span></code></p></td>
<td><p>Signed 24 bit samples for each channel (Little Endian byte order in 4 bytes)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S24_BE</span></code></p></td>
<td><p>Signed 24 bit samples for each channel (Big Endian byte order in 4 bytes)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U24_LE</span></code></p></td>
<td><p>Unsigned 24 bit samples for each channel (Little Endian byte order in 4 bytes)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U24_BE</span></code></p></td>
<td><p>Unsigned 24 bit samples for each channel (Big Endian byte order in 4 bytes)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S32_LE</span></code></p></td>
<td><p>Signed 32 bit samples for each channel (Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S32_BE</span></code></p></td>
<td><p>Signed 32 bit samples for each channel (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U32_LE</span></code></p></td>
<td><p>Unsigned 32 bit samples for each channel (Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U32_BE</span></code></p></td>
<td><p>Unsigned 32 bit samples for each channel (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_FLOAT_LE</span></code></p></td>
<td><p>32 bit samples encoded as float (Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_FLOAT_BE</span></code></p></td>
<td><p>32 bit samples encoded as float (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_FLOAT64_LE</span></code></p></td>
<td><p>64 bit samples encoded as float (Little Endian byte order)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_FLOAT64_BE</span></code></p></td>
<td><p>64 bit samples encoded as float (Big Endian byte order)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_MU_LAW</span></code></p></td>
<td><p>A logarithmic encoding (used by Sun .au files and telephony)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_A_LAW</span></code></p></td>
<td><p>Another logarithmic encoding</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_IMA_ADPCM</span></code></p></td>
<td><p>A 4:1 compressed format defined by the Interactive Multimedia Association.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_MPEG</span></code></p></td>
<td><p>MPEG encoded audio?</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_GSM</span></code></p></td>
<td><p>9600 bits/s constant rate encoding for speech</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S24_3LE</span></code></p></td>
<td><p>Signed 24 bit samples for each channel (Little Endian byte order in 3 bytes)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_S24_3BE</span></code></p></td>
<td><p>Signed 24 bit samples for each channel (Big Endian byte order in 3 bytes)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U24_3LE</span></code></p></td>
<td><p>Unsigned 24 bit samples for each channel (Little Endian byte order in 3 bytes)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_FORMAT_U24_3BE</span></code></p></td>
<td><p>Unsigned 24 bit samples for each channel (Big Endian byte order in 3 bytes)</p></td>
</tr>
</tbody>
</table>
<ul>
<li><p><em>periodsize</em> - the period size in frames.
Make sure you understand <a class="reference internal" href="terminology.html#term-period"><span class="std std-ref">the meaning of periods</span></a>.
The default value is 32, which is below the actual minimum of most devices,
and will therefore likely be larger in practice.</p></li>
<li><p><em>periods</em> - the number of periods in the buffer. The default value is 4.</p></li>
<li><p><em>device</em> - the name of the PCM device that should be used (for example
a value from the output of <a class="reference internal" href="#alsaaudio.pcms" title="alsaaudio.pcms"><code class="xref py py-func docutils literal notranslate"><span class="pre">pcms()</span></code></a>). The default value is
<code class="docutils literal notranslate"><span class="pre">'default'</span></code>.</p></li>
<li><p><em>cardindex</em> - the card index. If this argument is given, the device name
is constructed as hw:<em>cardindex</em> and
the <cite>device</cite> keyword argument is ignored.
<code class="docutils literal notranslate"><span class="pre">0</span></code> is the first hardware sound card.</p>
<p><strong>Note:</strong> This should not be used, as it bypasses most of ALSAs configuration.</p>
</li>
</ul>
<p>The defaults mentioned above are values passed by :mod:alsaaudio
to ALSA, not anything internal to ALSA.</p>
<p><strong>Note:</strong> For default and non-default values alike, there is no
guarantee that a PCM device supports the requested configuration,
and ALSA may pick realizable values which it believes to be closest
to the request. Therefore, after creating a PCM object, it is
necessary to verify whether its realized configuration is acceptable.
The :func:info method can be used to query it.</p>
<p><em>Changed in 0.10:</em></p>
<ul class="simple">
<li><p>Added the optional named parameter <cite>periods</cite>.</p></li>
</ul>
<p><em>Changed in 0.9:</em></p>
<ul class="simple">
<li><p>Added the optional named parameters <cite>rate</cite>, <cite>channels</cite>, <cite>format</cite> and <cite>periodsize</cite>.</p></li>
</ul>
<p><em>Changed in 0.8:</em></p>
<ul class="simple">
<li><p>The <cite>card</cite> keyword argument is still supported,
but deprecated. Please use <cite>device</cite> instead.</p></li>
<li><p>The keyword argument <cite>cardindex</cite> was added.</p></li>
</ul>
<p>The <cite>card</cite> keyword is deprecated because it guesses the real ALSA
name of the card. This was always fragile and broke some legitimate usecases.</p>
</dd></dl>
<p>PCM objects have the following methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.info">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">dict</span></span></span><a class="headerlink" href="#alsaaudio.PCM.info" title="Link to this definition"></a></dt>
<dd><p>Returns a dictionary containing the configuration of a PCM device.</p>
<p>A small subset of properties reflects fixed parameters given by the
user, stored within alsaaudio. To distinguish them from properties
retrieved from ALSA when the call is made, they have their name
prefixed with <strong>“ (call value) “</strong>.</p>
<p>Descriptions of properties which can be directly set during PCM object
instantiation carry the prefix “PCM():”, followed by the respective
constructor parameter. Note that due to device limitations, the values
may deviate from those originally requested.</p>
<p>Yet another set of properties cannot be set, and derives directly from
the hardware, possibly depending on other properties. Those properties
descriptions are prefixed with “hw:” below.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description (Reference)</p></th>
<th class="head"><p>Type</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>name</p></td>
<td><p>PCM():device</p></td>
<td><p>string</p></td>
</tr>
<tr class="row-odd"><td><p>card_no</p></td>
<td><p><em>index of card</em></p></td>
<td><p>integer (negative indicates device not associable with a card)</p></td>
</tr>
<tr class="row-even"><td><p>device_no</p></td>
<td><p><em>index of PCM device</em></p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-odd"><td><p>subdevice_no</p></td>
<td><p><em>index of PCM subdevice</em></p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-even"><td><p>state</p></td>
<td><p><em>name of PCM state</em></p></td>
<td><p>string</p></td>
</tr>
<tr class="row-odd"><td><p>access_type</p></td>
<td><p><em>name of PCM access type</em></p></td>
<td><p>string</p></td>
</tr>
<tr class="row-even"><td><p>(call value) type</p></td>
<td><p>PCM():type</p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-odd"><td><p>(call value) type_name</p></td>
<td><p>PCM():type</p></td>
<td><p>string</p></td>
</tr>
<tr class="row-even"><td><p>(call value) mode</p></td>
<td><p>PCM():mode</p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-odd"><td><p>(call value) mode_name</p></td>
<td><p>PCM():mode</p></td>
<td><p>string</p></td>
</tr>
<tr class="row-even"><td><p>format</p></td>
<td><p>PCM():format</p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-odd"><td><p>format_name</p></td>
<td><p>PCM():format</p></td>
<td><p>string</p></td>
</tr>
<tr class="row-even"><td><p>format_description</p></td>
<td><p>PCM():format</p></td>
<td><p>string</p></td>
</tr>
<tr class="row-odd"><td><p>subformat_name</p></td>
<td><p><em>name of PCM subformat</em></p></td>
<td><p>string</p></td>
</tr>
<tr class="row-even"><td><p>subformat_description</p></td>
<td><p><em>description of subformat</em></p></td>
<td><p>string</p></td>
</tr>
<tr class="row-odd"><td><p>channels</p></td>
<td><p>PCM():channels</p></td>
<td><p>integer</p></td>
</tr>
<tr class="row-even"><td><p>rate</p></td>
<td><p>PCM():rate</p></td>
<td><p>integer (Hz)</p></td>
</tr>
<tr class="row-odd"><td><p>period_time</p></td>
<td><p><em>period duration</em></p></td>
<td><p>integer (<span class="math notranslate nohighlight">\(\mu s\)</span>)</p></td>
</tr>
<tr class="row-even"><td><p>period_size</p></td>
<td><p>PCM():period_size</p></td>
<td><p>integer (frames)</p></td>
</tr>
<tr class="row-odd"><td><p>buffer_time</p></td>
<td><p><em>buffer time</em></p></td>
<td><p>integer (<span class="math notranslate nohighlight">\(\mu s\)</span>) (negative indicates error)</p></td>
</tr>
<tr class="row-even"><td><p>buffer_size</p></td>
<td><p><em>buffer size</em></p></td>
<td><p>integer (frames) (negative indicates error)</p></td>
</tr>
<tr class="row-odd"><td><p>get_periods</p></td>
<td><p><em>approx. periods in buffer</em></p></td>
<td><p>integer (negative indicates error)</p></td>
</tr>
<tr class="row-even"><td><p>rate_numden</p></td>
<td><p><em>numerator, denominator</em></p></td>
<td><p>tuple (integer (Hz), integer (Hz))</p></td>
</tr>
<tr class="row-odd"><td><p>significant_bits</p></td>
<td><p><em>significant bits in sample</em> <a class="footnote-reference brackets" href="#tss" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></td>
<td><p>integer (negative indicates error)</p></td>
</tr>
<tr class="row-even"><td><p>nominal_bits</p></td>
<td><p><em>nominal bits in sample</em> <a class="footnote-reference brackets" href="#tss" id="id3" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></td>
<td><p>integer (negative indicates error)</p></td>
</tr>
<tr class="row-odd"><td><p>physical_bits</p></td>
<td><p><em>sample width in bits</em> <a class="footnote-reference brackets" href="#tss" id="id4" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></td>
<td><p>integer (negative indicates error)</p></td>
</tr>
<tr class="row-even"><td><p>is_batch</p></td>
<td><p><em>hw: double buffering</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-odd"><td><p>is_block_transfer</p></td>
<td><p><em>hw: block transfer</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-even"><td><p>is_double</p></td>
<td><p><em>hw: double buffering</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-odd"><td><p>is_half_duplex</p></td>
<td><p><em>hw: half-duplex</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-even"><td><p>is_joint_duplex</p></td>
<td><p><em>hw: joint-duplex</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-odd"><td><p>can_overrange</p></td>
<td><p><em>hw: overrange detection</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-even"><td><p>can_mmap_sample_resolution</p></td>
<td><p><em>hw: sample-resol. mmap</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-odd"><td><p>can_pause</p></td>
<td><p><em>hw: pause</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-even"><td><p>can_resume</p></td>
<td><p><em>hw: resume</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
<tr class="row-odd"><td><p>can_sync_start</p></td>
<td><p><em>hw: synchronized start</em></p></td>
<td><p>boolean (True: hardware supported)</p></td>
</tr>
</tbody>
</table>
</dd></dl>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="tss" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id2">1</a>,<a role="doc-backlink" href="#id3">2</a>,<a role="doc-backlink" href="#id4">3</a>)</span>
<p>More information in the <a class="reference internal" href="terminology.html#term-sample-size"><span class="std std-ref">terminology section for sample size</span></a></p>
</aside>
</aside>
<blockquote>
<div><p>The italicized descriptions give a summary of the “full” description
as can be found in the
<a class="reference external" href="https://www.alsa-project.org/alsa-doc">ALSA documentation</a>.</p>
<p><em>New in 0.9.1</em></p>
</div></blockquote>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.dumpinfo">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">dumpinfo</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#alsaaudio.PCM.dumpinfo" title="Link to this definition"></a></dt>
<dd><p>Dumps the PCM objects configured parameters to stdout.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.pcmtype">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">pcmtype</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.pcmtype" title="Link to this definition"></a></dt>
<dd><p>Returns the type of PCM object. Either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code> or
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.pcmmode">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">pcmmode</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.pcmmode" title="Link to this definition"></a></dt>
<dd><p>Return the mode of the PCM object. One of <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_ASYNC</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.cardname">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">cardname</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">string</span></span></span><a class="headerlink" href="#alsaaudio.PCM.cardname" title="Link to this definition"></a></dt>
<dd><p>Return the name of the sound card used by this PCM object.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.setchannels">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">setchannels</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nchannels</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.setchannels" title="Link to this definition"></a></dt>
<dd><div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 0.9: </span>Use the <cite>channels</cite> named argument to <code class="xref py py-func docutils literal notranslate"><span class="pre">PCM()</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.setrate">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">setrate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rate</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.setrate" title="Link to this definition"></a></dt>
<dd><div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 0.9: </span>Use the <cite>rate</cite> named argument to <code class="xref py py-func docutils literal notranslate"><span class="pre">PCM()</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.setformat">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">setformat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">format</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.setformat" title="Link to this definition"></a></dt>
<dd><div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 0.9: </span>Use the <cite>format</cite> named argument to <code class="xref py py-func docutils literal notranslate"><span class="pre">PCM()</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.setperiodsize">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">setperiodsize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">period</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.setperiodsize" title="Link to this definition"></a></dt>
<dd><div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 0.9: </span>Use the <cite>periodsize</cite> named argument to <code class="xref py py-func docutils literal notranslate"><span class="pre">PCM()</span></code>.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.state">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.state" title="Link to this definition"></a></dt>
<dd><p>Returs the current state of the stream, which can be one of
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_OPEN</span></code> (this should not actually happen),
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_SETUP</span></code> (after <a class="reference internal" href="#alsaaudio.PCM.drop" title="alsaaudio.PCM.drop"><code class="xref py py-func docutils literal notranslate"><span class="pre">drop()</span></code></a> or <a class="reference internal" href="#alsaaudio.PCM.drain" title="alsaaudio.PCM.drain"><code class="xref py py-func docutils literal notranslate"><span class="pre">drain()</span></code></a>),
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_PREPARED</span></code> (after construction),
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_RUNNING</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_XRUN</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_DRAINING</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_PAUSED</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_SUSPENDED</span></code>, and
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_STATE_DISCONNECTED</span></code>.</p>
<p><em>New in 0.10</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.avail">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">avail</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.avail" title="Link to this definition"></a></dt>
<dd><p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> PCM objects, returns the number of writable
(that is, free) frames in the buffer.</p>
<p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code> PCM objects, returns the number of readable
(that is, filled) frames in the buffer.</p>
<p>An attempt to read/write more frames than indicated will block (in
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode) or fail and return zero (in
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code> mode).</p>
<p><em>New in 0.11</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.read">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">read</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">bytes</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.PCM.read" title="Link to this definition"></a></dt>
<dd><p>In <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode, this function blocks until a full period is
available, and then returns a tuple (length,data) where <em>length</em> is
the number of frames of captured data, and <em>data</em> is the captured
sound frames as a string. The length of the returned data will be
periodsize*framesize bytes.</p>
<p>In <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code> mode, the call will not block, but will return
<code class="docutils literal notranslate"><span class="pre">(0,'')</span></code> if no new period has become available since the last
call to read.</p>
<p>In case of a buffer overrun, this function will return the negative
size <code class="xref py py-const docutils literal notranslate"><span class="pre">-EPIPE</span></code>, and no data is read.
This indicates that data was lost. To resume capturing, just call read
again, but note that the stream was already corrupted.
To avoid the problem in the future, try using a larger period size
and/or more periods, at the cost of higher latency.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.write">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bytes</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.write" title="Link to this definition"></a></dt>
<dd><p>Writes (plays) the sound in data. The length of data <em>must</em> be a
multiple of the frame size, and <em>should</em> be exactly the size of a
period. If less than period size frames are provided, the actual
playout will not happen until more data is written.</p>
<p>If the data was successfully written, the call returns the size of the
data <em>in frames</em>.</p>
<p>If the device is not in <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code> mode, this call will block
if the kernel buffer is full, and until enough sound has been played
to allow the sound data to be buffered.</p>
<p>In <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code> mode, the call will return immediately, with a
return value of zero, if the buffer is full. In this case, the data
should be written again at a later time.</p>
<p>In case of a buffer underrun, this function will return the negative
size <code class="xref py py-const docutils literal notranslate"><span class="pre">-EPIPE</span></code>, and no data is written.
At this point, the playback was already corrupted. If you want to play
the data nonetheless, call write again with the same data.
To avoid the problem in the future, try using a larger period size
and/or more periods, at the cost of higher latency.</p>
<p>Note that this call completing means only that the samples were buffered
in the kernel, and playout will continue afterwards. Make sure that the
stream is drained before discarding the PCM handle.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.pause">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">pause</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">enable:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">True</span></span></em><span class="optional">]</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.pause" title="Link to this definition"></a></dt>
<dd><p>If <em>enable</em> is <code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code>, playback or capture is paused.
Otherwise, playback/capture is resumed.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.drop">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">drop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.drop" title="Link to this definition"></a></dt>
<dd><p>Stop the stream and drop residual buffered frames.</p>
<p><em>New in 0.9</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.drain">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">drain</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.drain" title="Link to this definition"></a></dt>
<dd><p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> PCM objects, play residual buffered frames
and then stop the stream. In <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode,
this function blocks until all pending playback is drained.</p>
<p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code> PCM objects, this function is not very useful.</p>
<p><em>New in 0.10</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.close">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.PCM.close" title="Link to this definition"></a></dt>
<dd><p>Closes the PCM device.</p>
<p>For <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> PCM objects in <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode,
this function blocks until all pending playback is drained.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.polldescriptors">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">polldescriptors</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.PCM.polldescriptors" title="Link to this definition"></a></dt>
<dd><p>Returns a list of tuples of <em>(file descriptor, eventmask)</em> that can be
used to wait for changes on the PCM with <em>select.poll</em>.</p>
<p>The <em>eventmask</em> value is compatible with <a href="#id6"><span class="problematic" id="id7">`poll.register`__</span></a> in the Python
<code class="xref py py-const docutils literal notranslate"><span class="pre">select</span></code> module.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.polldescriptors_revents">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">polldescriptors_revents</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">descriptors</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.polldescriptors_revents" title="Link to this definition"></a></dt>
<dd><p>Processes the descriptor list returned by <a class="reference internal" href="#alsaaudio.PCM.polldescriptors" title="alsaaudio.PCM.polldescriptors"><code class="xref py py-func docutils literal notranslate"><span class="pre">polldescriptors()</span></code></a> after
using it with <em>select.poll</em>, and returns a single <em>eventmask</em> value that
is meaningful for deciding whether <a class="reference internal" href="#alsaaudio.PCM.read" title="alsaaudio.PCM.read"><code class="xref py py-func docutils literal notranslate"><span class="pre">read()</span></code></a> or <a class="reference internal" href="#alsaaudio.PCM.write" title="alsaaudio.PCM.write"><code class="xref py py-func docutils literal notranslate"><span class="pre">write()</span></code></a> should
be called.</p>
<p><em>New in 0.11</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.set_tstamp_mode">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">set_tstamp_mode</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">mode:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">PCM_TSTAMP_ENABLE</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#alsaaudio.PCM.set_tstamp_mode" title="Link to this definition"></a></dt>
<dd><p>Set the ALSA timestamp mode on the device. The mode argument can be set to
either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_NONE</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_ENABLE</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.get_tstamp_mode">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">get_tstamp_mode</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.get_tstamp_mode" title="Link to this definition"></a></dt>
<dd><p>Return the integer value corresponding to the ALSA timestamp mode. The
return value can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_NONE</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_ENABLE</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.set_tstamp_type">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">set_tstamp_type</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">type:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">PCM_TSTAMP_TYPE_GETTIMEOFDAY</span></span></em><span class="optional">]</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.PCM.set_tstamp_type" title="Link to this definition"></a></dt>
<dd><p>Set the ALSA timestamp mode on the device. The type argument
can be set to either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_GETTIMEOFDAY</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC_RAW</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.get_tstamp_type">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">get_tstamp_type</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.PCM.get_tstamp_type" title="Link to this definition"></a></dt>
<dd><p>Return the integer value corresponding to the ALSA timestamp type. The
return value can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_GETTIMEOFDAY</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC</span></code> or <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC_RAW</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.PCM.htimestamp">
<span class="sig-prename descclassname"><span class="pre">PCM.</span></span><span class="sig-name descname"><span class="pre">htimestamp</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.PCM.htimestamp" title="Link to this definition"></a></dt>
<dd><p>Return a Python tuple <em>(seconds, nanoseconds, frames_available_in_buffer)</em>.</p>
<p>The type of output is controlled by the tstamp_type, as described in the table below.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Timestamp Type</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_GETTIMEOFDAY</span></code></p></td>
<td><p>System-wide realtime clock with seconds
since epoch.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC</span></code></p></td>
<td><p>Monotonic time from an unspecified starting
time. Progress is NTP synchronized.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_TSTAMP_TYPE_MONOTONIC_RAW</span></code></p></td>
<td><p>Monotonic time from an unspecified starting
time using only the system clock.</p></td>
</tr>
</tbody>
</table>
<p>The timestamp mode is controlled by the tstamp_mode, as described in the table below.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Timestamp Mode</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_TSTAMP_NONE</span></code></p></td>
<td><p>No timestamp.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">PCM_TSTAMP_ENABLE</span></code></p></td>
<td><p>Update timestamp at every hardware position
update.</p></td>
</tr>
</tbody>
</table>
</dd></dl>
<p><strong>A few hints on using PCM devices for playback</strong></p>
<p>The most common reason for problems with playback of PCM audio is that writes
to PCM devices must <em>exactly</em> match the data rate of the device.</p>
<p>If too little data is written to the device, it will underrun, and
ugly clicking sounds will occur. Conversely, if too much data is
written to the device, the write function will either block
(<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode) or return zero (<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NONBLOCK</span></code> mode).</p>
<p>If your program does nothing but play sound, the best strategy is to put the
device in <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_NORMAL</span></code> mode, and just write as much data to the device as
possible. This strategy can also be achieved by using a separate
thread with the sole task of playing out sound.</p>
<p>In GUI programs, however, it may be a better strategy to setup the device,
preload the buffer with a few periods by calling write a couple of times, and
then use some timer method to write one period size of data to the device every
period. The purpose of the preloading is to avoid underrun clicks if the used
timer doesnt expire exactly on time.</p>
<p>Also note, that most timer APIs that you can find for Python will
accummulate time delays: If you set the timer to expire after 1/10th
of a second, the actual timeout will happen slightly later, which will
accumulate to quite a lot after a few seconds. Hint: use time.time()
to check how much time has really passed, and add extra writes as nessecary.</p>
</section>
<section id="mixer-objects">
<span id="id5"></span><h2>Mixer Objects<a class="headerlink" href="#mixer-objects" title="Link to this heading"></a></h2>
<p>Mixer objects provides access to the ALSA mixer API.</p>
<dl class="py class">
<dt class="sig sig-object py" id="alsaaudio.Mixer">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">alsaaudio.</span></span><span class="sig-name descname"><span class="pre">Mixer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">control</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'Master'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cardindex</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'default'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#alsaaudio.Mixer" title="alsaaudio.Mixer"><span class="pre">Mixer</span></a></span></span><a class="headerlink" href="#alsaaudio.Mixer" title="Link to this definition"></a></dt>
<dd><p>Arguments are:</p>
<ul class="simple">
<li><p><em>control</em> - specifies which control to manipulate using this mixer
object. The list of available controls can be found with the
<a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a>.<a class="reference internal" href="#alsaaudio.mixers" title="alsaaudio.mixers"><code class="xref py py-func docutils literal notranslate"><span class="pre">mixers()</span></code></a> function. The default value is
<code class="docutils literal notranslate"><span class="pre">'Master'</span></code> - other common controls may be <code class="docutils literal notranslate"><span class="pre">'Master</span> <span class="pre">Mono'</span></code>, <code class="docutils literal notranslate"><span class="pre">'PCM'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'Line'</span></code>, etc.</p></li>
<li><p><em>id</em> - the id of the mixer control. Default is <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p></li>
<li><p><em>cardindex</em> - specifies which card should be used. If this argument
is given, the device name is constructed like this: hw:<em>cardindex</em> and
the <cite>device</cite> keyword argument is ignored. <code class="docutils literal notranslate"><span class="pre">0</span></code> is the
first sound card.</p></li>
<li><p><em>device</em> - the name of the device on which the mixer resides. The default
value is <code class="docutils literal notranslate"><span class="pre">'default'</span></code>.</p></li>
</ul>
<p><em>Changed in 0.8</em>:</p>
<ul class="simple">
<li><p>The keyword argument <cite>device</cite> is new and can be used to select virtual
devices.</p></li>
</ul>
</dd></dl>
<p>Mixer objects have the following methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.cardname">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">cardname</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.cardname" title="Link to this definition"></a></dt>
<dd><p>Return the name of the sound card used by this Mixer object</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.mixer">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">mixer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.mixer" title="Link to this definition"></a></dt>
<dd><p>Return the name of the specific mixer controlled by this object, For example
<code class="docutils literal notranslate"><span class="pre">'Master'</span></code> or <code class="docutils literal notranslate"><span class="pre">'PCM'</span></code></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.mixerid">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">mixerid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.mixerid" title="Link to this definition"></a></dt>
<dd><p>Return the ID of the ALSA mixer controlled by this object.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.switchcap">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">switchcap</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.switchcap" title="Link to this definition"></a></dt>
<dd><p>Returns a list of the switches which are defined by this specific mixer.
Possible values in this list are:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Switch</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Mute</p></td>
<td><p>This mixer can mute</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Mute</p></td>
<td><p>This mixer can mute all channels at the same time</p></td>
</tr>
<tr class="row-even"><td><p>Playback Mute</p></td>
<td><p>This mixer can mute the playback output</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Playback Mute</p></td>
<td><p>Mute playback for all channels at the same time}</p></td>
</tr>
<tr class="row-even"><td><p>Capture Mute</p></td>
<td><p>Mute sound capture</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Capture Mute</p></td>
<td><p>Mute sound capture for all channels at a time}</p></td>
</tr>
<tr class="row-even"><td><p>Capture Exclusive</p></td>
<td><p>Not quite sure what this is</p></td>
</tr>
</tbody>
</table>
<p>To manipulate these switches use the <a class="reference internal" href="#alsaaudio.Mixer.setrec" title="alsaaudio.Mixer.setrec"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setrec()</span></code></a> or
<a class="reference internal" href="#alsaaudio.Mixer.setmute" title="alsaaudio.Mixer.setmute"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setmute()</span></code></a> methods</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.volumecap">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">volumecap</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.volumecap" title="Link to this definition"></a></dt>
<dd><p>Returns a list of the volume control capabilities of this
mixer. Possible values in the list are:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Capability</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Volume</p></td>
<td><p>This mixer can control volume</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Volume</p></td>
<td><p>This mixer can control volume for all channels at the same time</p></td>
</tr>
<tr class="row-even"><td><p>Playback Volume</p></td>
<td><p>This mixer can manipulate the playback output</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Playback Volume</p></td>
<td><p>Manipulate playback volumne for all channels at the same time</p></td>
</tr>
<tr class="row-even"><td><p>Capture Volume</p></td>
<td><p>Manipulate sound capture volume</p></td>
</tr>
<tr class="row-odd"><td><p>Joined Capture Volume</p></td>
<td><p>Manipulate sound capture volume for all channels at a time</p></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.getenum">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">getenum</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.Mixer.getenum" title="Link to this definition"></a></dt>
<dd><p>For enumerated controls, return the currently selected item and the list of
items available.</p>
<p>Returns a tuple <em>(string, list of strings)</em>.</p>
<p>For example, my soundcard has a Mixer called <em>Mono Output Select</em>. Using
<em>amixer</em>, I get:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ amixer get &quot;Mono Output Select&quot;
Simple mixer control &#39;Mono Output Select&#39;,0
Capabilities: enum
Items: &#39;Mix&#39; &#39;Mic&#39;
Item0: &#39;Mix&#39;
</pre></div>
</div>
<p>Using <a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a>, one could do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">alsaaudio</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">alsaaudio</span><span class="o">.</span><span class="n">Mixer</span><span class="p">(</span><span class="s1">&#39;Mono Output Select&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span><span class="o">.</span><span class="n">getenum</span><span class="p">()</span>
<span class="go">(&#39;Mix&#39;, [&#39;Mix&#39;, &#39;Mic&#39;])</span>
</pre></div>
</div>
<p>This method will return an empty tuple if the mixer is not an enumerated
control.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.setenum">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">setenum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.setenum" title="Link to this definition"></a></dt>
<dd><p>For enumerated controls, sets the currently selected item.
<em>index</em> is an index into the list of available enumerated items returned
by <a class="reference internal" href="#alsaaudio.Mixer.getenum" title="alsaaudio.Mixer.getenum"><code class="xref py py-func docutils literal notranslate"><span class="pre">getenum()</span></code></a>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.getrange">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">getrange</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pcmtype</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">PCM_PLAYBACK</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">units</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">VOLUME_UNITS_RAW</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.Mixer.getrange" title="Link to this definition"></a></dt>
<dd><p>Return the volume range of the ALSA mixer controlled by this object.
The value is a tuple of integers whose meaning is determined by the
<em>units</em> argument.</p>
<p>The optional <em>pcmtype</em> argument can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> or
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>, which is relevant if the mixer can control both
playback and capture volume. The default value is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>
if the mixer has playback channels, otherwise it is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>.</p>
<p>The optional <em>units</em> argument can be one of <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_PERCENTAGE</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_RAW</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_DB</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.getvolume">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">getvolume</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pcmtype</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">PCM_PLAYBACK</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">units</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">VOLUME_UNITS_PERCENTAGE</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.getvolume" title="Link to this definition"></a></dt>
<dd><p>Returns a list with the current volume settings for each channel. The list
elements are integers whose meaning is determined by the <em>units</em> argument.</p>
<p>The optional <em>pcmtype</em> argument can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> or
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>, which is relevant if the mixer can control both
playback and capture volume. The default value is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>
if the mixer has playback channels, otherwise it is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>.</p>
<p>The optional <em>units</em> argument can be one of <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_PERCENTAGE</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_RAW</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_DB</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.setvolume">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">setvolume</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">volume</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pcmtype</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">PCM_PLAYBACK</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">units</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">VOLUME_UNITS_PERCENTAGE</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">channel</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.setvolume" title="Link to this definition"></a></dt>
<dd><p>Change the current volume settings for this mixer. The <em>volume</em> argument
is an integer whose meaning is determined by the <em>units</em> argument.</p>
<p>If the optional argument <em>channel</em> is present, the volume is set
only for this channel. This assumes that the mixer can control the
volume for the channels independently.</p>
<p>The optional <em>pcmtype</em> argument can be either <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code> or
<code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>, which is relevant if the mixer can control both
playback and capture volume. The default value is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_PLAYBACK</span></code>
if the mixer has playback channels, otherwise it is <code class="xref py py-const docutils literal notranslate"><span class="pre">PCM_CAPTURE</span></code>.</p>
<p>The optional <em>units</em> argument can be one of <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_PERCENTAGE</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_RAW</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">VOLUME_UNITS_DB</span></code>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.getmute">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">getmute</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.Mixer.getmute" title="Link to this definition"></a></dt>
<dd><p>Return a list indicating the current mute setting for each channel.
0 means not muted, 1 means muted.</p>
<p>This method will fail if the mixer has no playback switch capabilities.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.setmute">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">setmute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mute</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">channel</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.setmute" title="Link to this definition"></a></dt>
<dd><p>Sets the mute flag to a new value. The <em>mute</em> argument is either 0 for not
muted, or 1 for muted.</p>
<p>The optional <em>channel</em> argument controls which channel is
muted. The default is to set the mute flag for all channels.</p>
<p>This method will fail if the mixer has no playback mute capabilities</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.getrec">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">getrec</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.Mixer.getrec" title="Link to this definition"></a></dt>
<dd><p>Return a list indicating the current record mute setting for each channel.
0 means not recording, 1 means recording.</p>
<p>This method will fail if the mixer has no capture switch capabilities.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.setrec">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">setrec</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">capture</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">channel</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.setrec" title="Link to this definition"></a></dt>
<dd><p>Sets the capture mute flag to a new value. The <em>capture</em> argument
is either 0 for no capture, or 1 for capture.</p>
<p>The optional <em>channel</em> argument controls which channel is
changed. The default is to set the capture flag for all channels.</p>
<p>This method will fail if the mixer has no capture switch capabilities.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.polldescriptors">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">polldescriptors</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#alsaaudio.Mixer.polldescriptors" title="Link to this definition"></a></dt>
<dd><p>Returns a list of tuples of <em>(file descriptor, eventmask)</em> that can be
used to wait for changes on the mixer with <em>select.poll</em>.</p>
<p>The <em>eventmask</em> value is compatible with <a href="#id6"><span class="problematic" id="id8">`poll.register`__</span></a> in the Python
<code class="xref py py-const docutils literal notranslate"><span class="pre">select</span></code> module.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.handleevents">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">handleevents</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.handleevents" title="Link to this definition"></a></dt>
<dd><p>Acknowledge events on the <a class="reference internal" href="#alsaaudio.Mixer.polldescriptors" title="alsaaudio.Mixer.polldescriptors"><code class="xref py py-func docutils literal notranslate"><span class="pre">polldescriptors()</span></code></a> file descriptors
to prevent subsequent polls from returning the same events again.
Returns the number of events that were acknowledged.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="alsaaudio.Mixer.close">
<span class="sig-prename descclassname"><span class="pre">Mixer.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#alsaaudio.Mixer.close" title="Link to this definition"></a></dt>
<dd><p>Closes the Mixer device.</p>
</dd></dl>
<p><strong>A rant on the ALSA Mixer API</strong></p>
<p>The ALSA mixer API is extremely complicated - and hardly documented at all.
<a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a> implements a much simplified way to access this API. In
designing the API Ive had to make some choices which may limit what can and
cannot be controlled through the API. However, if I had chosen to implement the
full API, I would have reexposed the horrible complexity/documentation ratio of
the underlying API. At least the <a class="reference internal" href="#module-alsaaudio" title="alsaaudio (Linux)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a> API is easy to
understand and use.</p>
<p>If my design choises prevents you from doing something that the underlying API
would have allowed, please let me know, so I can incorporate these needs into
future versions.</p>
<p>If the current state of affairs annoys you, the best you can do is to write a
HOWTO on the API and make this available on the net. Until somebody does this,
the availability of ALSA mixer capable devices will stay quite limited.</p>
<p>Unfortunately, Im not able to create such a HOWTO myself, since I only
understand half of the API, and that which I do understand has come from a
painful trial and error process.</p>
</section>
<section id="examples">
<span id="pcm-example"></span><h2>Examples<a class="headerlink" href="#examples" title="Link to this heading"></a></h2>
<p>The following example are provided:</p>
<ul class="simple">
<li><p><cite>playwav.py</cite></p></li>
<li><p><cite>recordtest.py</cite></p></li>
<li><p><cite>playbacktest.py</cite></p></li>
<li><p><cite>mixertest.py</cite></p></li>
</ul>
<p>All examples (except <cite>mixertest.py</cite>) accept the commandline option
<em>-c &lt;cardname&gt;</em>.</p>
<p>To determine a valid card name, use the commandline ALSA player:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ aplay -L
</pre></div>
</div>
<p>or:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python
&gt;&gt;&gt; import alsaaudio
&gt;&gt;&gt; alsaaudio.pcms()
</pre></div>
</div>
<p>mixertest.py accepts the commandline options <em>-d &lt;device&gt;</em> and
<em>-c &lt;cardindex&gt;</em>.</p>
<section id="playwav-py">
<h3>playwav.py<a class="headerlink" href="#playwav-py" title="Link to this heading"></a></h3>
<p><strong>playwav.py</strong> plays a wav file.</p>
<p>To test PCM playback (on your default soundcard), run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python playwav.py &lt;wav file&gt;
</pre></div>
</div>
</section>
<section id="recordtest-py-and-playbacktest-py">
<h3>recordtest.py and playbacktest.py<a class="headerlink" href="#recordtest-py-and-playbacktest-py" title="Link to this heading"></a></h3>
<p><strong>recordtest.py</strong> and <strong>playbacktest.py</strong> will record and play a raw
sound file in CD quality.</p>
<p>To test PCM recordings (on your default soundcard), run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python recordtest.py &lt;filename&gt;
</pre></div>
</div>
<p>Speak into the microphone, and interrupt the recording at any time
with <code class="docutils literal notranslate"><span class="pre">Ctl-C</span></code>.</p>
<p>Play back the recording with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python playbacktest.py &lt;filename&gt;
</pre></div>
</div>
</section>
<section id="mixertest-py">
<h3>mixertest.py<a class="headerlink" href="#mixertest-py" title="Link to this heading"></a></h3>
<p>Without arguments, <strong>mixertest.py</strong> will list all available <em>controls</em> on the
default soundcard.</p>
<p>The output might look like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ./mixertest.py
Available mixer controls:
&#39;Master&#39;
&#39;Master Mono&#39;
&#39;Headphone&#39;
&#39;PCM&#39;
&#39;Line&#39;
&#39;Line In-&gt;Rear Out&#39;
&#39;CD&#39;
&#39;Mic&#39;
&#39;PC Speaker&#39;
&#39;Aux&#39;
&#39;Mono Output Select&#39;
&#39;Capture&#39;
&#39;Mix&#39;
&#39;Mix Mono&#39;
</pre></div>
</div>
<p>With a single argument - the <em>control</em>, it will display the settings of
that control; for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ./mixertest.py Master
Mixer name: &#39;Master&#39;
Capabilities: Playback Volume Playback Mute
Channel 0 volume: 61%
Channel 1 volume: 61%
</pre></div>
</div>
<p>With two arguments, the <em>control</em> and a <em>parameter</em>, it will set the
parameter on the mixer:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ./mixertest.py Master mute
</pre></div>
</div>
<p>This will mute the Master mixer.</p>
<p>Or:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ./mixertest.py Master 40
</pre></div>
</div>
<p>This sets the volume to 40% on all channels.</p>
<p>To select a different soundcard, use either the <em>device</em> or <em>cardindex</em>
argument:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ./mixertest.py -c 0 Master
Mixer name: &#39;Master&#39;
Capabilities: Playback Volume Playback Mute
Channel 0 volume: 61%
Channel 1 volume: 61%
</pre></div>
</div>
</section>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a><ul>
<li><a class="reference internal" href="#alsaaudio.pcms"><code class="docutils literal notranslate"><span class="pre">pcms()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.cards"><code class="docutils literal notranslate"><span class="pre">cards()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.mixers"><code class="docutils literal notranslate"><span class="pre">mixers()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.asoundlib_version"><code class="docutils literal notranslate"><span class="pre">asoundlib_version()</span></code></a></li>
<li><a class="reference internal" href="#pcm-objects">PCM Objects</a><ul>
<li><a class="reference internal" href="#alsaaudio.PCM.info"><code class="docutils literal notranslate"><span class="pre">PCM.info()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.dumpinfo"><code class="docutils literal notranslate"><span class="pre">PCM.dumpinfo()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.pcmtype"><code class="docutils literal notranslate"><span class="pre">PCM.pcmtype()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.pcmmode"><code class="docutils literal notranslate"><span class="pre">PCM.pcmmode()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.cardname"><code class="docutils literal notranslate"><span class="pre">PCM.cardname()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.setchannels"><code class="docutils literal notranslate"><span class="pre">PCM.setchannels()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.setrate"><code class="docutils literal notranslate"><span class="pre">PCM.setrate()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.setformat"><code class="docutils literal notranslate"><span class="pre">PCM.setformat()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.setperiodsize"><code class="docutils literal notranslate"><span class="pre">PCM.setperiodsize()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.state"><code class="docutils literal notranslate"><span class="pre">PCM.state()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.avail"><code class="docutils literal notranslate"><span class="pre">PCM.avail()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.read"><code class="docutils literal notranslate"><span class="pre">PCM.read()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.write"><code class="docutils literal notranslate"><span class="pre">PCM.write()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.pause"><code class="docutils literal notranslate"><span class="pre">PCM.pause()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.drop"><code class="docutils literal notranslate"><span class="pre">PCM.drop()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.drain"><code class="docutils literal notranslate"><span class="pre">PCM.drain()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.close"><code class="docutils literal notranslate"><span class="pre">PCM.close()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.polldescriptors"><code class="docutils literal notranslate"><span class="pre">PCM.polldescriptors()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.polldescriptors_revents"><code class="docutils literal notranslate"><span class="pre">PCM.polldescriptors_revents()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.set_tstamp_mode"><code class="docutils literal notranslate"><span class="pre">PCM.set_tstamp_mode()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.get_tstamp_mode"><code class="docutils literal notranslate"><span class="pre">PCM.get_tstamp_mode()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.set_tstamp_type"><code class="docutils literal notranslate"><span class="pre">PCM.set_tstamp_type()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.get_tstamp_type"><code class="docutils literal notranslate"><span class="pre">PCM.get_tstamp_type()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.PCM.htimestamp"><code class="docutils literal notranslate"><span class="pre">PCM.htimestamp()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#mixer-objects">Mixer Objects</a><ul>
<li><a class="reference internal" href="#alsaaudio.Mixer"><code class="docutils literal notranslate"><span class="pre">Mixer</span></code></a><ul>
<li><a class="reference internal" href="#alsaaudio.Mixer.cardname"><code class="docutils literal notranslate"><span class="pre">Mixer.cardname()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.mixer"><code class="docutils literal notranslate"><span class="pre">Mixer.mixer()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.mixerid"><code class="docutils literal notranslate"><span class="pre">Mixer.mixerid()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.switchcap"><code class="docutils literal notranslate"><span class="pre">Mixer.switchcap()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.volumecap"><code class="docutils literal notranslate"><span class="pre">Mixer.volumecap()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.getenum"><code class="docutils literal notranslate"><span class="pre">Mixer.getenum()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.setenum"><code class="docutils literal notranslate"><span class="pre">Mixer.setenum()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.getrange"><code class="docutils literal notranslate"><span class="pre">Mixer.getrange()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.getvolume"><code class="docutils literal notranslate"><span class="pre">Mixer.getvolume()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.setvolume"><code class="docutils literal notranslate"><span class="pre">Mixer.setvolume()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.getmute"><code class="docutils literal notranslate"><span class="pre">Mixer.getmute()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.setmute"><code class="docutils literal notranslate"><span class="pre">Mixer.setmute()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.getrec"><code class="docutils literal notranslate"><span class="pre">Mixer.getrec()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.setrec"><code class="docutils literal notranslate"><span class="pre">Mixer.setrec()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.polldescriptors"><code class="docutils literal notranslate"><span class="pre">Mixer.polldescriptors()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.handleevents"><code class="docutils literal notranslate"><span class="pre">Mixer.handleevents()</span></code></a></li>
<li><a class="reference internal" href="#alsaaudio.Mixer.close"><code class="docutils literal notranslate"><span class="pre">Mixer.close()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#playwav-py">playwav.py</a></li>
<li><a class="reference internal" href="#recordtest-py-and-playbacktest-py">recordtest.py and playbacktest.py</a></li>
<li><a class="reference internal" href="#mixertest-py">mixertest.py</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div><div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="terminology.html" title="previous chapter">PCM Terminology and Concepts</a></li>
</ul></li>
</ul>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/libalsaaudio.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2017, Lars Immisch & Casper Wilstrup.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.3.7</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/libalsaaudio.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>