Movatterモバイル変換
[0]ホーム
[Python-Dev] linuxaudiodev minimal test
est@hyperreal.orgest@hyperreal.org
Sat, 1 Apr 2000 14:00:54 -0800 (PST)
The appended script works for me. I think the module should be calledsomething like OSS (since it uses the Open Sound System API) with a -Ientry in Setup.in to indicate that this will probably need to bespecified 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 haveto wait until I finish moving to California. :)Best,Eric#!/usr/bin/pythonimport linuxaudiodevimport math, struct, fcntl, FCNTLa = 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)
[8]ページ先頭