[Python-Dev] linuxaudiodev module

Guido van Rossum guido@python.org
Sat, 07 Oct 2000 20:41:11 -0500

I think I fixed the linuxaudio test -- see if it sounds reasonable

The crux of the matter seemed to be that the last, optional argument
to setparameters(), meaning "emulate the format if the sound card
doesn't support it", is not supported right.  It suppresses the error
message, and the ioctl to set the format succeeds, but the emulation
doesn't work (at least not on my system, or on Jeremy's).

So I've used a subterfuge: assuming most sound cards support signed
16-bit native-endian format, I convert the data to that format, and
use the appropriate format code: AFMT_S16_LE for little-endian
machines, AFMT_S16_BE for big-endian machines.  I've only tested

I use the new sys.byteorder variable to determine the endianness.

I use the audioop module to do the conversion.  Much simpler than sox!
(Oh feeling of nostalgia...  I wrote several of the file format
handlers for sox, and fixed lots of bugs in it too...  I even started
the audio file formats FAQ, now maintained by Chris Bagwell, who also
took over sox...)

Downside: test_linuxaudiodev will now be skipped if you don't have the
audioop enabled in your Setup file.  But that's fixed easily.

By the way -- the checkin freeze for the release candidate should go
in just about now...

--Guido van Rossum (home page: http://www.python.org/~guido/)