Import from divmod. Original log message:

r1274 | casper | 2005-03-26 00:37:10 +0100 (Sat, 26 Mar 2005) | 2 lines

Module documentation



git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@9 ec2f30ec-7544-0410-870e-f70ca00c83f0
This commit is contained in:
larsimmisch
2008-01-24 11:29:25 +00:00
parent 1c9229226c
commit 03325b1561
24 changed files with 2462 additions and 0 deletions

106
doc/about.html Normal file
View File

@@ -0,0 +1,106 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="prev" href="contents.html">
<LINK REL="parent" HREF="pyalsaaudio.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="About this document ...">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>About this document ...</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.4 ALSA Examples"
href="pcm-example.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pcm-example.html">4.4 ALSA Examples</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION003000000000000000000">
About this document ...</A>
</H1>
<strong>PyAlsaAudio</strong>
<p> This document was generated using the <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> translator.
</p>
<p> <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> is Copyright &copy;
1993, 1994, 1995, 1996, 1997, <a
href="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos
Drakos</a>, Computer Based Learning Unit, University of
Leeds, and Copyright &copy; 1997, 1998, <a
href="http://www.maths.mq.edu.au/~ross/">Ross
Moore</a>, Mathematics Department, Macquarie University,
Sydney.
</p>
<p> The application of <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> to the Python
documentation has been heavily tailored by Fred L. Drake,
Jr. Original navigation icons were contributed by Christopher
Petrilli.
</p>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.4 ALSA Examples"
rel="prev" title="4.4 ALSA Examples"
href="pcm-example.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pcm-example.html">4.4 ALSA Examples</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

BIN
doc/blank.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
doc/contents.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

99
doc/contents.html Normal file
View File

@@ -0,0 +1,99 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="about.html">
<LINK REL="prev" href="front.html">
<LINK REL="parent" HREF="pyalsaaudio.html">
<LINK REL="next" HREF="node3.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="Contents">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>Contents</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="Front Matter"
href="front.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="1 What is ALSA"
HREF="node3.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="front.html">Front Matter</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node3.html">1 What is ALSA</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<BR>
<BR><H2><A NAME="SECTION002000000000000000000">
Contents</A>
</H2>
<!--Table of Contents-->
<UL CLASS="TofC">
<LI><UL>
<LI><A href="node3.html">1 What is ALSA</a>
<LI><A href="node4.html">2 ALSA and Python</a>
<LI><A href="node5.html">3 Installation</a>
<LI><A href="module-alsaaudio.html">4 alsaaudio</a>
<UL>
<LI><A href="node7.html">4.1 PCM Terminology and Concepts</a>
<LI><A href="pcm-objects.html">4.2 PCM Objects</a>
<LI><A href="mixer-objects.html">4.3 Mixer Objects</a>
<LI><A href="pcm-example.html">4.4 ALSA Examples</a>
</ul></ul></ul>
<!--End of Table of Contents-->
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="Front Matter"
rel="prev" title="Front Matter"
href="front.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="1 What is ALSA"
rel="next" title="1 What is ALSA"
HREF="node3.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="front.html">Front Matter</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node3.html">1 What is ALSA</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

116
doc/front.html Normal file
View File

@@ -0,0 +1,116 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="contents.html">
<LINK REL="prev" HREF="pyalsaaudio.html">
<LINK REL="parent" HREF="pyalsaaudio.html">
<LINK REL="next" href="contents.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="Front Matter">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>Front Matter</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="Contents"
href="contents.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="contents.html">Contents</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION001000000000000000000">&nbsp;</A>
<BR>
Front Matter
</H1>
<P>
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>
<H3>Abstract:</H3>
<DIV CLASS="ABSTRACT">
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 my priority list, but volunteers are welcome.
<P>
If you find bugs in the wrappers please notify me on email. 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.
</DIV>
<P>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="PyAlsaAudio"
rel="prev" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="PyAlsaAudio"
rel="parent" title="PyAlsaAudio"
HREF="pyalsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="Contents"
rel="next" title="Contents"
href="contents.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" HREF="pyalsaaudio.html">PyAlsaAudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="contents.html">Contents</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

BIN
doc/index.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

103
doc/index.html Normal file
View File

@@ -0,0 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="front.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="PyAlsaAudio">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>PyAlsaAudio</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="next" title="Front Matter"
href="front.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="front.html">Front Matter</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<div class="titlepage">
<center>
<h1>PyAlsaAudio</h1>
<p><b><font size="+2">Casper Wilstrup</font></b></p>
<p>cwi@unispeed.com</p>
<p>
</center>
</div>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"></a>
<UL CLASS="ChildLinks">
<LI><A href="front.html">Front Matter</a>
<LI><A href="contents.html">Contents</a>
<UL>
<LI><A href="node3.html">1 What is ALSA</a>
<LI><A href="node4.html">2 ALSA and Python</a>
<LI><A href="node5.html">3 Installation</a>
<LI><A href="module-alsaaudio.html">4 <tt class="module">alsaaudio</tt></a>
<UL>
<LI><A href="node7.html">4.1 PCM Terminology and Concepts</a>
<LI><A href="pcm-objects.html">4.2 PCM Objects</a>
<LI><A href="mixer-objects.html">4.3 Mixer Objects</a>
<LI><A href="pcm-example.html">4.4 ALSA Examples</a>
</ul>
</ul>
<LI><A href="about.html">About this document ...</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="next" title="Front Matter"
rel="next" title="Front Matter"
href="front.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="front.html">Front Matter</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

323
doc/mixer-objects.html Normal file
View File

