Matlab real-time audio plotting in a GUI
11 views (last 30 days)
Show older comments
Hi Community,
I encountered the following two problems using the audioPlayerRecorder object. I hope to display some processed variable based on input audio and provide audio alarming if such variable above a certain threshold. I followed instructions here: https://www.mathworks.com/help/audio/gs/real-time-audio-in-matlab.html Right now the audio processing is conducted in an infinite while loop. The code is roughly working however still have some issues
Problem 1): since the current procesing time is long. When running the code, the audio player queue always has some underruns. I do not know how to solve this. I tried Malab multi-threading while the performance is even worse
Problem 2) I tried to design a GUI for the existing code, when pressing the 'start' button, the code should run and real-time display the variable in the area speicifed by the GUI settings. However, when pressing the start button, the loop not conduct properly, should I use timer for such process?
Thank you in advance for any help.
Best,
Larry
3 Comments
Matthew
on 2 Apr 2024
Hi,
I am facing a similar issue. I am creating an application that plays real time audio and plots the spectrum with some other functions. Also using the AudioPlayerRecorder.
Here is a quick list of things I have tried that have not seemed to work:
- Using the background thread or parallel processing toolbox. Unfortunately neither the AudioPlayerRecorder or the GUI can be pushed to a background thread, meaning that an update to the GUI results in an underflow in the audio.
- Timer. I have a successful demo of using a timer to periodically play/record samples. However I've run into the same issue regarding underflows with GUI underflows. This solution works to a point, but does not scale as the GUI demands increase.
The big issue that I am facing is the fact that the AudioPlayerRecorder and anything to do with the GUI seems to fight over the same resource without an easy way to multithread the two operations.
I am open to all ideas to get this to work.
Thanks,
Matt
Answers (0)
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!