forked from auracaster/pyalsaaudio
203 lines
9.7 KiB
HTML
203 lines
9.7 KiB
HTML
<!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>Introduction — 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>
|
||
<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="Link to this heading">¶</a></h1>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Author<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p>Casper Wilstrup <<a class="reference external" href="mailto:cwi%40aves.dk">cwi<span>@</span>aves<span>.</span>dk</a>></p>
|
||
</dd>
|
||
<dt class="field-even">Author<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p>Lars Immisch <<a class="reference external" href="mailto:lars%40ibp.de">lars<span>@</span>ibp<span>.</span>de</a>></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>
|
||
<aside 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 the github 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>
|
||
</aside>
|
||
</section>
|
||
<section id="what-is-alsa">
|
||
<h1>What is ALSA<a class="headerlink" href="#what-is-alsa" title="Link to this heading">¶</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="Link to this heading">¶</a></h2>
|
||
<p>The older Linux sound API (OSS) – which is now deprecated – is well supported
|
||
by 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 don’t own any MIDI hardware, it’s
|
||
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="Link to this heading">¶</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="Link to this heading">¶</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 <filename.wav>
|
||
</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 <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 notranslate"><div class="highlight"><pre><span></span>$ 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 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 <device> <filename>
|
||
</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">
|
||
<div>
|
||
<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><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>
|
||
<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">
|
||
©2017, Lars Immisch & Casper Wilstrup.
|
||
|
||
|
|
||
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.3.7</a>
|
||
& <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> |