@@ -0,0 +1,323 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="pcm-example.html">
<LINK REL="prev" href="pcm-objects.html">
<LINK REL="parent" href="module-alsaaudio.html">
<LINK REL="next" href="pcm-example.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="Mixer Objects">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4.3 Mixer Objects</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.2 PCM Objects"
href="pcm-objects.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.4 ALSA Examples"
href="pcm-example.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pcm-objects.html">4.2 PCM Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pcm-example.html">4.4 ALSA Examples</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION002430000000000000000">&nbsp;</A>
<BR>
4.3 Mixer Objects
</H2>
<P>
Mixer objects provides access to the ALSA mixer API.
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span>&nbsp;<a name="l2h-16"><tt class="class">Mixer</tt></a></b>(</nobr></td>
<td><big>[</big><var>control</var><big>]</big><var>, </var><big>[</big><var>id</var><big>]</big><var>, </var><big>[</big><var>cardname</var><big>]</big>)</td></tr></table>
<dd>
<var>control</var> - specifies which control to manipulate using this mixer object. The list
of available controls can be found with the <tt class="module">alsaaudio</tt>.<tt class="function">mixers</tt> function.
The default value is 'Master' - other common controls include 'Master Mono', 'PCM', 'Line', etc.
<P>
<var>id</var> - the id of the mixer control. Default is 0
<P>
<var>cardname</var> - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
</dl>
<P>
Mixer objects have the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-17"><tt class="method">cardname</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return the name of the sound card used by this Mixer object
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-18"><tt class="method">mixer</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return the name of the specific mixer controlled by this object, For example 'Master'
or 'PCM'
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-19"><tt class="method">mixerid</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return the ID of the ALSA mixer controlled by this object.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-20"><tt class="method">switchcap</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Returns a list of the switches which are defined by this specific mixer. Possible values in
this list are:
<P>
<table border align="center" style="border-collapse: collapse">
<thead>
<tr class="tableheader">
<th align="left"><b>Switch</b>&nbsp;</th>
<th align="left"><b>Description</b>&nbsp;</th>
</tr>
</thead>
<tbody valign="baseline">
<tr><td align="left" valign="baseline"><Volume Capabilities>'Mute'</Volume></td>
<td align="left">This mixer can be muted</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Mute'</Volume></td>
<td align="left">This mixer can mute all channels at the same time</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Playback Mute'</Volume></td>
<td align="left">This mixer can mute the playback output</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Playback Mute'</Volume></td>
<td align="left">Mute playback for all channels at the same time</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Capture Mute'</Volume></td>
<td align="left">Mute sound capture</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Capture Mute'</Volume></td>
<td align="left">Mute sound capture for all channels at a time</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Capture Exclusive'</Volume></td>
<td align="left">Not quite sure what this is</td></tbody>
</table>
<P>
To manipulate these swithes use the <tt class="method">setrec</tt> or <tt class="method">setmute</tt> methods
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-21"><tt class="method">volumecap</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Returns a list of the volume control capabilities of this mixer. Possible values in
the list are:
<P>
<table border align="center" style="border-collapse: collapse">
<thead>
<tr class="tableheader">
<th align="left"><b>Capability</b>&nbsp;</th>
<th align="left"><b>Description</b>&nbsp;</th>
</tr>
</thead>
<tbody valign="baseline">
<tr><td align="left" valign="baseline"><Volume Capabilities>'Volume'</Volume></td>
<td align="left">This mixer can control volume</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Volume'</Volume></td>
<td align="left">This mixer can control volume for all channels at the same time</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Playback Volume'</Volume></td>
<td align="left">This mixer can manipulate the playback volume</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Playback Volume'</Volume></td>
<td align="left">Manipulate playback volumne for all channels at the same time</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Capture Volume'</Volume></td>
<td align="left">Manipulate sound capture volume</td>
<tr><td align="left" valign="baseline"><Volume Capabilities>'Joined Capture Volume'</Volume></td>
<td align="left">Manipulate sound capture volume for all channels at a time</td></tbody>
</table>
<P>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-22"><tt class="method">getvolume</tt></a></b>(</nobr></td>
<td><big>[</big><var>direction</var><big>]</big>)</td></tr></table>
<dd>
Returns a list with the current volume settings for each channel. The list elements
are integer percentages.
<P>
The optional <var>direction</var> argument can be either 'playback' or 'capture', which is relevant
if the mixer can control both playback and capture volume. The default value is 'playback'
if the mixer has this capability, otherwise 'capture'
<P>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-23"><tt class="method">getmute</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return a list indicating the current mute setting for each channel. 0 means not muted, 1 means muted.
<P>
This method will fail if the mixer has no playback switch capabilities.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-24"><tt class="method">getrec</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return a list indicating the current record mute setting for each channel. 0 means not recording, 1
means not recording.
<P>
This method will fail if the mixer has no capture switch capabilities.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-25"><tt class="method">setvolume</tt></a></b>(</nobr></td>
<td><var>volume,</var><big>[</big><var>channel</var><big>]</big><var>,</var><big>[</big><var>direction</var><big>]</big>)</td></tr></table>
<dd>
Change the current volume settings for this mixer. The <var>volume</var> argument controls
the new volume setting as an integer percentage.
<P>
If the optional argument <var>channel</var> is present, the volume is set only for this channel. This
assumes that the mixer can control the volume for the channels independently.
<P>
The optional <var>direction</var> argument can be either 'playback' or 'capture' is relevant if the mixer
has independent playback and capture volume capabilities, and controls which of the volumes
if changed. The default is 'playback' if the mixer has this capability, otherwise 'capture'.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-26"><tt class="method">setmute</tt></a></b>(</nobr></td>
<td><var>mute, </var><big>[</big><var>channel</var><big>]</big>)</td></tr></table>
<dd>
Sets the mute flag to a new value. The <var>mute</var> argument is either 0 for not muted, or 1 for muted.
<P>
The optional <var>channel</var> argument controls which channel is muted. The default is to set the mute flag
for all channels.
<P>
This method will fail if the mixer has no playback mute capabilities
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-27"><tt class="method">setrec</tt></a></b>(</nobr></td>
<td><var>capture,</var><big>[</big><var>channel</var><big>]</big>)</td></tr></table>
<dd>
Sets the capture mute flag to a new value. The <var>capture</var> argument is either 0 for no capture,
or 1 for capture.
<P>
The optional <var>channel</var> argument controls which channel is changed. The default is to set the capture flag
for all channels.
<P>
This method will fail if the mixer has no capture switch capabilities
</dl>
<P>
<b>A Note on the ALSA Mixer API</b>
<P>
The ALSA mixer API is extremely complicated - and hardly documented at all. <tt class="module">alsaaudio</tt> implements
a much simplified way to access this API. In designing the API I've 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 <tt class="module">alsaaudio</tt> API is easy to understand and use.
<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 need into future versions.
<P>
If the current state of affairs annoy 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>
Unfortunately, I'm 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>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.2 PCM Objects"
rel="prev" title="4.2 PCM Objects"
href="pcm-objects.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.4 ALSA Examples"
rel="next" title="4.4 ALSA Examples"
href="pcm-example.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="pcm-objects.html">4.2 PCM Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pcm-example.html">4.4 ALSA Examples</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

162
doc/module-alsaaudio.html Normal file
View File

