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
ossaudiodev full duplex
Started by ●March 26, 2005
Reply by ●March 27, 20052005-03-27
On 26 Mar 2005 11:18:08 -0800, rjm@si.rr.com wrote:>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.This very possibly has nothing to do with your programming, but rather a setting in the windows 'mixer' application that puts the sound being sent out into the sound being captured. Double-click the speaker icon in the tray to bring up the 'volume control' icon. Go to Options->Properties, and check everything under the "show the following volume controls" and click ok. Click the Mute checkbox for everything but Line In.>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://mindspring.com/~benbradley
Reply by ●March 27, 20052005-03-27
> This very possibly has nothing to do with your programming, but >rather a setting in the windows 'mixer' application that puts the >sound being sent out into the sound being captured. Double-click the >speaker icon in the tray to bring up the 'volume control' icon. Go to >Options->Properties,I forgot something very important here. First select Recording, then:>and check everything under the "show the >following volume controls" and click ok. Click the Mute checkbox for >everything but Line In.----- http://mindspring.com/~benbradley
Reply by ●March 27, 20052005-03-27
Thanks. It definitly seems to be something due to the mixer settings. I don't quit understand all the settings yet but it seems I can only get it to record the line in if the "mix" channel is set to "capture". However, doing this mixs all sources together it appears which gives me the orginal wave as well. I'll experiment with different settings with the mutes and volumes and see what happens. Thanks for your help. Ben Bradley wrote:> On 26 Mar 2005 11:18:08 -0800, rjm@si.rr.com wrote: > > >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 outputtone> >back from the read (as well as the input from the mic). I'massuming> >it's the same internal buffer somewhere on the soundcard so when Ido> >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 everythingfrom> >the sound card I'll still get it. > > This very possibly has nothing to do with your programming, but > rather a setting in the windows 'mixer' application that puts the > sound being sent out into the sound being captured. Double-click the > speaker icon in the tray to bring up the 'volume control' icon. Go to > Options->Properties, and check everything under the "show the > following volume controls" and click ok. Click the Mute checkbox for > everything but Line In. > > >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 thesame> >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 helpwould> >be greatly appreciated. > >Thanks. > >-richie > > ----- > http://mindspring.com/~benbradley