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

Method updatePhase

src/fl/audio/detector/beat.cpp.hpp:161–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void Beat::updatePhase(u32 timestamp) {
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}
176
177void Beat::fireCallbacks() {
178 if (mBeatDetected) {

Callers

nothing calls this directly

Calls 1

fmodfFunction · 0.85

Tested by

no test coverage detected