@@ -0,0 +1,162 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="prev" HREF="node5.html">
<LINK REL="parent" href="contents.html">
<LINK REL="next" HREF="node7.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="alsaaudio">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4 alsaaudio</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="3 Installation"
HREF="node5.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.1 PCM Terminology and"
HREF="node7.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node5.html">3 Installation</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node7.html">4.1 PCM Terminology and</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION002400000000000000000">
4 <tt class="module">alsaaudio</tt></A>
</H1>
<P>
<P>
<p class="availability">Availability: <span
class="platform">Linux</span>.</p>
<P>
<P>
<P>
The <tt class="module">alsaaudio</tt> module defines functions and classes for using
ALSA.
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-2"><tt class="function">mixers</tt></a></b>(</nobr></td>
<td><big>[</big><var>cardname</var><big>]</big>)</td></tr></table>
<dd>
List the available mixers. The optional <var>cardname</var> specifies which
card should be queried (this is only relevant if you have more than one
sound card). Omit to use the default sound card
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span>&nbsp;<a name="l2h-3"><tt class="class">PCM</tt></a></b>(</nobr></td>
<td><big>[</big><var>type</var><big>]</big><var>, </var><big>[</big><var>mode</var><big>]</big><var>, </var><big>[</big><var>cardname</var><big>]</big>)</td></tr></table>
<dd>
This class is used to represent a PCM device (both playback and capture devices).
The arguments are:
<BR><var>type</var> - can be either PCM_CAPTURE or PCM_PLAYBACK (default).
<BR><var>mode</var> - can be either PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL (the default).
<BR><var>cardname</var> - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span>&nbsp;<a name="l2h-4"><tt class="class">Mixer</tt></a></b>(</nobr></td>
<td><big>[</big><var>control</var><big>]</big><var>, </var><big>[</big><var>id</var><big>]</big><var>, </var><big>[</big><var>cardname</var><big>]</big>)</td></tr></table>
<dd>
This class is used to access a specific ALSA mixer.
The arguments are:
<BR><var>control</var> - Name of the chosen mixed (default is Master).
<BR><var>id</var> - id of mixer (default is 0) - More explaniation needed here
<BR><var>cardname</var> specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
</dl>
<P>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<a name="l2h-5"><tt class="exception">ALSAAudioError</tt></a></b>
<dd>
Exception raised when an operation fails for a ALSA specific reason.
The exception argument is a string describing the reason of the
failure.
</dl>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL CLASS="ChildLinks">
<LI><A href="node7.html">4.1 PCM Terminology and Concepts</a>
<LI><A href="pcm-objects.html">4.2 PCM Objects</a>
<LI><A href="mixer-objects.html">4.3 Mixer Objects</a>
<LI><A href="pcm-example.html">4.4 ALSA Examples</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="3 Installation"
rel="prev" title="3 Installation"
HREF="node5.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.1 PCM Terminology and"
rel="next" title="4.1 PCM Terminology and"
HREF="node7.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node5.html">3 Installation</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node7.html">4.1 PCM Terminology and</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

BIN
doc/modules.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

BIN
doc/next.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

117
doc/node3.html Normal file
View File

@@ -0,0 +1,117 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" HREF="node4.html">
<LINK REL="prev" href="contents.html">
<LINK REL="parent" href="contents.html">
<LINK REL="next" HREF="node4.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="What is ALSA">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>1 What is ALSA</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="Contents"
href="contents.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="2 ALSA and Python"
HREF="node4.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="contents.html">Contents</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node4.html">2 ALSA and Python</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION002100000000000000000">
1 What is ALSA</A>
</H1>
<P>
The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI
functionality to the Linux operating system.
<P>
Logically ALSA consists of these components:
<UL>
<LI>A set of kernel drivers.
<BR>
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 <i>libasound</i>
and is required by all ALSA capable applications.
</LI>
</UL>
<P>
More information about ALSA may be found on the project homepage
<a class="url" href="http://www.alsa-project.org">http://www.alsa-project.org</a>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="Contents"
rel="prev" title="Contents"
href="contents.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="2 ALSA and Python"
rel="next" title="2 ALSA and Python"
HREF="node4.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="contents.html">Contents</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node4.html">2 ALSA and Python</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

113
doc/node4.html Normal file
View File

@@ -0,0 +1,113 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" HREF="node5.html">
<LINK REL="prev" HREF="node3.html">
<LINK REL="parent" href="contents.html">
<LINK REL="next" HREF="node5.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="ALSA and Python">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>2 ALSA and Python</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="1 What is ALSA"
HREF="node3.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="3 Installation"
HREF="node5.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node3.html">1 What is ALSA</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node5.html">3 Installation</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION002200000000000000000">
2 ALSA and Python</A>
</H1>
<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 (yet).
<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>
I wrote PyAlsaAudio to fill this gap. My long term goal is to have the module
included in the standard Python library, but that is probably a while of yet.
<P>
PyAlsaAudio hass full support for sound capture, playback of sound, as well as
the ALSA Mixer API.
<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
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="1 What is ALSA"
rel="prev" title="1 What is ALSA"
HREF="node3.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="3 Installation"
rel="next" title="3 Installation"
HREF="node5.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node3.html">1 What is ALSA</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" HREF="node5.html">3 Installation</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

112
doc/node5.html Normal file
View File

@@ -0,0 +1,112 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="module-alsaaudio.html">
<LINK REL="prev" HREF="node4.html">
<LINK REL="parent" href="contents.html">
<LINK REL="next" href="module-alsaaudio.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="Installation">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>3 Installation</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="2 ALSA and Python"
HREF="node4.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node4.html">2 ALSA and Python</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-alsaaudio.html">4 alsaaudio</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION002300000000000000000">
3 Installation</A>
</H1>
<P>
Note: the wrappers link with the alsasound library (from the alsa-lib
package). Verify that this is installed by looking for /usr/lib/libasound.so
before building. 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>
To install, execute the following:
<BR><div class="verbatim"><pre>
$ python setup.py build
</pre></div>
<P>
And then as root:
<BR><div class="verbatim"><pre>
# python setup.py install
</pre></div>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="2 ALSA and Python"
rel="prev" title="2 ALSA and Python"
HREF="node4.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="Contents"
rel="parent" title="Contents"
href="contents.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4 alsaaudio"
rel="next" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node4.html">2 ALSA and Python</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="contents.html">Contents</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-alsaaudio.html">4 alsaaudio</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

166
doc/node7.html Normal file
View File

