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

3 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by