FastLED 3.9.15
Loading...
Searching...
No Matches
audio_reactive.cpp
Go to the documentation of this file.
1// audio_reactive.cpp
2#include "audio_reactive.h"
4
6 auto input = audio.audioInput();
7 if (input) {
8 processor = FastLED.add(input);
9 autoPump = true;
10 }
11 if (!processor) {
13 }
14}
15
17 fl::UICheckbox &enableVibe,
18 fl::UISlider &speedMultiplier,
19 fl::UISlider &baseSpeed,
21 processor->onVibeLevels(
22 [&fxEngine, &enableVibe, &speedMultiplier, &baseSpeed,
24 if (enableVibe.value()) {
25 float bassBoost = (vibe.bass - 1.0f) * speedMultiplier.value();
26 float speed = baseSpeed.value() + bassBoost;
27 speed *= timeSpeed.value();
28 fxEngine.setSpeed(speed);
29 }
30 });
31}
32
34 if (autoPump)
35 return;
36 fl::audio::Sample sample = audio.next();
37 if (!sample.isValid())
38 return;
40 if (sampleCount == 1) {
41 printf("AnimartrixRing: First audio sample received! "
42 "enableVibeReactive=%d\n",
43 (int)enableVibe.value());
44 } else if (sampleCount % 172 == 0) {
45 printf("AnimartrixRing: %u audio samples processed, "
46 "enableVibeReactive=%d\n",
47 (unsigned)sampleCount, (int)enableVibe.value());
48 }
49 if (enableVibe.value()) {
50 processor->update(sample);
51 }
52}
fl::UIAudio audio("Audio Input")
fl::FxEngine fxEngine(NUM_LEDS)
fl::UISlider timeSpeed("Time Speed", 1, -10, 10,.1)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint16_t speed
Definition Noise.ino:66
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:33
bool value() const FL_NOEXCEPT
Definition checkbox.h:59
float value
Definition slider.h:68
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
void pump(fl::UIAudio &audio, fl::UICheckbox &enableVibe)
void begin(fl::UIAudio &audio)
uint32_t sampleCount
void connectToEngine(fl::FxEngine &fxEngine, fl::UICheckbox &enableVibe, fl::UISlider &speedMultiplier, fl::UISlider &baseSpeed, fl::UISlider &timeSpeed)
fl::shared_ptr< fl::audio::Processor > processor