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

3 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-5-26
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by