Why doesn't the audio recorder object execute the callback function?

3 Ansichten (letzte 30 Tage)
I'm doing a program that detects hits in real time, up to a maximum of 10 hits. The problem I have is that the audiorecorder object does not execute its callback function during this recording. The only way I have succeeded in executing the program perfectly is by putting a debug on the next line at the beginning of the recording. I have tried to make the same effect by using the pause function in the following line, but it neither works. The result of making a tic-toc between these two lines is 0.019 seconds. Definitely neither of these two lines is working. I don't know if someone has faced a similar problem with these two functions and they know how to solve it.
recorder = audiorecorder(Fs,24,1);
set(recorder,'TimerPeriod',time_period,'TimerFcn',@(src,eventdata)hitDetection(src,eventdata,Fs,maxpeaks,MR,M,N));
tic
record(recorder)
pause(30)
toc
>> RecordingFunction
Elapsed time is 0.019214 seconds.
  4 Kommentare
Walter Roberson
Walter Roberson am 26 Mai 2019
It seems to work for me in my test in R2019a on Mac:
Fs = 8000;
time_period = 2;
recorder = audiorecorder(Fs,24,1);
set(recorder,'TimerPeriod',time_period,'TimerFcn',@(src,eventdata)disp(datetime()));
tic
record(recorder)
pause(30)
toc
stop(recorder)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by