Simultaneous Recording and Reprodction of a File in MATLAB
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(4 个)
Daniel Shub
2011-3-24
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 个评论
Walter Roberson
2011-3-23
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 个评论
Walter Roberson
2011-3-24
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
2011-3-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!