@@ -0,0 +1,166 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="pcm-objects.html">
<LINK REL="prev" href="module-alsaaudio.html">
<LINK REL="parent" href="module-alsaaudio.html">
<LINK REL="next" href="pcm-objects.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="PCM Terminology and Concepts">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4.1 PCM Terminology and Concepts</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.2 PCM Objects"
href="pcm-objects.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pcm-objects.html">4.2 PCM Objects</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION002410000000000000000">
4.1 PCM Terminology and Concepts</A>
</H2>
<P>
In order to use PCM devices it is useful to be familiar with some concepts and
terminology.
<P>
<DL>
<DT><STRONG>Sample</STRONG></DT>
<DD>PCM audio, whether it is input or output, consists at the lowest level
of a number of single samples. A sample represents the sound in a single channel in
a brief interval. If more than one channel is in use, more than one sample is required
for each interval to describe the sound. Samples can be of many different sizes, ranging
from 8 bit to 64 bit presition. The specific format of each sample can also vary - they
can be big endian byte order, little endian byte order, or even floats.
<P>
</DD>
<DT><STRONG>Frame</STRONG></DT>
<DD>A frame consists of exactly one sample per channel. If there is only one
channel (Mono sound) a frame is simply a single sample. If the sound is stereo, each frame
consists of two samples, etc.
<P>
</DD>
<DT><STRONG>Frame size</STRONG></DT>
<DD>This is the size in bytes of each frame. This can vary a lot: if each sample is
8 bits, and we're handling mono sound, the frame size is one byte. Similarly in 6 channel audio with
64 bit floating point samples, the frame size is 48 bytes
<P>
</DD>
<DT><STRONG>Rate</STRONG></DT>
<DD>PCM sound consists of a flow of sound frames. The sound rate controls how often
the current frame is replaced. For example, a rate of 8000 Hz means that a new frame is played
or captured 8000 times per second.
<P>
</DD>
<DT><STRONG>Data rate</STRONG></DT>
<DD>This is the number of bytes, which must be recorded or provided per second
at a certain frame size and rate.
<P>
8000 Hz mono sound with 8 bit (1 byte) samples has a data rate of 8000 * 1 * 1 = 8 kb/s
<P>
At the other end of the scale, 96000 Hz, 6 channel sound with 64 bit (8 bytes) samples
has a data rate of 96000 * 6 * 8 = 4608 kb/s (almost 5 Mb sound data per second)
<P>
</DD>
<DT><STRONG>Period</STRONG></DT>
<DD>When the hardware processes data this is done in chunks of frames. The time interval
between each processing (A/D or D/A conversion) is known as the period. The size of the period has
direct implication on the latency of the sound input or output. For low-latency the period size should
be very small, while low CPU resource usage would usually demand larger period sizes. With ALSA, the
CPU utilization is not impacted much by the period size, since the kernel layer buffers multiple
periods internally, so each period generates an interrupt and a memory copy, but userspace can be
slower and read or write multiple periods at the same time.
<P>
</DD>
<DT><STRONG>Period size</STRONG></DT>
<DD>This is the size of each period in Hz. <i>Not bytes, but Hz!.</i> In <tt class="module">alsaaudio</tt>
the period size is set directly, and it is therefore important to understand the significance of this
number. If the period size is configured to for example 32, each write should contain exactly 32 frames
of sound data, and each read will return either 32 frames of data or nothing at all.
<P>
</DD>
</DL>
<P>
Once you understand these concepts, you will be ready to actually utilize PCM API. Read on.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4 alsaaudio"
rel="prev" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.2 PCM Objects"
rel="next" title="4.2 PCM Objects"
href="pcm-objects.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pcm-objects.html">4.2 PCM Objects</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

96
doc/pcm-example.html Normal file
View File

@@ -0,0 +1,96 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="prev" href="mixer-objects.html">
<LINK REL="parent" href="module-alsaaudio.html">
<LINK REL="next" href="about.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="ALSA Examples ">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4.4 ALSA Examples </title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="About this document ..."
href="about.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mixer-objects.html">4.3 Mixer Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="about.html">About this document ...</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION002440000000000000000">&nbsp;</A>
<BR>
4.4 ALSA Examples
</H2>
<P>
For now, the only examples available are the 'playbacktest.py' and the 'recordtest.py' programs included.
This will change in a future version.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.3 Mixer Objects"
rel="prev" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="About this document ..."
rel="next" title="About this document ..."
href="about.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mixer-objects.html">4.3 Mixer Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="about.html">About this document ...</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

327
doc/pcm-objects.html Normal file
View File

