forked from auracaster/pyalsaaudio
214 lines
9.9 KiB
HTML
214 lines
9.9 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Introduction — alsaaudio 0.8.4 documentation</title>
|
|
|
|
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '0.8.4',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true,
|
|
SOURCELINK_SUFFIX: '.txt'
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" 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 role="document">
|
|
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="introduction">
|
|
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Author:</th><td class="field-body">Casper Wilstrup <<a class="reference external" href="mailto:cwi%40aves.dk">cwi<span>@</span>aves<span>.</span>dk</a>></td>
|
|
</tr>
|
|
<tr class="field-even field"><th class="field-name">Author:</th><td class="field-body">Lars Immisch <<a class="reference external" href="mailto:lars%40ibp.de">lars<span>@</span>ibp<span>.</span>de</a>></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<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 first">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 don’t 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>
|
|
</div>
|
|
<div class="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>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</li>
|
|
<li>A kernel level API for manipulating the ALSA devices.</li>
|
|
<li>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.</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>
|
|
<div class="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 hass 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 don’t own any MIDI hardware, it’s
|
|
difficult for me to implement it. Volunteers to work on this would be greatly
|
|
appreciated.</p>
|
|
</div>
|
|
</div>
|
|
<div class="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"><div class="highlight"><pre>$ python setup.py build
|
|
</pre></div>
|
|
</div>
|
|
<p>And then as root: —</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span class="c"># python setup.py install</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="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"><span class="pre">aplay</span></code> plays a file through the soundcard you want, then
|
|
try:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre>$ python playwav.py <filename.wav>
|
|
</pre></div>
|
|
</div>
|
|
<p>If <code class="code docutils literal"><span class="pre">aplay</span></code> needs a device argument, like
|
|
<code class="code docutils literal"><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"><div class="highlight"><pre>$ python playwav.py -d hw:CARD=sndrpihifiberry,DEV=0 <filename.wav>
|
|
</pre></div>
|
|
</div>
|
|
<p>To test PCM recordings (on your default soundcard), verify your
|
|
microphone works, then do:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre>$ python recordtest.py -d <device> <filename>
|
|
</pre></div>
|
|
</div>
|
|
<p>Speak into the microphone, and interrupt the recording at any time
|
|
with <code class="docutils literal"><span class="pre">Ctl-C</span></code>.</p>
|
|
<p>Play back the recording with:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre>$ python playbacktest.py-d <device> <filename>
|
|
</pre></div>
|
|
</div>
|
|
<p>There is a minimal test suite in <code class="code docutils literal"><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>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h3><a href="index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">Introduction</a></li>
|
|
<li><a class="reference internal" href="#what-is-alsa">What is ALSA</a><ul>
|
|
<li><a class="reference internal" href="#alsa-and-python">ALSA and Python</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#installation">Installation</a></li>
|
|
<li><a class="reference internal" href="#testing">Testing</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 role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="_sources/pyalsaaudio.rst.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<div><input type="text" name="q" /></div>
|
|
<div><input type="submit" value="Go" /></div>
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="footer">
|
|
©2008-20017, Casper Wilstrup, Lars Immisch.
|
|
|
|
|
|
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.3</a>
|
|
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
|
|
|
|
|
|
|
<a href="_sources/pyalsaaudio.rst.txt"
|
|
rel="nofollow">Page source</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |