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

3 vues (au cours des 30 derniers jours)
Sergio Nieves Martínez
Sergio Nieves Martínez le 24 Mai 2019
Commenté : Walter Roberson le 26 Mai 2019
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 commentaires
Sergio Nieves Martínez
Sergio Nieves Martínez le 26 Mai 2019
The value for time_period is 0.1 seconds.
Walter Roberson
Walter Roberson le 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)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by