[Python-3000] audio device support
Lars Immisch
lars at ibp.de
Tue Sep 4 23:54:53 CEST 2007
Hi,
I recently worked on Python audio device support for Linux and OS X. Not
so recently, I wrote a DirectSound module for win32.
Python 2 has support for various audio devices, but they have no common
interface and some are broken or obsolete. Python 3000 might be a chance
to improve on this.
The situation seems to be:
Linux:
ossaudiodev is becoming obsolete on Linux (because OSS is being replaced
by ALSA).
pyalsaaudio, http://sourceforge.net/projects/pyalsaaudio, is broken for
multithreaded programs: it does not wrap blocking calls with
Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS. A suitable, submitted patch
has not been included by the maintainer in nearly two years. With this
or a similar patch, it works fine, however.
Windows:
win32all has DirectSound support, but it's lowlevel and complicated.
Other audio device wrappers may exit, but I don't know about them.
OS X:
The (undocumented) audiodev implementation does not work for me. There
is a pyrex implementation for coreaudio support which I haven't tested,
but I have written coreaudio wrappers in C (to be published).
What I'd like to see:
I like the idea of having audio device support for the major operating
systems in the standard library.
But I am even more interested in a common interface for simple operations.
IMO, the API should support:
- stereo playback
- stereo recording
- different sampling rates and formats (alaw, mulaw and PCM in signed
integers in various widths and maybe PCM in floats/doubles).
- device selection
- volume control
Overall, I think the level of abstraction in the OSS or ALSA APIs is
about right, coreaudio on OS X and DirectSound on Windows are overkill
outside of niche applications.
I would volunteer sample implementations for Windows, OS X and Linux (ALSA).
- Lars
More information about the Python-3000
mailing list