How can I reduce latency while processing audio in Simulink?
1 view (last 30 days)
Show older comments
I'm trying to process audio signals using DSP toolbox in Simulink. I'm using the "from wave device" block to input microphone or guitar signals.
While my circuit is able to process the signal, there's a lot of latency(about one second or more). I need to know how to reduce this latency.
I don't think hardware is an issue. I'm using an external audio interface and have tested it with other signal processing software and there has been almost no latency(~10ms and is unnoticeable).
For my purposes, it is very essential that the latency is lower than 20ms.
Would be great if I knew how to reduce the latency. Thanks.
Walter Roberson on 20 Nov 2012
Thanks, Tucker! I would suggest you move your comment to become an Answer.
Tucker McClure on 27 Dec 2012
Yes, Walter is right. ASIO support first shipped with r2012a, and without ASIO, you probably won't reduce your latency below 20ms inside of MATLAB/Simulink.
- Update to 12a. This is by far the easiest, will have very good latency performance, and is a great way to prototype algorithms. I have even fairly complicated algorithms running with ~5ms latency in MATLAB.
- Generate C code from your Simulink model via Simulink Coder and Embedded Coder. Wrap the C code into a VST plugin or some such thing. This is expensive, but is a mature solution to developing production-ready C code from Simulink and has the added benefit of being completely portable. If you're a pro, this is a very good option for much more than just latency reduction.
- The final option is something I've seen but is a really bad option. You could compile PortAudio yourself to get ASIO into an older version of MATLAB. This requires a lot of work, downloading libraries from third parties, figuring out how to build them, and actually changing your MATLAB binaries. Not recommended.
I can't help with Audio Plugin Generator. Never used it.
Find more on Audio Plugin Creation and Hosting 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!