STOP dsp.audioplayer object from a GUIDE

1 view (last 30 days)
Mariano
Mariano on 5 Nov 2014
Answered: Sean de Wolski on 5 Nov 2014
Hello everybody! I'm trying to make in a kind of multichannel audio recorder, using Matlab 2013b and working with the dsp tollbox.
I have a GUI with 2 buttons, one for reproduction and one for stop. When I press PLAY, I create a dsp.AudioReader and a dsp.AudioPlayer object, and I get sound from one channel of my interface. The reproduction stops when the file is ended.
What I need to do is to also stop reproduccion if somebody presses the STOP button. What i thought was to use a flag "recordingON" and use a While loop. Inside pushbuttonPLAY's calback I have something like:
while (recordingON)
do one step of reproduction.
check new value of recordingON
end
Then, if I pressed STOP, I changed recordingON to 0, recording should stop. I have tried it by saving the variable in one callback and loading it in ther other, by using globals, using guidata and directly reading the pushbutton stop:
while (recordingON)
do one step of record.
recordingON = ~get(handles.pusshbuttonSTOP,'Value');
end
while debbuging, everything goes OK. When I press pusshbuttonSTOP, recordingON changes to 0 and the reproduction is stopped. But in normal mode, the condition does not work, and the reproduction does not stop.
To check if the problem is due to dsp.Audio objects, I changed the content of the loop to simply:
i = 0;
while (recordingON)
i = i+1;
recordingON = ~get(handles.pusshbuttonSTOP,'Value');
end
And "i" continues adding one and never stops (i have to press Control+C to cancel).
In the STOP button I added a breakpoint and the program goes to that point only when I cancel the audio reproduccion manually (I mean that MATLAB runs all the reproduction and only then goes inside STOP).
Which is the correct form to stop a while loop inside one callback from other ?
Thanks a lot!

Answers (1)

Sean de Wolski
Sean de Wolski on 5 Nov 2014

Categories

Find more on Signal Processing Toolbox 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!