I'm a Software Engineer Undergraduate. I'm trying to detect drum strokes(beats) in real-time in python. I used amplitude threshold-based onset detect (beat detect) algorithm but it takes other noises also onsets and it omits some actual beats with low amplitude. Can you have suggestions to optimize my code or another way to solve this?
2 Answers
My guess is that the currently popular and new and likely robust way to solve this detection problem is to feed a sequence of audio fingerprints (such as MFCCs) to an RNN machine learning algorithm that was trained on a large wide range of rhythm tracks mixed with increasing levels of realistic background noise.
Feeding audio stream samples directly to a deeper CNN+RNN ML inference engine might work even better by detecting humanly resolvable beat details that audio fingerprinting misses, but that would be computationally far less efficient and would take a lot longer to train.
-
-
$\begingroup$ Is there any possibility to find an existing Neural Network machine learning model that has already been trained with a large dataset? Is MFCC enough to classify a sound from another or we should use other audio fingerprints too depending on the situation or we should use other features like Spectral Bandwidth, Spectral Centroid, Zero Crossing rate, etc? $\endgroup$ Nov 3, 2019 at 21:34
Using an adaptive threshold might help you: calculating the mean amplitude over a small moving time window (e.g. 0.5 sec), and setting a threshold as a function of the mean (e.g. 3X). This should detect sudden changes in amplitude (which drum strokes almost always are).
-
$\begingroup$ I already use a threshold-based onset detect algorithm with a window size of 0.02s. But when I put lower value to the threshold it takes noises as a strokes and when I set it as a higher value it passes real strokes. I put that much of window size to get real-time output less than 0.1s, which cannot identify the difference between input and output time gap to the human ear. $\endgroup$ Nov 3, 2019 at 21:05