MCPcopy Create free account
hub / github.com/FastLED/FastLED / calculateIntervalScore

Method calculateIntervalScore

src/fl/audio/detector/tempo_analyzer.cpp.hpp:304–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304float TempoAnalyzer::calculateIntervalScore(u32 interval) {
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}
323
324float TempoAnalyzer::calculateTempoConfidence(const TempoHypothesis& hyp) {
325 // Confidence based on:

Callers 2

FL_TEST_FILEFunction · 0.80
tempo_analyzer.hppFile · 0.80

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected