FastLED 3.9.15
Loading...
Searching...
No Matches

◆ updateBPMEstimate()

void fl::audio::detector::MusicalBeat::updateBPMEstimate ( )
private

Update BPM estimate from inter-beat intervals.

Definition at line 183 of file musical_beat_detector.cpp.hpp.

183 {
184 if (mIBIHistory.empty()) {
185 return;
186 }
187
188 // Calculate BPM from average IBI
189 float avgIBI = getAverageIBI();
190 if (avgIBI <= 0.0f) {
191 return;
192 }
193
194 float instantaneousBPM = 60.0f / avgIBI;
195
196 // Clamp to valid range
197 instantaneousBPM = fl::max(mConfig.minBPM, fl::min(mConfig.maxBPM, instantaneousBPM));
198
199 // Smooth BPM estimate (exponential moving average)
200 float alpha = mConfig.bpmSmoothingAlpha;
201 mCurrentBPM = (alpha * mCurrentBPM) + ((1.0f - alpha) * instantaneousBPM);
202
203 // Ensure BPM stays in valid range after smoothing
205}
deque< u32 > mIBIHistory
Inter-beat interval history (in frames)
float mCurrentBPM
Current BPM estimate (smoothed)
float getAverageIBI() const
Get inter-beat interval (IBI) statistics.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References getAverageIBI(), fl::max(), mConfig, mCurrentBPM, mIBIHistory, and fl::min().

Referenced by processSample().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: