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

조회 수: 11 (최근 30일)
Sergio Nieves Martínez
Sergio Nieves Martínez 2019년 5월 24일
댓글: Walter Roberson 2019년 5월 26일
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
Sergio Nieves Martínez
Sergio Nieves Martínez 2019년 5월 26일
The value for time_period is 0.1 seconds.
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