Import from divmod. Added css. Original log message:

r1585 | casper | 2005-07-09 23:26:15 +0200 (Sat, 09 Jul 2005) | 3 lines

Last checkin before version 0.2





git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@12 ec2f30ec-7544-0410-870e-f70ca00c83f0
This commit is contained in:
larsimmisch
2008-01-24 12:22:41 +00:00
parent 470d6140df
commit 8fa9d27a88
24 changed files with 1192 additions and 820 deletions

View File

@@ -1,53 +1,55 @@
<!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">
<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' />
<title>4.2 PCM Objects</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<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 class='online-navigation'><a rel="prev" title="4.1 PCM Terminology and"
href="node7.html"><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='next.png'
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>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node7.html">4.1 PCM Terminology and</A>
<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>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION002420000000000000000">&nbsp;</A>
<H2><A NAME="SECTION002420000000000000000"></A>
<A NAME="pcm-objects"></A>
<BR>
4.2 PCM Objects
</H2>
@@ -63,8 +65,8 @@ 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>
<td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-6' xml:id='l2h-6' class="class">PCM</tt></b>(</nobr></td>
<td><var></var><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><var></var>)</td></tr></table></dt>
<dd>
<P>
@@ -102,32 +104,32 @@ 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>
<td><nobr><b><tt id='l2h-7' xml:id='l2h-7' class="method">pcmtype</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<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>
<td><nobr><b><tt id='l2h-8' xml:id='l2h-8' class="method">pcmmode</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<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>
<td><nobr><b><tt id='l2h-9' xml:id='l2h-9' class="method">cardname</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<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>
<td><nobr><b><tt id='l2h-10' xml:id='l2h-10' class="method">setchannels</tt></b>(</nobr></td>
<td><var>nchannels</var>)</td></tr></table></dt>
<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
@@ -135,8 +137,8 @@ and 6 = full 6 channel audio. Few sound cards support more than 2 channels
<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>
<td><nobr><b><tt id='l2h-11' xml:id='l2h-11' class="method">setrate</tt></b>(</nobr></td>
<td><var>rate</var>)</td></tr></table></dt>
<dd>
Set the sample rate in Hz for the device. Typical values are 8000 (poor sound), 16000, 44100 (cd quality),
and 96000
@@ -144,77 +146,77 @@ and 96000
<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>
<td><nobr><b><tt id='l2h-12' xml:id='l2h-12' class="method">setformat</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<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">
<div class="center"><table class="realtable">
<thead>
<tr class="tableheader">
<th align="left"><b>Format</b>&nbsp;</th>
<th align="left"><b>Description</b>&nbsp;</th>
<tr>
<th class="left" >Format</th>
<th class="left" >Description</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>
<tbody>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S8</Formats></td>
<td class="left" >Signed 8 bit samples for each channel</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U8</Formats></td>
<td class="left" >Signed 8 bit samples for each channel</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S16_LE</Formats></td>
<td class="left" >Signed 16 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S16_BE</Formats></td>
<td class="left" >Signed 16 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U16_LE</Formats></td>
<td class="left" >Unsigned 16 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U16_BE</Formats></td>
<td class="left" >Unsigned 16 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S24_LE</Formats></td>
<td class="left" >Signed 24 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S24_BE</Formats></td>
<td class="left" >Signed 24 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U24_LE</Formats></td>
<td class="left" >Unsigned 24 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U24_BE</Formats></td>
<td class="left" >Unsigned 24 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S32_LE</Formats></td>
<td class="left" >Signed 32 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_S32_BE</Formats></td>
<td class="left" >Signed 32 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U32_LE</Formats></td>
<td class="left" >Unsigned 32 bit samples for each channel (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_U32_BE</Formats></td>
<td class="left" >Unsigned 32 bit samples for each channel (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT_LE</Formats></td>
<td class="left" >32 bit samples encoded as float. (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT_BE</Formats></td>
<td class="left" >32 bit samples encoded as float (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT64_LE</Formats></td>
<td class="left" >64 bit samples encoded as float. (Little Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_FLOAT64_BE</Formats></td>
<td class="left" >64 bit samples encoded as float. (Big Endian byte order)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_MU_LAW</Formats></td>
<td class="left" >A logarithmic encoding (used by Sun .au files)</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_A_LAW</Formats></td>
<td class="left" >Another logarithmic encoding</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_IMA_ADPCM</Formats></td>
<td class="left" >a 4:1 compressed format defined by the Interactive Multimedia Association</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_MPEG</Formats></td>
<td class="left" >MPEG encoded audio?</td></tr>
<tr><td class="left" valign="baseline"><Formats>PCM_FORMAT_GSM</Formats></td>
<td class="left" >9600 constant rate encoding well suitet for speech</td></tr></tbody>
</table></div>
<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>
<td><nobr><b><tt id='l2h-13' xml:id='l2h-13' class="method">setperiodsize</tt></b>(</nobr></td>
<td><var>period</var>)</td></tr></table></dt>
<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
@@ -223,11 +225,11 @@ it may return nothing at all)
<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>
<td><nobr><b><tt id='l2h-14' xml:id='l2h-14' class="method">read</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<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>
tuple (length,data) where <em>length</em> is the size in bytes of the captured data, and <em>data</em>
is the captured sound frames as a string. The length of the returned data will be periodsize*framesize
bytes.
@@ -238,11 +240,11 @@ has become available since the last call to read.
<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>
<td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="method">write</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<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
Writes (plays) the sound in data. The length of data <em>must</em> be a multiple of the frame size, and
<em>should</em> 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>
@@ -258,14 +260,14 @@ full. In this case, the data should be written at a later time.
</dl>
<P>
<b>A few hints on using PCM devices for playback</b>
<strong>A few hints on using PCM devices for playback</strong>
<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.
that writes to PCM devices must match <em>exactly</em> 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,
If too little data is written to the device, it will 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).
@@ -289,37 +291,39 @@ extra writes as nessecary.
<P>
<DIV CLASS="navigation">
<p><hr>
<div class='online-navigation'>
<p></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 class='online-navigation'><a rel="prev" title="4.1 PCM Terminology and"
href="node7.html"><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4 alsaaudio"
href="module-alsaaudio.html"><img src='up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.3 Mixer Objects"
href="mixer-objects.html"><img src='next.png'
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>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" HREF="node7.html">4.1 PCM Terminology and</A>
<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>
</div>
<hr />
<span class="release-info">Release 0.2.</span>
</DIV>
<!--End of Navigation Panel-->