planning ALSA PCM audio interface

Johannes Nix Johannes.Nix at mail.uni-oldenburg.de
Fri Jun 2 14:58:26 EDT 2000


Hi,

I am considering to make a simple interface to the ALSA (Advanced
Linux Sound Architecture) driver library, to allow audio I/O for some
sound cards which don't support the OSS interface. (Actually many
cards are already supported by ALSA, which offers better capabilities
for duplex I/O, for example; however, few applications exist, partly
because the ALSA API ist still alpha and changes frequently). As I
need to use ALSA, I am probably forced to keep up with the API for the
next time, and insulate it pretty nicely from my number crunching.

I am especially interested in doing I/O of digital sample data
(/dev/dsp in OSS notation, PCM interface in ALSA notion), also for
mmap'ed I/O (that means using asynchronous direct access to a DMA
buffer which is mapped to part of Python's virtual memory).
Contrarily I am not interested at all in dealing with MIDI data or
that like. Oh, it will be also 64-bit clean from the beginning.

Does there exist a useful interface for similar tasks ? Perhaps
somebody already is doing this kind of work ?


What would you propose for a simple audio API? (which includes sound
cards for different channels, or voices)?

The module should do the following:

- Open a Soundcard/channel object

- possibly, query hardware preferences from the environment

- get a kind of configuration object

- configure and open the audio device (or throw an exception if the
hardware cannot satisfy the desired setting)

- provide a kind of read() / write() method for data exchange

- alternatively, provide buffer space and sychronization methods for
asynchronous I/O

- watch for buffer underruns/overruns and throw exceptions if they
should crop up

- close the audio interface

What it won't do is data type conversion.

If you want to have a look at the API:

http://www.alsa-project.org/alsa-doc/alsa-lib/

As you see, the API is very clean, but not kind of small. It supports
various soundcards, independent playback and capture, soundcard with
different audio devices at once and multichannel soundcards with
digital I/O.

I think the simplest approach would be to make a hierarchy of objects:
soundcard, device, channel, voice. But perhaps it is not smart to
reproduce the whole C API...

In the SGI audio interface, a lot is done with specific member
functions which set / retreive parameters. I think it could become
perhaps a bit easier with dictionaries and functions with keyword
arguments.


(I am also generelly interested to get contact to people which do
audio programming with Python/NumPy. Here everyone is using MATLAB all
over the place...)

P.S.

Does there exist a "tostring" or "tofile" implementation for the NumPy
array class ? It would be quite useful for me !

Johannes

jnix at medi.physik.uni-oldenburg.de

(our newsserver is cronically unreliable, so I would ask you kindly to
send me a carbon copy. However I am very interested in a thoughtful
discussion!)






More information about the Python-list mailing list