From 8fa9d27a8865a10d485fc98b625c6d40a18bdec7 Mon Sep 17 00:00:00 2001
From: larsimmisch
Date: Thu, 24 Jan 2008 12:22:41 +0000
Subject: [PATCH] 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
---
CHANGES | 8 ++
LICENSE | 54 ++++++++
README | 13 +-
TODO | 1 -
alsaaudio.c | 2 +-
doc/about.html | 98 +++++++-------
doc/contents.html | 107 ++++++++-------
doc/front.html | 113 ++++++++--------
doc/index.html | 97 +++++++-------
doc/mixer-objects.html | 230 ++++++++++++++++----------------
doc/module-alsaaudio.html | 131 ++++++++++---------
doc/node3.html | 107 +++++++--------
doc/node4.html | 111 ++++++++--------
doc/node5.html | 107 +++++++--------
doc/node7.html | 105 +++++++--------
doc/pcm-example.html | 103 ++++++++-------
doc/pcm-objects.html | 266 +++++++++++++++++++-------------------
doc/pyalsaaudio.css | 243 ++++++++++++++++++++++++++++++++++
doc/pyalsaaudio.html | 97 +++++++-------
doc/src/Makefile | 7 +-
doc/src/libalsaaudio.tex | 4 +-
doc/src/pyalsaaudio.tex | 2 +-
playbacktest.py | 4 +-
recordtest.py | 2 +-
24 files changed, 1192 insertions(+), 820 deletions(-)
create mode 100644 CHANGES
create mode 100644 LICENSE
create mode 100644 doc/pyalsaaudio.css
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..6ce8463
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,8 @@
+VERSION 0.1
+- Initial version
+
+
+VERSION 0.2
+- Many bugfixes related to playback in particular
+- Module documentation in the doc subdirectory
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8aa69f7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,54 @@
+PyAlsaAudio is released under the same conditions as Python itself.
+The original wording of this license can be found below.
+
+
+PSF LICENSE AGREEMENT FOR PYTHON 2.4
+------------------------------------
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation
+("PSF"), and the Individual or Organization ("Licensee") accessing and
+otherwise using Python 2.4 software in source or binary form and its
+associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use Python 2.4
+alone or in any derivative version, provided, however, that PSF's
+License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
+2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved"
+are retained in Python 2.4 alone or in any derivative version prepared
+by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python 2.4 or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python 2.4.
+
+4. PSF is making Python 2.4 available to Licensee on an "AS IS"
+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.4 WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+2.4 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.4,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between PSF and
+Licensee. This License Agreement does not grant permission to use PSF
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Python 2.4, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
diff --git a/README b/README
index 5276f40..179cb79 100644
--- a/README
+++ b/README
@@ -24,7 +24,10 @@ Installation
Note: the wrappers link with the alsasound library alsa (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
+before building. The libasound development files are also neccesary. On debian
+and derivatives, this is achieved by installing the alsalib-dev package.
+
+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.
@@ -38,13 +41,15 @@ And then as root:
Using the API
=============
+There is a reasonably usefull API documentation included in the module
+documentation, which can be found in the doc subdirectory of the source
+distribution.
-There are two example programs included with the source:
+There are also three example programs included with the source:
'playbacktest.py' which plays back raw sound data read from
stdin
'recordtest.py' which captures sound from the microphone at writes
it raw to stdout.
-In a future version, I'll include documentation with the package, but
-for now, you're stuck with the examples.
+'mixertest.py' which can be used to manipulate the mixers
diff --git a/TODO b/TODO
index 8f8f370..710a8a3 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-- Write documentation
- Better example code (aplay,arecord,amixer workalike for example)
- Implement MIDI/sequencer support.
diff --git a/alsaaudio.c b/alsaaudio.c
index 85e3509..1828148 100644
--- a/alsaaudio.c
+++ b/alsaaudio.c
@@ -373,7 +373,7 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args) {
int res;
if (!PyArg_ParseTuple(args,"s#",&data,&datalen)) return NULL;
if (datalen%self->framesize) {
- PyErr_SetString(ALSAAudioError,"Data size must be a multipla of framesize");
+ PyErr_SetString(ALSAAudioError,"Data size must be a multiple of framesize");
return NULL;
}
res = snd_pcm_writei(self->handle, data, datalen/self->framesize);
diff --git a/doc/about.html b/doc/about.html
index 13c8b28..c47ebca 100644
--- a/doc/about.html
+++ b/doc/about.html
@@ -1,44 +1,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
About this document ...
control - specifies which control to manipulate using this mixer object. The list
of available controls can be found with the alsaaudio.mixers function.
@@ -77,16 +79,16 @@ Mixer objects have the following methods:
Returns a list with the current volume settings for each channel. The list elements
are integer percentages.
@@ -189,8 +191,8 @@ if the mixer has this capability, otherwise 'capture'
Return a list indicating the current mute setting for each channel. 0 means not muted, 1 means muted.
@@ -200,8 +202,8 @@ This method will fail if the mixer has no playback switch capabilities.
Return a list indicating the current record mute setting for each channel. 0 means not recording, 1
means not recording.
@@ -212,8 +214,8 @@ This method will fail if the mixer has no capture switch capabilities.
Change the current volume settings for this mixer. The volume argument controls
the new volume setting as an integer percentage.
@@ -230,8 +232,8 @@ if changed. The default is 'playback' if the mixer has this capability, otherwis
Sets the mute flag to a new value. The mute argument is either 0 for not muted, or 1 for muted.
@@ -245,8 +247,8 @@ This method will fail if the mixer has no playback mute capabilities
Sets the capture mute flag to a new value. The capture argument is either 0 for no capture,
or 1 for capture.
@@ -285,37 +287,39 @@ and that which I do understand has come from a painful trial and error process.
List the available mixers. The optional cardname specifies which
card should be queried (this is only relevant if you have more than one
@@ -77,8 +78,8 @@ sound card). Omit to use the default sound card
This class is used to represent a PCM device (both playback and capture devices).
The arguments are:
@@ -90,8 +91,8 @@ if you have more than one sound card). Omit to use the default sound card
This class is used to access a specific ALSA mixer.
The arguments are:
@@ -102,16 +103,17 @@ if you have more than one sound card). Omit to use the default sound card
@@ -113,7 +114,7 @@ slower and read or write multiple periods at the same time.
Period size
-
This is the size of each period in Hz. Not bytes, but Hz!. In alsaaudio
+
This is the size of each period in Hz. Not bytes, but Hz!. In 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.
@@ -128,37 +129,39 @@ Once you understand these concepts, you will be ready to actually utilize PCM AP
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
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)
In PCM_NORMAL mode, this function blocks until a full period is available, and then returns a
-tuple (length,data) where length is the size in bytes of the captured data, and data
+tuple (length,data) where length is the size in bytes of the captured data, and data
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.
-Writes (plays) the sound in data. The length of data must be a multiple of the frame size, and
-should 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 must be a multiple of the frame size, and
+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.
@@ -258,14 +260,14 @@ full. In this case, the data should be written at a later time.
-A few hints on using PCM devices for playback
+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 exactly the data rate of the device.
+that writes to PCM devices must match 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,
+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.
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 8187760..44c3313 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -5,7 +5,7 @@
#
# You also need a working latex installation, and the latex2html
# tool installed.
-PYTHONSOURCE = /usr/src/Python-2.3.4/
+PYTHONSOURCE = /usr/src/Python-2.4.1/
# Shouldn't need to change anything below here!
@@ -13,3 +13,8 @@ MKHOWTO = $(PYTHONSOURCE)/Doc/tools/mkhowto
all:
$(MKHOWTO) --dir .. --html pyalsaaudio.tex
+
+text:
+ $(MKHOWTO) --dir .. --text pyalsaaudio.tex
+
+
diff --git a/doc/src/libalsaaudio.tex b/doc/src/libalsaaudio.tex
index 5ac8775..c50ffe5 100644
--- a/doc/src/libalsaaudio.tex
+++ b/doc/src/libalsaaudio.tex
@@ -234,7 +234,7 @@ full. In this case, the data should be written at a later time.
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,
+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).
@@ -394,4 +394,4 @@ and that which I do understand has come from a painful trial and error process.
\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.
\ No newline at end of file
+This will change in a future version.
diff --git a/doc/src/pyalsaaudio.tex b/doc/src/pyalsaaudio.tex
index d8958f1..1a5a4b0 100644
--- a/doc/src/pyalsaaudio.tex
+++ b/doc/src/pyalsaaudio.tex
@@ -2,7 +2,7 @@
\title{PyAlsaAudio}
-\release{0.1}
+\release{0.2}
% At minimum, give your name and an email address. You can include a
% snail-mail address if you like.
diff --git a/playbacktest.py b/playbacktest.py
index 61218a6..06e0fe9 100644
--- a/playbacktest.py
+++ b/playbacktest.py
@@ -9,7 +9,9 @@
## To test it out do the following:
## python recordtest.py > out.raw # talk to the microphone
## python playbacktest.py < out.raw
-
+##
+## If you have Gnome, you could also just test by doing something like:
+## python playbacktest.py < /usr/share/sounds/gnibbles/laughter.wav
import alsaaudio
import sys
import time
diff --git a/recordtest.py b/recordtest.py
index 8a5b9e3..216d627 100644
--- a/recordtest.py
+++ b/recordtest.py
@@ -33,7 +33,7 @@ inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
# mode.
inp.setperiodsize(160)
-loops = 10000
+loops = 1000000
while loops > 0:
loops -= 1
# Read data from device