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

◆ begin()

void animartrix_ring::SoundOrchestrator::begin ( )

Wire up audio callbacks (downbeat/kick/snare).

Call once after the Processor is created. Safe to call multiple times – last call wins because the Processor stores a single callback per event.

Definition at line 62 of file sound_orchestrator.cpp.

62 {
63 if (!mProcessor) return;
64
65 // Capture event-style audio cues for BpmLocked state.
66 // The Processor stores a single callback per event; we install closures
67 // that mark "last seen at" timestamps which the per-frame tick consults.
68 // (We can't capture `this->mLastKickMs` directly by reference in a
69 // function<void()> stored by Processor across callback re-registration
70 // without UAF risk, so we route through `this`.)
71 SoundOrchestrator *self = this;
72 mProcessor->onKick([self]() {
73 self->mLastKickMs = fl::millis();
74 });
75 mProcessor->onSnare([self]() {
76 self->mLastSnareMs = fl::millis();
77 });
78 mProcessor->onDownbeat([self]() {
79 self->mLastDownbeatMs = fl::millis();
80 self->mDownbeatCount++;
81 });
82}
SoundOrchestrator(fl::shared_ptr< fl::audio::Processor > processor, fl::shared_ptr< fl::Animartrix > animartrix, fl::FxEngine *engine)
fl::shared_ptr< fl::audio::Processor > mProcessor
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.

References SoundOrchestrator(), mDownbeatCount, fl::millis(), mLastDownbeatMs, mLastKickMs, mLastSnareMs, and mProcessor.

+ Here is the call graph for this function: