Mailing List Archive

linuxaudiodev minimal test
The appended script works for me. I think the module should be called
something like OSS (since it uses the Open Sound System API) with a -I
entry in Setup.in to indicate that this will probably need to be
specified to find <soundcard.h> (e.g., -I/usr/include/linux for Linux,
-I/usr/include/machine for FreeBSD...).

I'm sure I'll have other suggestions for the module, but they'll have
to wait until I finish moving to California. :)

Best,

Eric

#!/usr/bin/python

import linuxaudiodev
import math, struct, fcntl, FCNTL

a = linuxaudiodev.open('w')

a.setparameters(44100, 16, 1, linuxaudiodev.AFMT_S16_LE)

N = 500

data = apply(struct.pack,
['<%dh' % N]
+ map(lambda n: 32767 * math.sin((2 * math.pi * n) / N),
range(N)))

fd = a.fileno()

fcntl.fcntl(fd, FCNTL.F_SETFL,
~FCNTL.O_NONBLOCK & fcntl.fcntl(fd, FCNTL.F_GETFL))

for i in xrange(200):
a.write(data)