@@ -0,0 +1,327 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="mixer-objects.html">
<LINK REL="prev" HREF="node7.html">
<LINK REL="parent" href="module-alsaaudio.html">
<LINK REL="next" href="mixer-objects.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="PCM Objects">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>4.2 PCM Objects</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.1 PCM Terminology and"
HREF="node7.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node7.html">4.1 PCM Terminology and</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mixer-objects.html">4.3 Mixer Objects</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION002420000000000000000">&nbsp;</A>
<BR>
4.2 PCM Objects
</H2>
<P>
The acronym PCM is short for Pulse Code Modulation and is the method used in ALSA
and many other places to handle playback and capture of sampled sound data.
<P>
PCM objects in <tt class="module">alsaaudio</tt> are used to do exactly that, either play sample based
sound or capture sound from some input source (perhaps a microphone). The PCM object
constructor takes the following arguments:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span>&nbsp;<a name="l2h-6"><tt class="class">PCM</tt></a></b>(</nobr></td>
<td><big>[</big><var>type</var><big>]</big><var>, </var><big>[</big><var>mode</var><big>]</big><var>, </var><big>[</big><var>cardname</var><big>]</big>)</td></tr></table>
<dd>
<P>
<var>type</var> - can be either PCM_CAPTURE or PCM_PLAYBACK (default).
<P>
<var>mode</var> - can be either PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL (the default).
In PCM_NONBLOCK mode, calls to read will return immediately independent of wether
there is any actual data to read. Similarly, write calls will return immediately
without actually writing anything to the playout buffer if the buffer is full.
<P>
In the current version of <tt class="module">alsaaudio</tt> PCM_ASYNC is useless, since it relies
on a callback procedure, which can't be specified from Python.
<P>
<var>cardname</var> - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
<P>
This will construct a PCM object with default settings:
<P>
Sample format: PCM_FORMAT_S16_LE
<BR>
Rate: 8000 Hz
<BR>
Channels: 2
<BR>
Period size: 32 frames
<BR></dl>
<P>
PCM objects have the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-7"><tt class="method">pcmtype</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Returns the type of PCM object. Either PCM_CAPTURE or PCM_PLAYBACK.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-8"><tt class="method">pcmmode</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return the mode of the PCM object. One of PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-9"><tt class="method">cardname</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
Return the name of the sound card used by this PCM object.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-10"><tt class="method">setchannels</tt></a></b>(</nobr></td>
<td><var>nchannels</var>)</td></tr></table>
<dd>
Used to set the number of capture or playback channels. Common values are: 1 = mono, 2 = stereo,
and 6 = full 6 channel audio. Few sound cards support more than 2 channels
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-11"><tt class="method">setrate</tt></a></b>(</nobr></td>
<td><var>rate</var>)</td></tr></table>
<dd>
Set the sample rate in Hz for the device. Typical values are 8000 (poor sound), 16000, 44100 (cd quality),
and 96000
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-12"><tt class="method">setformat</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
The sound format of the device. Sound format controls how the PCM device interpret data for playback,
and how data is encoded in captures.
<P>
The following formats are provided by ALSA:
<table border align="center" style="border-collapse: collapse">
<thead>
<tr class="tableheader">
<th align="left"><b>Format</b>&nbsp;</th>
<th align="left"><b>Description</b>&nbsp;</th>
</tr>
</thead>
<tbody valign="baseline">
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S8</Formats></td>
<td align="left">Signed 8 bit samples for each channel</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U8</Formats></td>
<td align="left">Signed 8 bit samples for each channel</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S16_LE</Formats></td>
<td align="left">Signed 16 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S16_BE</Formats></td>
<td align="left">Signed 16 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U16_LE</Formats></td>
<td align="left">Unsigned 16 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U16_BE</Formats></td>
<td align="left">Unsigned 16 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S24_LE</Formats></td>
<td align="left">Signed 24 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S24_BE</Formats></td>
<td align="left">Signed 24 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U24_LE</Formats></td>
<td align="left">Unsigned 24 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U24_BE</Formats></td>
<td align="left">Unsigned 24 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S32_LE</Formats></td>
<td align="left">Signed 32 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_S32_BE</Formats></td>
<td align="left">Signed 32 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U32_LE</Formats></td>
<td align="left">Unsigned 32 bit samples for each channel (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_U32_BE</Formats></td>
<td align="left">Unsigned 32 bit samples for each channel (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT_LE</Formats></td>
<td align="left">32 bit samples encoded as float. (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT_BE</Formats></td>
<td align="left">32 bit samples encoded as float (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT64_LE</Formats></td>
<td align="left">64 bit samples encoded as float. (Little Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT64_BE</Formats></td>
<td align="left">64 bit samples encoded as float. (Big Endian byte order)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_MU_LAW</Formats></td>
<td align="left">A logarithmic encoding (used by Sun .au files)</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_A_LAW</Formats></td>
<td align="left">Another logarithmic encoding</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_IMA_ADPCM</Formats></td>
<td align="left">a 4:1 compressed format defined by the Interactive Multimedia Association</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_MPEG</Formats></td>
<td align="left">MPEG encoded audio?</td>
<tr><td align="left" valign="baseline"><Formats>PCM_FORMAT_GSM</Formats></td>
<td align="left">9600 constant rate encoding well suitet for speech</td></tbody>
</table>
<P>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-13"><tt class="method">setperiodsize</tt></a></b>(</nobr></td>
<td><var>period</var>)</td></tr></table>
<dd>
Sets the actual period size in frames. Each write should consist of exactly this number of frames, and
each read will return this number of frames (unless the device is in PCM_NONBLOCK mode, in which case
it may return nothing at all)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-14"><tt class="method">read</tt></a></b>(</nobr></td>
<td>)</td></tr></table>
<dd>
In PCM_NORMAL mode, this function blocks until a full period is available, and then returns a
tuple (length,data) where <i>length</i> is the size in bytes of the captured data, and <i>data</i>
is the captured sound frames as a string. The length of the returned data will be periodsize*framesize
bytes.
<P>
In PCM_NONBLOCK mode, the call will not block, but will return <code>(0,'')</code> if no new period
has become available since the last call to read.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><a name="l2h-15"><tt class="method">write</tt></a></b>(</nobr></td>
<td><var>data</var>)</td></tr></table>
<dd>
Writes (plays) the sound in data. The length of data <i>must</i> be a multiple of the frame size, and
<i>should</i> 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>
If the device is not in PCM_NONBLOCK 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. The call always returns
the size of the data provided
<P>
In PCM_NONBLOCK 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 at a later time.
<P>
</dl>
<P>
<b>A few hints on using PCM devices for playback</b>
<P>
The most common reason for problems with playback of PCM audio, is that the people don't properly understand
that writes to PCM devices must match <i>exactly</i> the data rate of the device.
<P>
If too little data is written to the device will an underrun, and ugly clicking sounds will occur. Conversely,
of too much data is written to the device, the write function will either block (PCM_NORMAL mode) or return zero
(PCM_NONBLOCK mode).
<P>
If your program does nothing, but play sound, the easiest way is to put the device in PCM_NORMAL 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>
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
doesn't expire exactly on time.
<P>
Also note, that most timer API's that you can find for Python will cummulate time delays: If you set the timer
to expire after 1/10'th 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>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><a rel="prev" title="4.1 PCM Terminology and"
rel="prev" title="4.1 PCM Terminology and"
HREF="node7.html"><img src='previous.gif'
border='0' height='32' alt='Previous Page' width='32'></A></td>
<td><a rel="parent" title="4 alsaaudio"
rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.gif'
border='0' height='32' alt='Up One Level' width='32'></A></td>
<td><a rel="next" title="4.3 Mixer Objects"
rel="next" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node7.html">4.1 PCM Terminology and</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mixer-objects.html">4.3 Mixer Objects</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

BIN
doc/previous.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

103
doc/pyalsaaudio.html Normal file
View File

@@ -0,0 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css'>
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio'>
<link rel='contents' href='contents.html' title="Contents">
<link rel='last' href='about.html' title='About this document...'>
<link rel='help' href='about.html' title='About this document...'>
<LINK REL="next" href="front.html">
<meta name='aesop' content='information'>
<META NAME="description" CONTENT="PyAlsaAudio">
<META NAME="keywords" CONTENT="pyalsaaudio">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<title>PyAlsaAudio</title>
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="next" title="Front Matter"
href="front.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="front.html">Front Matter</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<div class="titlepage">
<center>
<h1>PyAlsaAudio</h1>
<p><b><font size="+2">Casper Wilstrup</font></b></p>
<p>cwi@unispeed.com</p>
<p>
</center>
</div>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"></a>
<UL CLASS="ChildLinks">
<LI><A href="front.html">Front Matter</a>
<LI><A href="contents.html">Contents</a>
<UL>
<LI><A href="node3.html">1 What is ALSA</a>
<LI><A href="node4.html">2 ALSA and Python</a>
<LI><A href="node5.html">3 Installation</a>
<LI><A href="module-alsaaudio.html">4 <tt class="module">alsaaudio</tt></a>
<UL>
<LI><A href="node7.html">4.1 PCM Terminology and Concepts</a>
<LI><A href="pcm-objects.html">4.2 PCM Objects</a>
<LI><A href="mixer-objects.html">4.3 Mixer Objects</a>
<LI><A href="pcm-example.html">4.4 ALSA Examples</a>
</ul>
</ul>
<LI><A href="about.html">About this document ...</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
<td><a rel="next" title="Front Matter"
rel="next" title="Front Matter"
href="front.html"><img src='next.gif'
border='0' height='32' alt='Next Page' width='32'></A></td>
<td align="center" width="100%">PyAlsaAudio</td>
<td><a rel="contents" title="Table of Contents"
rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.gif'
border='0' height='32' alt='Contents' width='32'></A></td>
<td><img src='blank.gif'
border='0' height='32' alt='' width='32'></td>
</tr></table>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="front.html">Front Matter</A>
<hr>
<span class="release-info">Release 0.1.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>

BIN
doc/pyfav.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

15
doc/src/Makefile Normal file
View File

@@ -0,0 +1,15 @@
# Makefile for PyAlsaAudio documentation
#
# In order to use this you need an unpacked version of the
# Python source available. Set the source path below
#
# You also need a working latex installation, and the latex2html
# tool installed.
PYTHONSOURCE = /usr/src/Python-2.3.4/
# Shouldn't need to change anything below here!
MKHOWTO = $(PYTHONSOURCE)/Doc/tools/mkhowto
all:
$(MKHOWTO) --dir .. --html pyalsaaudio.tex

397
doc/src/libalsaaudio.tex Normal file
View File

@@ -0,0 +1,397 @@
\section{\module{alsaaudio}}
%\declaremodule{builtin}{alsaaudio} % standard library, in C
\declaremodule{extension}{alsaaudio} % not standard, in C
\platform{Linux}
\moduleauthor{Casper Wilstrup}{cwi@unispeed.com} % Author of the module code;
\modulesynopsis{ALSA sound support}
The \module{alsaaudio} module defines functions and classes for using
ALSA.
% ---- 3.1. ----
% For each function, use a ``funcdesc'' block. This has exactly two
% parameters (each parameters is contained in a set of curly braces):
% the first parameter is the function name (this automatically
% generates an index entry); the second parameter is the function's
% argument list. If there are no arguments, use an empty pair of
% curly braces. If there is more than one argument, separate the
% arguments with backslash-comma. Optional parts of the parameter
% list are contained in \optional{...} (this generates a set of square
% brackets around its parameter). Arguments are automatically set in
% italics in the parameter list. Each argument should be mentioned at
% least once in the description; each usage (even inside \code{...})
% should be enclosed in \var{...}.
\begin{funcdesc}{mixers}{\optional{cardname}}
List the available mixers. The optional \var{cardname} specifies which
card should be queried (this is only relevant if you have more than one
sound card). Omit to use the default sound card
\end{funcdesc}
\begin{classdesc}{PCM}{\optional{type}, \optional{mode}, \optional{cardname}}
This class is used to represent a PCM device (both playback and capture devices).
The arguments are: \\
\var{type} - can be either PCM_CAPTURE or PCM_PLAYBACK (default). \\
\var{mode} - can be either PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL (the default).\\
\var{cardname} - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
\end{classdesc}
\begin{classdesc}{Mixer}{\optional{control}, \optional{id}, \optional{cardname}}
This class is used to access a specific ALSA mixer.
The arguments are: \\
\var{control} - Name of the chosen mixed (default is Master). \\
\var{id} - id of mixer (default is 0) -- More explaniation needed here\\
\var{cardname} specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
\end{classdesc}
\begin{excdesc}{ALSAAudioError}
Exception raised when an operation fails for a ALSA specific reason.
The exception argument is a string describing the reason of the
failure.
\end{excdesc}
\subsection{PCM Terminology and Concepts}
In order to use PCM devices it is useful to be familiar with some concepts and
terminology.
\begin{description}
\item[Sample] PCM audio, whether it is input or output, consists at the lowest level
of a number of single samples. A sample represents the sound in a single channel in
a brief interval. If more than one channel is in use, more than one sample is required
for each interval to describe the sound. Samples can be of many different sizes, ranging
from 8 bit to 64 bit presition. The specific format of each sample can also vary - they
can be big endian byte order, little endian byte order, or even floats.
\item[Frame] A frame consists of exactly one sample per channel. If there is only one
channel (Mono sound) a frame is simply a single sample. If the sound is stereo, each frame
consists of two samples, etc.
\item[Frame size] This is the size in bytes of each frame. This can vary a lot: if each sample is
8 bits, and we're handling mono sound, the frame size is one byte. Similarly in 6 channel audio with
64 bit floating point samples, the frame size is 48 bytes
\item[Rate] PCM sound consists of a flow of sound frames. The sound rate controls how often
the current frame is replaced. For example, a rate of 8000 Hz means that a new frame is played
or captured 8000 times per second.
\item[Data rate] This is the number of bytes, which must be recorded or provided per second
at a certain frame size and rate.
8000 Hz mono sound with 8 bit (1 byte) samples has a data rate of 8000 * 1 * 1 = 8 kb/s
At the other end of the scale, 96000 Hz, 6 channel sound with 64 bit (8 bytes) samples
has a data rate of 96000 * 6 * 8 = 4608 kb/s (almost 5 Mb sound data per second)
\item[Period] When the hardware processes data this is done in chunks of frames. The time interval
between each processing (A/D or D/A conversion) is known as the period. The size of the period has
direct implication on the latency of the sound input or output. For low-latency the period size should
be very small, while low CPU resource usage would usually demand larger period sizes. With ALSA, the
CPU utilization is not impacted much by the period size, since the kernel layer buffers multiple
periods internally, so each period generates an interrupt and a memory copy, but userspace can be
slower and read or write multiple periods at the same time.
\item[Period size] This is the size of each period in Hz. \emph{Not bytes, but Hz!.} In \module{alsaaudio}
the period size is set directly, and it is therefore important to understand the significance of this
number. If the period size is configured to for example 32, each write should contain exactly 32 frames
of sound data, and each read will return either 32 frames of data or nothing at all.
\end{description}
Once you understand these concepts, you will be ready to actually utilize PCM API. Read on.
\subsection{PCM Objects}
\label{pcm-objects}
The acronym PCM is short for Pulse Code Modulation and is the method used in ALSA
and many other places to handle playback and capture of sampled sound data.
PCM objects in \module{alsaaudio} are used to do exactly that, either play sample based
sound or capture sound from some input source (perhaps a microphone). The PCM object
constructor takes the following arguments:
\begin{classdesc}{PCM}{\optional{type}, \optional{mode}, \optional{cardname}}
\var{type} - can be either PCM_CAPTURE or PCM_PLAYBACK (default).
\var{mode} - can be either PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL (the default).
In PCM_NONBLOCK mode, calls to read will return immediately independent of wether
there is any actual data to read. Similarly, write calls will return immediately
without actually writing anything to the playout buffer if the buffer is full.
In the current version of \module{alsaaudio} PCM_ASYNC is useless, since it relies
on a callback procedure, which can't be specified from Python.
\var{cardname} - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
This will construct a PCM object with default settings:
Sample format: PCM_FORMAT_S16_LE \\
Rate: 8000 Hz \\
Channels: 2 \\
Period size: 32 frames \\
\end{classdesc}
PCM objects have the following methods:
\begin{methoddesc}[PCM]{pcmtype}{}
Returns the type of PCM object. Either PCM_CAPTURE or PCM_PLAYBACK.
\end{methoddesc}
\begin{methoddesc}[PCM]{pcmmode}{}
Return the mode of the PCM object. One of PCM_NONBLOCK, PCM_ASYNC, or PCM_NORMAL
\end{methoddesc}
\begin{methoddesc}[PCM]{cardname}{}
Return the name of the sound card used by this PCM object.
\end{methoddesc}
\begin{methoddesc}[PCM]{setchannels}{nchannels}
Used to set the number of capture or playback channels. Common values are: 1 = mono, 2 = stereo,
and 6 = full 6 channel audio. Few sound cards support more than 2 channels
\end{methoddesc}
\begin{methoddesc}[PCM]{setrate}{rate}
Set the sample rate in Hz for the device. Typical values are 8000 (poor sound), 16000, 44100 (cd quality),
and 96000
\end{methoddesc}
\begin{methoddesc}[PCM]{setformat}{}
The sound format of the device. Sound format controls how the PCM device interpret data for playback,
and how data is encoded in captures.
The following formats are provided by ALSA:
\begin{tableii}{l|l}{Formats}{Format}{Description}
\lineii{PCM_FORMAT_S8}{Signed 8 bit samples for each channel}
\lineii{PCM_FORMAT_U8}{Signed 8 bit samples for each channel}
\lineii{PCM_FORMAT_S16_LE}{Signed 16 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_S16_BE}{Signed 16 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_U16_LE}{Unsigned 16 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_U16_BE}{Unsigned 16 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_S24_LE}{Signed 24 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_S24_BE}{Signed 24 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_U24_LE}{Unsigned 24 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_U24_BE}{Unsigned 24 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_S32_LE}{Signed 32 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_S32_BE}{Signed 32 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_U32_LE}{Unsigned 32 bit samples for each channel (Little Endian byte order)}
\lineii{PCM_FORMAT_U32_BE}{Unsigned 32 bit samples for each channel (Big Endian byte order)}
\lineii{PCM_FORMAT_FLOAT_LE}{32 bit samples encoded as float. (Little Endian byte order)}
\lineii{PCM_FORMAT_FLOAT_BE}{32 bit samples encoded as float (Big Endian byte order)}
\lineii{PCM_FORMAT_FLOAT64_LE}{64 bit samples encoded as float. (Little Endian byte order)}
\lineii{PCM_FORMAT_FLOAT64_BE}{64 bit samples encoded as float. (Big Endian byte order)}
\lineii{PCM_FORMAT_MU_LAW}{A logarithmic encoding (used by Sun .au files)}
\lineii{PCM_FORMAT_A_LAW}{Another logarithmic encoding}
\lineii{PCM_FORMAT_IMA_ADPCM}{a 4:1 compressed format defined by the Interactive Multimedia Association}
\lineii{PCM_FORMAT_MPEG}{MPEG encoded audio?}
\lineii{PCM_FORMAT_GSM}{9600 constant rate encoding well suitet for speech}
\end{tableii}
\end{methoddesc}
\begin{methoddesc}[PCM]{setperiodsize}{period}
Sets the actual period size in frames. Each write should consist of exactly this number of frames, and
each read will return this number of frames (unless the device is in PCM_NONBLOCK mode, in which case
it may return nothing at all)
\end{methoddesc}
\begin{methoddesc}[PCM]{read}{}
In PCM_NORMAL mode, this function blocks until a full period is available, and then returns a
tuple (length,data) where \emph{length} is the size in bytes of the captured data, and \emph{data}
is the captured sound frames as a string. The length of the returned data will be periodsize*framesize
bytes.
In PCM_NONBLOCK mode, the call will not block, but will return \code{(0,'')} if no new period
has become available since the last call to read.
\end{methoddesc}
\begin{methoddesc}[PCM]{write}{data}
Writes (plays) the sound in data. The length of data \emph{must} be a multiple of the frame size, and
\emph{should} 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.
If the device is not in PCM_NONBLOCK 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. The call always returns
the size of the data provided
In PCM_NONBLOCK 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 at a later time.
\end{methoddesc}
\strong{A few hints on using PCM devices for playback}
The most common reason for problems with playback of PCM audio, is that the people don't properly understand
that writes to PCM devices must match \emph{exactly} the data rate of the device.
If too little data is written to the device will an underrun, and ugly clicking sounds will occur. Conversely,
of too much data is written to the device, the write function will either block (PCM_NORMAL mode) or return zero
(PCM_NONBLOCK mode).
If your program does nothing, but play sound, the easiest way is to put the device in PCM_NORMAL 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.
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
doesn't expire exactly on time.
Also note, that most timer API's that you can find for Python will cummulate time delays: If you set the timer
to expire after 1/10'th 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.
\subsection{Mixer Objects}
\label{mixer-objects}
Mixer objects provides access to the ALSA mixer API.
\begin{classdesc}{Mixer}{\optional{control}, \optional{id}, \optional{cardname}}
\var{control} - specifies which control to manipulate using this mixer object. The list
of available controls can be found with the \module{alsaaudio}.\function{mixers} function.
The default value is 'Master' - other common controls include 'Master Mono', 'PCM', 'Line', etc.
\var{id} - the id of the mixer control. Default is 0
\var{cardname} - specifies which card should be used (this is only relevant
if you have more than one sound card). Omit to use the default sound card
\end{classdesc}
Mixer objects have the following methods:
\begin{methoddesc}[Mixer]{cardname}{}
Return the name of the sound card used by this Mixer object
\end{methoddesc}
\begin{methoddesc}[Mixer]{mixer}{}
Return the name of the specific mixer controlled by this object, For example 'Master'
or 'PCM'
\end{methoddesc}
\begin{methoddesc}[Mixer]{mixerid}{}
Return the ID of the ALSA mixer controlled by this object.
\end{methoddesc}
\begin{methoddesc}[Mixer]{switchcap}{}
Returns a list of the switches which are defined by this specific mixer. Possible values in
this list are:
\begin{tableii}{l|l}{Switches}{Switch}{Description}
\lineii{'Mute'}{This mixer can be muted}
\lineii{'Joined Mute'}{This mixer can mute all channels at the same time}
\lineii{'Playback Mute'}{This mixer can mute the playback output}
\lineii{'Joined Playback Mute'}{Mute playback for all channels at the same time}
\lineii{'Capture Mute'}{Mute sound capture}
\lineii{'Joined Capture Mute'}{Mute sound capture for all channels at a time}
\lineii{'Capture Exclusive'}{Not quite sure what this is}
\end{tableii}
To manipulate these swithes use the \method{setrec} or \method{setmute} methods
\end{methoddesc}
\begin{methoddesc}[Mixer]{volumecap}{}
Returns a list of the volume control capabilities of this mixer. Possible values in
the list are:
\begin{tableii}{l|l}{Volume Capabilities}{Capability}{Description}
\lineii{'Volume'}{This mixer can control volume}
\lineii{'Joined Volume'}{This mixer can control volume for all channels at the same time}
\lineii{'Playback Volume'}{This mixer can manipulate the playback volume}
\lineii{'Joined Playback Volume'}{Manipulate playback volumne for all channels at the same time}
\lineii{'Capture Volume'}{Manipulate sound capture volume}
\lineii{'Joined Capture Volume'}{Manipulate sound capture volume for all channels at a time}
\end{tableii}
\end{methoddesc}
\begin{methoddesc}[Mixer]{getvolume}{\optional{direction}}
Returns a list with the current volume settings for each channel. The list elements
are integer percentages.
The optional \var{direction} argument can be either 'playback' or 'capture', which is relevant
if the mixer can control both playback and capture volume. The default value is 'playback'
if the mixer has this capability, otherwise 'capture'
\end{methoddesc}
\begin{methoddesc}[Mixer]{getmute}{}
Return a list indicating the current mute setting for each channel. 0 means not muted, 1 means muted.
This method will fail if the mixer has no playback switch capabilities.
\end{methoddesc}
\begin{methoddesc}[Mixer]{getrec}{}
Return a list indicating the current record mute setting for each channel. 0 means not recording, 1
means not recording.
This method will fail if the mixer has no capture switch capabilities.
\end{methoddesc}
\begin{methoddesc}[Mixer]{setvolume}{volume,\optional{channel},\optional{direction}}
Change the current volume settings for this mixer. The \var{volume} argument controls
the new volume setting as an integer percentage.
If the optional argument \var{channel} is present, the volume is set only for this channel. This
assumes that the mixer can control the volume for the channels independently.
The optional \var{direction} argument can be either 'playback' or 'capture' is relevant if the mixer
has independent playback and capture volume capabilities, and controls which of the volumes
if changed. The default is 'playback' if the mixer has this capability, otherwise 'capture'.
\end{methoddesc}
\begin{methoddesc}[Mixer]{setmute}{mute, \optional{channel}}
Sets the mute flag to a new value. The \var{mute} argument is either 0 for not muted, or 1 for muted.
The optional \var{channel} argument controls which channel is muted. The default is to set the mute flag
for all channels.
This method will fail if the mixer has no playback mute capabilities
\end{methoddesc}
\begin{methoddesc}[Mixer]{setrec}{capture,\optional{channel}}
Sets the capture mute flag to a new value. The \var{capture} argument is either 0 for no capture,
or 1 for capture.
The optional \var{channel} argument controls which channel is changed. The default is to set the capture flag
for all channels.
This method will fail if the mixer has no capture switch capabilities
\end{methoddesc}
\textbf{A Note on the ALSA Mixer API}
The ALSA mixer API is extremely complicated - and hardly documented at all. \module{alsaaudio} implements
a much simplified way to access this API. In designing the API I've 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 \module{alsaaudio} API is easy to understand and use.
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 need into future versions.
If the current state of affairs annoy 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.
Unfortunately, I'm 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.
% ==== 4. ====
\subsection{ALSA Examples \label{pcm-example}}
For now, the only examples available are the 'playbacktest.py' and the 'recordtest.py' programs included.
This will change in a future version.

107
doc/src/pyalsaaudio.tex Normal file
View File

@@ -0,0 +1,107 @@
\documentclass{howto}
\title{PyAlsaAudio}
\release{0.1}
% At minimum, give your name and an email address. You can include a
% snail-mail address if you like.
\author{Casper Wilstrup}
\authoraddress{cwi@unispeed.com}
\begin{document}
\maketitle
% This makes the Abstract go on a separate page in the HTML version;
% if a copyright notice is used, it should go immediately after this.
%
\ifhtml
\chapter*{Front Matter\label{front}}
\fi
% Copyright statement should go here, if needed.
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.
% The abstract should be a paragraph or two long, and describe the
% scope of the document.
\begin{abstract}
\noindent
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 my priority list, but volunteers are welcome.
If you find bugs in the wrappers please notify me on email. 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.
\end{abstract}
\tableofcontents
\section{What is ALSA}
The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI
functionality to the Linux operating system.
Logically ALSA consists of these components:
\begin{itemize}
\item 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
\item A kernel level API for manipulating the ALSA devices.
\item A user-space C library for simplified access to the sound hardware
from userspace applications. This library is called \textit{libasound}
and is required by all ALSA capable applications.
\end{itemize}
More information about ALSA may be found on the project homepage
\url{http://www.alsa-project.org}
\section{ALSA and Python}
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 (yet).
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.
I wrote PyAlsaAudio to fill this gap. My long term goal is to have the module
included in the standard Python library, but that is probably a while of yet.
PyAlsaAudio hass full support for sound capture, playback of sound, as well as
the ALSA Mixer API.
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
\section{Installation}
Note: the wrappers link with the alsasound library (from the alsa-lib
package). Verify that this is installed by looking for /usr/lib/libasound.so
before building. 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.
To install, execute the following: \\
\begin{verbatim}
$ python setup.py build
\end{verbatim}
And then as root: \\
\begin{verbatim}
# python setup.py install
\end{verbatim}
\input{libalsaaudio}
\end{document}

BIN
doc/up.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B