From: Gus Lott on
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