|
FastLED 3.9.15
|
MusicalBeat distinguishes true musical beats from random onset detection.
This class improves upon basic spectral flux onset detection by:
Key insight: Basic onset detection triggers on ANY spectral change, not just musical beats. This detector uses temporal pattern recognition to distinguish true beats from random noise bursts or non-rhythmic transients.
Usage:
Definition at line 70 of file musical_beat_detector.h.
#include <musical_beat_detector.h>
Collaboration diagram for fl::audio::detector::MusicalBeat:Classes | |
| struct | Stats |
| Get statistics (for debugging/monitoring) More... | |
Public Member Functions | |
| MusicalBeat () FL_NOEXCEPT | |
| MusicalBeat (const MusicalBeatDetectorConfig &config) | |
| ~MusicalBeat () FL_NOEXCEPT | |
| void | configure (const MusicalBeatDetectorConfig &config) |
| Configure the beat detector. | |
| float | getAverageIBI () const |
| Get inter-beat interval (IBI) statistics. | |
| float | getBeatConfidence () const |
| Get beat confidence for the last detected beat. | |
| float | getBPM () const |
| Get current BPM estimate. | |
| const Stats & | getStats () const |
| bool | isBeat () const |
| Check if a musical beat was detected in the last frame. | |
| void | processSample (bool onsetDetected, float onsetStrength) |
| Process one audio frame. | |
| void | reset () |
| Reset internal state (clear history, reset BPM) | |
Private Member Functions | |
| float | calculateBeatConfidence (float currentIBI) |
| Calculate beat confidence based on rhythmic consistency. | |
| float | calculateIBIStdDev () const |
| Calculate standard deviation of IBI history. | |
| bool | isValidIBI (float ibi) const |
| Check if IBI is within valid BPM range. | |
| void | updateBPMEstimate () |
| Update BPM estimate from inter-beat intervals. | |
| bool | validateBeat (float onsetStrength) |
| Validate if an onset is a true musical beat. | |
Private Attributes | |
| float | mAverageIBI = 0.0f |
| Average inter-beat interval (in frames) | |
| bool | mBeatDetected = false |
| Last beat was detected. | |
| MusicalBeatDetectorConfig | mConfig |
| float | mCurrentBPM = 120.0f |
| Current BPM estimate (smoothed) | |
| u32 | mCurrentFrame = 0 |
| Current frame counter. | |
| deque< u32 > | mIBIHistory |
| Inter-beat interval history (in frames) | |
| float | mLastBeatConfidence = 0.0f |
| Last beat confidence score. | |
| u32 | mLastBeatFrame = 0 |
| Last beat timestamp (in frames) | |
| Stats | mStats |