Try to determine the start time and duration of each "beat" in an audio signal (circled in figure below). It looks like a simple question, and python or Matlab should have toolbox/functions to do this, just couldn't find them. I tried low pass filtering and freq analysis, but neither worked.
-
$\begingroup$ Did you have a look on the following answer $\endgroup$– IrreducibleMar 27, 2019 at 7:27
-
$\begingroup$ Possible duplicate of Smoothing signal / detecting bumps in a data stream Also research "Onset Detection" it's effectively a whole field on it. $\endgroup$– CyberMenMar 27, 2019 at 14:13
2 Answers
The area you're asking about is called "Onset Detection" this is used all throughout signal processing, but most oven used in Music Information Retrieval to identify the start and stop to notes.
While there are many ways to accomplish this lets consider two: energy and frequency domain.
Energy: We know that when there is a spike in a signal there is a marked increase in the energy of the signal. You could simply create sampling windows and calculate the average absolute energy of the window by tracking the area under the curve. When you see a large increase it means you've reached a peak (or close enough to an onset)
Frequency: We know that in the time domain, if a signal is high in amplitude and short in time it will have a wide spread in the frequency domain with most of that content in the higher end of the frequency spectrum. (Dirac function is a prime example of this)
You could cut your signal into small windows, calculate the FFT and detect when there is a large change in high frequency content.
These two methods are theoretically the same, however your implementation would result in different accuracy.
Here's a tutorial on many of the onset detection algorithms out there.
The beat is pretty abrupt and packs considerable signal power. Power thresholding after low pass filtering and wavelet transform are good options.
If you are more specific and attach some code we’d be able to help better.