I'm messing around with trying to record sound reflections off of various objects at different frequencies. I'm using python 2.4 on Fedora Core 3 and I have an SBLive card. Basically, I want to send some samples through a speaker and then record from an input source (the line input on the sound card which I have the output of a mixer going into and a mic plugged into the mixer). So I want to using the soundcard in full duplex mode. I'm trying something like this:
number_of_channels= 1 sample_rate= 44100 sample_width= 2 frames_out= get_frames("test.wav") fh= ossaudiodev.open("/dev/dsp", "rw") fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels, sample_rate) fh.writeall(frames_out) frames_in= fh.read(number_of_samples * sample_width) fh.close() However, even if I turn off the speakers I get the original output tone back from the read (as well as the input from the mic). I'm assuming it's the same internal buffer somewhere on the soundcard so when I do the read I'm really reading what the write just wrote (because I get that orginal tone in the background even though I turned off the speaker so it's just not the reflections coming back through the mic...it's happening internally somewhere). If I unplug everything from the sound card I'll still get it. I tried closing the filehandle after the write and then reopening it before the read and I also tried opening two filehandles, one to /dev/dsp and another to /dev/dsp1 and still have th same problem. In the above example I tried the ossaudiodev's sync() and reset() functions inbetween the write() and read(). Also still have the same problem even when I do this: fh= ossaudiodev.open("/dev/dsp", "w") fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels, sample_rate) fh.writeall(frames_out) fh.close() fh= ossaudiodev.open("/dev/dsp", "r") fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels, sample_rate) frames_in= fh.read(number_of_samples * sample_width) fh.close() Any ideas? Am I doing something fundamentally wrong? Any help would be greatly appreciated. Thanks. -richie -- http://mail.python.org/mailman/listinfo/python-list