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

◆ updatePhase()

void fl::audio::detector::Beat::updatePhase ( u32 timestamp)
private

Definition at line 161 of file beat.cpp.hpp.

161 {
162 if (mBeatInterval == 0) {
163 mPhase = 0.0f;
164 return;
165 }
166
167 u32 timeSinceLastBeat = timestamp - mLastBeatTime;
168 mPhase = static_cast<float>(timeSinceLastBeat) / static_cast<float>(mBeatInterval);
169
170 // Wrap phase to [0, 1) using fmod for proper wrapping
171 // when beats are missed (phase exceeds 1.0)
172 if (mPhase >= 1.0f) {
173 mPhase = fl::fmodf(mPhase, 1.0f);
174 }
175}
float fmodf(float x, float y) FL_NOEXCEPT
Definition math.h:336

References fl::fmodf(), mBeatInterval, mLastBeatTime, and mPhase.

Referenced by update().

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