[Python-Dev] Audio devices

Greg Ward gward@python.net
Tue, 11 Mar 2003 16:44:50 -0500


On 11 March 2003, Guido van Rossum said:
> Yes, it fixes the hang.  Please check it in!

OK, done.

> The sample is still played at too high a speed, but maybe that's
> expected?

No, definitely not.  On my system, it sounds the same as it has with
linuxaudiodev for quite a while, and the same as it did with sunaudiodev
on my old Sun box at CNRI before that.

*Maybe* there's something wrong with how setparameters() initializes the
audio device.  Try this patch and see how it goes:

--- Lib/test/test_ossaudiodev.py        14 Feb 2003 19:29:22 -0000      1.4
+++ Lib/test/test_ossaudiodev.py        11 Mar 2003 21:42:31 -0000
@@ -52,8 +52,10 @@
     a.fileno()
 
     # set parameters based on .au file headers
-    a.setparameters(rate, 16, nchannels, fmt)
-    a.write(data)
+    a.setfmt(fmt)
+    a.channels(nchannels)
+    a.speed(rate)
+    a.writeall(data)
     a.flush()
     a.close()
 

Hmmm, I just noticed that setting O_NONBLOCK at open() time *does* have
an effect -- I needed to change that write() to writeall() in order to
hear the whole test sound.  Uh-oh.

        Greg
-- 
Greg Ward <gward@python.net>                         http://www.gerg.ca/
"... but in the town it was well known that when they got home their fat and
psychopathic wives would thrash them to within inches of their lives ..."