MATLAB Answers

comparing a value with previous ones during real time recording

1 view (last 30 days)
Sadegh Rahimi
Sadegh Rahimi on 5 Jul 2019
Hi colleagues,
I am trying to draw amplitude vs time plot of real time audio input, asking Matlab (R2017a) to find a value above a specific threshold and as a response, give an audio output simultaneously. For example, when I knock the table during the recording, the program should detect more intense ones (according to the threshold), and respond with an alarm sound. I wrote a program, using Data Acquisition Toolbox. It works completely fine, but I faced with a problem: When I knock the table, because of a diverse range of sound amplitude, there is more than one value (above the threshold) for each knocking. Indeed, Ideally, my code should find a peak and after that neglect next 20000 samples(0.5 second, my sample rate is 40000) or more easily, compare the value with the last 20000 value and if there is another peak(above the threshold), do not consider new data as a peak. Is there any way to solve this problem?
Your help is very appreciated.
Bests,
Sadegh
P.S. I attached code and alarm sound as zip file.

Answers (0)

Community Treasure Hunt

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

Start Hunting!