real time analog input and output

  • Follow


hello,
i'm trying to get a code which will continuously sample an analog input (microphone) and then output the sample to a speaker.
i'm trying to do it using 2 TimerFcn, one for the input and one for the output, but only one of them is working (the last).
i also tried doing it with one timer function but i keep getting an error.

anyone have an idea?

thanks.
0
Reply lior 6/11/2010 9:08:04 PM

You are using the DAQ toolbox?  The fastest way to accomplish this might be a getsample() followed by a putsample() 

"lior " <liord2@gmail.com> wrote in message <huu8jk$458$1@fred.mathworks.com>...
> hello,
> i'm trying to get a code which will continuously sample an analog input (microphone) and then output the sample to a speaker.
> i'm trying to do it using 2 TimerFcn, one for the input and one for the output, but only one of them is working (the last).
> i also tried doing it with one timer function but i keep getting an error.
> 
> anyone have an idea?
> 
> thanks.
0
Reply Patrick 6/11/2010 10:24:07 PM


http://spikehound.sourceforge.net/

This matlab program will route the data from any input source (daq toolbox) to the computer speakers using the "listen" button.  It was originally designed so that you could capture neural spikes on a national instruments board (or otherwise) and listen to them on your speakers.

It works by hooking the "samples acquired function" of a data acquisition object.  After a certain number of samples are captured on the input, the samp acq func is called and the samples are put into the output buffer of an analog output.

It's tricky.  In theory, the sample rates of your inputs and outputs need to be the same or you need to do interpolation or resampling to get your output signal matching your input signal in time.

Then, as you backfill the output buffer (using putdata) it may be that your device finishes before you can pump more data in, so you'll need to restart it with the next chunk of data.  Spikehound (the software at the link above) is provided in compiled and .m code version.  There's a "listen" button that allows you to route the selected input channel to your system speakers.

And you'll have to be careful about feedback if you're using a mic and speakers.  The software won't do feedback cancelation.

Good luck
0
Reply Gus 6/12/2010 12:12:26 PM

"lior" wrote in message <huu8jk$458$1@fred.mathworks.com>...
> hello,
> i'm trying to get a code which will continuously sample an analog input (microphone) and then output the sample to a speaker.
> i'm trying to do it using 2 TimerFcn, one for the input and one for the output, but only one of them is working (the last).
> i also tried doing it with one timer function but i keep getting an error.
> 
> anyone have an idea?
> 
> thanks.

pls see this...data can be =wavread()
or DAQ output
data = getdata(AI);
q = quantizer([16 10]);
input2=num2bin(q,data);
input3=double(input2);
input5=input3-48;
0
Reply bkv.kannur (2) 2/7/2012 8:59:11 PM

"lior" wrote in message <huu8jk$458$1@fred.mathworks.com>...
> hello,
> i'm trying to get a code which will continuously sample an analog input (microphone) and then output the sample to a speaker.
> i'm trying to do it using 2 TimerFcn, one for the input and one for the output, but only one of them is working (the last).
> i also tried doing it with one timer function but i keep getting an error.
> 
> anyone have an idea?
> 
> thanks.

pls see this...data can be =wavread()
or DAQ output
data = getdata(AI);
q = quantizer([16 10]);
input2=num2bin(q,data);
input3=double(input2);
input5=input3-48;
0
Reply bkv.kannur (2) 2/7/2012 8:59:11 PM

4 Replies
414 Views

(page loaded in 0.059 seconds)

Similiar Articles:













7/24/2012 1:47:17 AM


Reply: