Simultaneous Recording and Reprodction of a File in MATLAB
10 views (last 30 days)
Show older comments
I'm currently working on my undergraduate thesis, which consists on an assisted reverberation system for a small auditoria and got stuck while trying to record a file and play it while it's still in the recoring process. I was wondering if somebody could help me get pass this inconvienience.
I have to get audio from an external sound card, proccess it and play it into a speaker system in real time.
Thanks.
0 Comments
Answers (4)
Daniel Shub
on 24 Mar 2011
If you want to start playback and recording at the same time, this is really going to depend on your sound card and OS. Cheap sound cards sometimes do not lock the playback and recording clocks, but mid level and above cards do. Assuming your sound card supports what you are trying to do, look for a MATLAB based implementation of port audio that supports both playback and recording. Both Psych Toolbox and PAWAVPLAY are implementations of port audio, but I am not sure recording is implemented. Assuming Windows, based on comments about the Data Acquisition toolbox, you would need an ASIO compatible sound card to use port audio.
0 Comments
Walter Roberson
on 23 Mar 2011
The facilities in the Data Acquisition Toolbox would be most natural for that. You would use analoginput() to add a 'winsound' device, set() the sample rate and number of channels, getdata() to receive samples, and process them. To output, you would first analogoutput() a 'winsound' device and set() the parameters for it, and then at time of output, putdata() the samples.
2 Comments
Walter Roberson
on 24 Mar 2011
Sorry, I do not have the Data Acquisition Toolbox (and I run Matlab off a server anyhow.) Perhaps one of the DAQ people will have some suggestions.
Generally speaking, using Matlab for real-time work is hard unless you are using the Real Time Workshop on a target machine. Though I understand that some of the Simulink modules can get pretty close -- and probably the system you describe would be pretty easy to model in Simulink.
The best collection of routines that I know of for near real time work are the Psychometric Toolbox, http://psychtoolbox.org/PTB-2/intro.html . Although it is intended for vision, it has routines intended for synchronizing sound and vision, which is difficult in Matlab; you might be able to get some valuable clues from their code.
Daniel Shub
on 24 Mar 2011
Assuming you have a channel to spare on your sound card you can set up a loop back to compensate for the latency. You can push a pulse out the loop back channel and measure the latency. Once the latency is known you should be able to adjust you "indices" for the playback and recording.
0 Comments
See Also
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!