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

◆ updateMeasurePhase()

void fl::audio::detector::Downbeat::updateMeasurePhase ( u32 timestamp)
private

Definition at line 378 of file downbeat.cpp.hpp.

378 {
379 if (mLastDownbeatTime == 0) {
380 mMeasurePhase = 0.0f;
381 return;
382 }
383
384 u32 timeSinceDownbeat = timestamp - mLastDownbeatTime;
385 float beatInterval = mBeatDetector->getBPM() > 0.0f
386 ? (60000.0f / mBeatDetector->getBPM())
387 : 500.0f;
388 float measureDuration = beatInterval * static_cast<float>(mBeatsPerMeasure);
389
390 if (measureDuration > 0.0f) {
391 mMeasurePhase = static_cast<float>(timeSinceDownbeat) / measureDuration;
392
393 // Wrap phase to [0, 1)
394 while (mMeasurePhase >= 1.0f) {
395 mMeasurePhase -= 1.0f;
396 }
397 } else {
398 mMeasurePhase = 0.0f;
399 }
400}
shared_ptr< Beat > mBeatDetector
Definition downbeat.h:104

References mBeatDetector, mBeatsPerMeasure, mLastDownbeatTime, and mMeasurePhase.

Referenced by update().

+ Here is the caller graph for this function: