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

◆ calculateIntervalScore()

float fl::audio::detector::TempoAnalyzer::calculateIntervalScore ( u32 interval)

Definition at line 304 of file tempo_analyzer.cpp.hpp.

304 {
305 float bpm = 60000.0f / static_cast<float>(interval);
306
307 // All BPM values within the valid range score equally
308 if (bpm >= mMinBPM && bpm <= mMaxBPM) {
309 return 1.0f;
310 }
311
312 // Outside the range, penalize based on distance from nearest boundary
313 float distOutside;
314 if (bpm < mMinBPM) {
315 distOutside = mMinBPM - bpm;
316 } else {
317 distOutside = bpm - mMaxBPM;
318 }
319 float range = mMaxBPM - mMinBPM;
320 float normalizedDist = distOutside / range;
321 return fl::max(0.1f, 1.0f - normalizedDist);
322}
void bpm()
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References bpm(), fl::max(), mMaxBPM, and mMinBPM.

Referenced by updateHypotheses().

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