Files
sw_pyalsaaudio/pyalsaaudio.html
Lars Immisch cbca6be937 Release 0.9.2
2022-05-06 21:34:15 +02:00

217 lines
10 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>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Introduction &#8212; alsaaudio documentation 0.9.2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="PCM Terminology and Concepts" href="terminology.html" />
<link rel="prev" title="alsaaudio documentation" href="index.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="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author</dt>
<dd class="field-odd"><p>Casper Wilstrup &lt;<a class="reference external" href="mailto:cwi&#37;&#52;&#48;aves&#46;dk">cwi<span>&#64;</span>aves<span>&#46;</span>dk</a>&gt;</p>
</dd>
<dt class="field-even">Author</dt>
<dd class="field-even"><p>Lars Immisch &lt;<a class="reference external" href="mailto:lars&#37;&#52;&#48;ibp&#46;de">lars<span>&#64;</span>ibp<span>&#46;</span>de</a>&gt;</p>
</dd>
</dl>
<p id="front">This software is licensed under the PSF license - the same one used by the
majority of the python distribution. Basically you can use it for anything you
wish (even commercial purposes). There is no warranty whatsoever.</p>
<div class="topic">
<p class="topic-title">Abstract</p>
<p>This package contains wrappers for accessing the ALSA API from Python. It is
currently fairly complete for PCM devices and Mixer access. MIDI sequencer
support is low on our priority list, but volunteers are welcome.</p>
<p>If you find bugs in the wrappers please use thegithub issue tracker.
Please dont send bug reports regarding ALSA specifically. There are several
bugs in this API, and those should be reported to the ALSA team - not me.</p>
</div>
</section>
<section id="what-is-alsa">
<h1>What is ALSA<a class="headerlink" href="#what-is-alsa" title="Permalink to this headline"></a></h1>
<p>The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI
functionality to the Linux operating system.</p>
<p>Logically ALSA consists of these components:</p>
<ul class="simple">
<li><p>A set of kernel drivers. — These drivers are responsible for handling the
physical sound hardware from within the Linux kernel, and have been the
standard sound implementation in Linux since kernel version 2.5</p></li>
<li><p>A kernel level API for manipulating the ALSA devices.</p></li>
<li><p>A user-space C library for simplified access to the sound hardware from
userspace applications. This library is called <em>libasound</em> and is required by
all ALSA capable applications.</p></li>
</ul>
<p>More information about ALSA may be found on the project homepage
<a class="reference external" href="http://www.alsa-project.org">http://www.alsa-project.org</a></p>
<section id="alsa-and-python">
<h2>ALSA and Python<a class="headerlink" href="#alsa-and-python" title="Permalink to this headline"></a></h2>
<p>The older Linux sound API (OSS) which is now deprecated is well supported from
the standard Python library, through the ossaudiodev module. No native ALSA
support exists in the standard library.</p>
<p>There are a few other “ALSA for Python” projects available, including at least
two different projects called pyAlsa. Neither of these seem to be under active
development at the time - and neither are very feature complete.</p>
<p>I wrote PyAlsaAudio to fill this gap. My long term goal is to have the module
included in the standard Python library, but that looks currently unlikely.</p>
<p>PyAlsaAudio has full support for sound capture, playback of sound, as well as
the ALSA Mixer API.</p>
<p>MIDI support is not available, and since I dont own any MIDI hardware, its
difficult for me to implement it. Volunteers to work on this would be greatly
appreciated.</p>
</section>
</section>
<section id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<p>Note: the wrappers link with the alsasound library (from the alsa-lib package)
and need the ALSA headers for compilation. Verify that you have
/usr/lib/libasound.so and /usr/include/alsa (or similar paths) before building.</p>
<p><em>On Debian (and probably Ubuntu), install libasound2-dev.</em></p>
<p>Naturally you also need to use a kernel with proper ALSA support. This is the
default in Linux kernel 2.6 and later. If you are using kernel version 2.4 you
may need to install the ALSA patches yourself - although most distributions
ship with ALSA kernels.</p>
<p>To install, execute the following: —</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py build
</pre></div>
</div>
<p>And then as root: —</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># python setup.py install</span>
</pre></div>
</div>
</section>
<section id="testing">
<h1>Testing<a class="headerlink" href="#testing" title="Permalink to this headline"></a></h1>
<p>Make sure that <code class="code docutils literal notranslate"><span class="pre">aplay</span></code> plays a file through the soundcard you want, then
try:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python playwav.py &lt;filename.wav&gt;
</pre></div>
</div>
<p>If <code class="code docutils literal notranslate"><span class="pre">aplay</span></code> needs a device argument, like
<code class="code docutils literal notranslate"><span class="pre">aplay</span> <span class="pre">-D</span> <span class="pre">hw:CARD=sndrpihifiberry,DEV=0</span></code>, use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python playwav.py -d hw:CARD=sndrpihifiberry,DEV=0 &lt;filename.wav&gt;
</pre></div>
</div>
<p>To test PCM recordings (on your default soundcard), verify your
microphone works, then do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python recordtest.py -d &lt;device&gt; &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-d &lt;device&gt; &lt;filename&gt;
</pre></div>
</div>
<p>There is a minimal test suite in <code class="code docutils literal notranslate"><span class="pre">test.py</span></code>, but it is
a bit dependent on the ALSA configuration and may fail without indicating
a real problem.</p>
<p>If you find bugs/problems, please file a <a class="reference external" href="https://github.com/larsimmisch/pyalsaaudio/issues">bug report</a>.</p>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">alsaaudio documentation</a></h1>
<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="#what-is-alsa">What is ALSA</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#alsa-and-python">ALSA and Python</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="#testing">Testing</a></li>
<li class="toctree-l1"><a class="reference internal" href="terminology.html">PCM Terminology and Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="libalsaaudio.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">alsaaudio</span></code></a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="index.html" title="previous chapter">alsaaudio documentation</a></li>
<li>Next: <a href="terminology.html" title="next chapter">PCM Terminology and Concepts</a></li>
</ul></li>
</ul>
</div>
<div 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>
</div>
<script>$('#searchbox').show(0);</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 4.5.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/pyalsaaudio.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>