Validate if an onset is a true musical beat.
- Parameters
-
| onsetStrength | Onset magnitude |
- Returns
- True if onset matches expected beat timing
Definition at line 122 of file musical_beat_detector.cpp.hpp.
122 {
123
125 return true;
126 }
127
128
130 float expectedFrames = (expectedIBI *
static_cast<float>(
mConfig.sampleRate)) /
131 static_cast<float>(
mConfig.samplesPerFrame);
132
133
135
136
137 float tolerance = 0.25f;
138 float minExpected = expectedFrames * (1.0f - tolerance);
139 float maxExpected = expectedFrames * (1.0f + tolerance);
140
141
143 float actualIBI = (actualFrames *
static_cast<float>(
mConfig.samplesPerFrame)) /
144 static_cast<float>(
mConfig.sampleRate);
146 }
147
148
149 return (actualFrames >= minExpected) && (actualFrames <= maxExpected);
150}
deque< u32 > mIBIHistory
Inter-beat interval history (in frames)
bool isValidIBI(float ibi) const
Check if IBI is within valid BPM range.
float mCurrentBPM
Current BPM estimate (smoothed)
u32 mCurrentFrame
Current frame counter.
u32 mLastBeatFrame
Last beat timestamp (in frames)
MusicalBeatDetectorConfig mConfig
References isValidIBI(), mConfig, mCurrentBPM, mCurrentFrame, mIBIHistory, and mLastBeatFrame.
Referenced by processSample().