File: pyalsaaudio.html

package info (click to toggle)
pyalsaaudio 0.10.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,632 kB
  • sloc: javascript: 16,483; ansic: 2,559; python: 517; makefile: 79
file content (217 lines) | stat: -rw-r--r-- 10,115 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Introduction &#8212; alsaaudio documentation 0.9.0 documentation</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.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">
            
  <div class="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 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><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>
<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 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>
</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 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>
</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 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>
</div>


          </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"><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" />
      <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 3.1.2</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>