FastLED 3.9.15
Loading...
Searching...
No Matches
advanced.h
Go to the documentation of this file.
1
4
5#include <Arduino.h>
6#include <FastLED.h>
7
8
9
10#include "fl/ui/ui.h"
11#include "fl/audio/audio.h"
12#include "fl/fft.h"
13#include "fl/math/xymap.h"
14#include "fl/math/math.h"
15#include "fl/math/math.h"
16
18
19// This is used by fastled because we have extremely strict compiler settings.
20// Stock Arduino/Platformio does not need these.
22FL_DISABLE_WARNING(float-conversion)
23FL_DISABLE_WARNING(sign-conversion)
24
25// Display configuration
26// For WebAssembly, use a smaller display to avoid memory issues
27#ifdef __EMSCRIPTEN__
28#define WIDTH 32
29#define HEIGHT 32
30#else
31#define WIDTH 64
32#define HEIGHT 64
33#endif
34#define NUM_LEDS (WIDTH * HEIGHT)
35#define LED_PIN 3
36#define LED_TYPE WS2812B
37#define COLOR_ORDER GRB
38
39// Audio configuration
40#define SAMPLE_RATE 44100
41#define FFT_SIZE 512
42
43// UI Elements
44fl::UITitle title("Audio Reactive Visualizations");
45fl::UIDescription description("Real-time audio visualizations with beat detection and multiple modes");
46
47// Master controls
48fl::UICheckbox enableAudio("Enable Audio", true);
49fl::UIDropdown visualMode("Visualization Mode",
50 {"Spectrum Bars", "Radial Spectrum", "Waveform", "VU Meter", "Matrix Rain", "Fire Effect", "Plasma Wave"});
51
52// Audio controls
53fl::UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f);
54fl::UISlider noiseFloor("Noise Floor", 0.1f, 0.0f, 1.0f, 0.01f);
55fl::UICheckbox autoGain("Auto Gain", true);
56
57// Visual controls
58fl::UISlider brightness("Brightness", 128, 0, 255, 1);
59fl::UISlider fadeSpeed("Fade Speed", 20, 0, 255, 1);
61 {"Rainbow", "Heat", "Ocean", "Forest", "Party", "Lava", "Cloud"});
62fl::UICheckbox mirrorMode("Mirror Mode", false);
63
64// Beat detection
65fl::UICheckbox beatDetect("Beat Detection", true);
66fl::UISlider beatSensitivity("Beat Sensitivity", 1.5f, 0.5f, 3.0f, 0.1f);
67fl::UICheckbox beatFlash("Beat Flash", true);
68
69// Pitch detection
70fl::UICheckbox pitchDetectEnable("Pitch Detection", false);
71fl::UICheckbox pitchVisualizer("Show Pitch Visualizer", false);
72
73// Audio input
74fl::UIAudio audio("Audio Input");
75
76// Global variables
80
81// Audio processing variables - keep these smaller for WebAssembly
82static const int NUM_BANDS = 16; // Reduced from 32
83float fftSmooth[NUM_BANDS] = {0};
84float beatHistory[20] = {0}; // Reduced from 43
86float beatAverage = 0;
87float beatVariance = 0;
88uint32_t lastBeatTime = 0;
89bool isBeat = false;
90float autoGainValue = 1.0f;
91float peakLevel = 0;
92
93// Visual effect variables
94uint8_t hue = 0;
95// Remove large static arrays for WebAssembly
96#ifndef __EMSCRIPTEN__
97float plasma[WIDTH][HEIGHT] = {{0}};
98uint8_t fireBuffer[WIDTH][HEIGHT] = {{0}};
99#endif
100
101// Pitch detection engine
102fl::SoundToMIDI pitchConfig;
103fl::SoundToMIDIEngine* pitchEngine = nullptr;
104uint8_t currentMIDINote = 0;
105uint8_t currentVelocity = 0;
106bool noteIsOn = false;
107
108// Get current color palette
109fl::CRGBPalette16 getCurrentPalette() {
110 switch(colorPalette.as_int()) {
111 case 0: return fl::CRGBPalette16(fl::RainbowColors_p);
112 case 1: return fl::CRGBPalette16(fl::HeatColors_p);
113 case 2: return fl::CRGBPalette16(fl::OceanColors_p);
114 case 3: return fl::CRGBPalette16(fl::ForestColors_p);
115 case 4: return fl::CRGBPalette16(fl::PartyColors_p);
116 case 5: return fl::CRGBPalette16(fl::LavaColors_p);
117 case 6: return fl::CRGBPalette16(fl::CloudColors_p);
118 default: return fl::CRGBPalette16(fl::RainbowColors_p);
119 }
120}
121
122// Beat detection algorithm
123bool detectBeat(float energy) {
126
127 // Calculate average
128 beatAverage = 0;
129 for (int i = 0; i < 20; i++) {
131 }
132 beatAverage /= 20.0f;
133
134 // Calculate variance
135 beatVariance = 0;
136 for (int i = 0; i < 20; i++) {
137 float diff = beatHistory[i] - beatAverage;
138 beatVariance += diff * diff;
139 }
140 beatVariance /= 20.0f;
141
142 // Detect beat
143 float threshold = beatAverage + (beatSensitivity.value() * fl::sqrt(beatVariance));
144 uint32_t currentTime = millis();
145
146 if (energy > threshold && (currentTime - lastBeatTime) > 80) {
147 lastBeatTime = currentTime;
148 return true;
149 }
150 return false;
151}
152
153// Update auto gain
154void updateAutoGain(float level) {
155 if (!autoGain) {
156 autoGainValue = 1.0f;
157 return;
158 }
159
160 static float targetLevel = 0.7f;
161 static float avgLevel = 0.0f;
162
163 avgLevel = avgLevel * 0.95f + level * 0.05f;
164
165 if (avgLevel > 0.01f) {
166 float gainAdjust = targetLevel / avgLevel;
167 gainAdjust = fl::clamp(gainAdjust, 0.5f, 2.0f);
168 autoGainValue = autoGainValue * 0.9f + gainAdjust * 0.1f;
169 }
170}
171
172// Clear display
174 if (fadeSpeed.as_int() == 0) {
176 } else {
178 }
179}
180
181// Visualization: Spectrum Bars
182void drawSpectrumBars(fl::audio::fft::Bins* fft, float /* peak */) {
183 clearDisplay();
184 fl::CRGBPalette16 palette = getCurrentPalette();
185
186 int barWidth = WIDTH / NUM_BANDS;
187
188 auto bands = fft->db();
189
190 for (size_t band = 0; band < NUM_BANDS && band < bands.size(); band++) {
191 float magnitude = bands[band];
192
193 // Apply noise floor
194 magnitude = magnitude / 100.0f; // Normalize from dB
195 magnitude = fl::max(0.0f, magnitude - noiseFloor.value());
196
197 // Smooth the FFT
198 fftSmooth[band] = fftSmooth[band] * 0.8f + magnitude * 0.2f;
199 magnitude = fftSmooth[band];
200
201 // Apply gain
202 magnitude *= audioGain.value() * autoGainValue;
203 magnitude = fl::clamp(magnitude, 0.0f, 1.0f);
204
205 int barHeight = magnitude * HEIGHT;
206 int xStart = band * barWidth;
207
208 for (int x = 0; x < fl::max(barWidth, 1); x++) {
209 for (int y = 0; y < barHeight; y++) {
210 uint8_t colorIndex = fl::map_range<float, uint8_t>(
211 float(y) / HEIGHT, 0, 1, 0, 255
212 );
213 fl::CRGB color = ColorFromPalette(palette, colorIndex + hue);
214
215 int ledIndex = xyMap(xStart + x, y);
216 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
217 leds[ledIndex] = color;
218 }
219
220 if (mirrorMode) {
221 int mirrorIndex = xyMap(WIDTH - 1 - (xStart + x), y);
222 if (mirrorIndex >= 0 && mirrorIndex < NUM_LEDS) {
223 leds[mirrorIndex] = color;
224 }
225 }
226 }
227 }
228 }
229}
230
231// Visualization: Radial Spectrum
233 clearDisplay();
234 fl::CRGBPalette16 palette = getCurrentPalette();
235
236 int centerX = WIDTH / 2;
237 int centerY = HEIGHT / 2;
238
239 auto bands = fft->db();
240
241 for (size_t angle = 0; angle < 360; angle += 6) { // Reduced resolution
242 size_t band = (angle / 6) % NUM_BANDS;
243 if (band >= bands.size()) continue;
244
245 float magnitude = bands[band] / 100.0f;
246 magnitude = fl::max(0.0f, magnitude - noiseFloor.value());
247 magnitude *= audioGain.value() * autoGainValue;
248 magnitude = fl::clamp(magnitude, 0.0f, 1.0f);
249
250 int radius = magnitude * (fl::min(WIDTH, HEIGHT) / 2);
251
252 for (int r = 0; r < radius; r++) {
253 int x = centerX + (r * fl::cosf(angle * FL_PI / 180.0f));
254 int y = centerY + (r * fl::sinf(angle * FL_PI / 180.0f));
255
256 if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) {
257 uint8_t colorIndex = fl::map_range<int, uint8_t>(r, 0, radius, 255, 0);
258 int ledIndex = xyMap(x, y);
259 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
260 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
261 }
262 }
263 }
264 }
265}
266
267// Visualization: Logarithmic Waveform (prevents saturation)
268void drawWaveform(const fl::span<const int16_t>& pcm, float /* peak */) {
269 clearDisplay();
270 fl::CRGBPalette16 palette = getCurrentPalette();
271
272 int samplesPerPixel = pcm.size() / WIDTH;
273 int centerY = HEIGHT / 2;
274
275 for (size_t x = 0; x < WIDTH; x++) {
276 size_t sampleIndex = x * samplesPerPixel;
277 if (sampleIndex >= pcm.size()) break;
278
279 // Get the raw sample value
280 float sample = float(pcm[sampleIndex]) / 32768.0f; // Normalize to -1.0 to 1.0
281
282 // Apply logarithmic scaling to prevent saturation
283 float absSample = fl::fabsf(sample);
284 float logAmplitude = 0.0f;
285
286 if (absSample > 0.001f) { // Avoid log(0)
287 // Logarithmic compression: log10(1 + gain * sample)
288 float scaledSample = absSample * audioGain.value() * autoGainValue;
289 logAmplitude = fl::log10f(1.0f + scaledSample * 9.0f) / fl::log10f(10.0f); // Normalize to 0-1
290 }
291
292 // Apply smooth sensitivity curve
293 logAmplitude = fl::powf(logAmplitude, 0.7f); // Gamma correction for better visual response
294
295 // Calculate amplitude in pixels
296 int amplitude = int(logAmplitude * (HEIGHT / 2));
297 amplitude = fl::clamp(amplitude, 0, HEIGHT / 2);
298
299 // Preserve the sign for proper waveform display
300 if (sample < 0) amplitude = -amplitude;
301
302 // Color mapping based on amplitude intensity
303 uint8_t colorIndex = fl::map_range<int, uint8_t>(abs(amplitude), 0, HEIGHT/2, 40, 255);
304 fl::CRGB color = ColorFromPalette(palette, colorIndex + hue);
305
306 // Apply brightness scaling for low amplitudes
307 if (abs(amplitude) < HEIGHT / 4) {
308 color.fadeToBlackBy(128 - (abs(amplitude) * 512 / HEIGHT));
309 }
310
311 // Draw vertical line from center
312 if (amplitude == 0) {
313 // Draw center point for zero amplitude
314 int ledIndex = xyMap(x, centerY);
315 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
316 leds[ledIndex] = color.fadeToBlackBy(200);
317 }
318 } else {
319 // Draw line from center to amplitude
320 int startY = (amplitude > 0) ? centerY : centerY + amplitude;
321 int endY = (amplitude > 0) ? centerY + amplitude : centerY;
322
323 for (int y = startY; y <= endY; y++) {
324 if (y >= 0 && y < HEIGHT) {
325 int ledIndex = xyMap(x, y);
326 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
327 // Fade edges for smoother appearance
328 fl::CRGB pixelColor = color;
329 if (y == startY || y == endY) {
330 pixelColor.fadeToBlackBy(100);
331 }
332 leds[ledIndex] = pixelColor;
333 }
334 }
335 }
336 }
337 }
338}
339
340// Visualization: VU Meter
341void drawVUMeter(float rms, float peak) {
342 clearDisplay();
343 fl::CRGBPalette16 palette = getCurrentPalette();
344
345 // RMS level bar
346 int rmsWidth = rms * WIDTH * audioGain.value() * autoGainValue;
347 rmsWidth = fl::min(rmsWidth, WIDTH);
348
349 for (int x = 0; x < rmsWidth; x++) {
350 for (int y = HEIGHT/3; y < 2*HEIGHT/3; y++) {
351 uint8_t colorIndex = fl::map_range<int, uint8_t>(x, 0, WIDTH, 0, 255);
352 int ledIndex = xyMap(x, y);
353 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
354 leds[ledIndex] = ColorFromPalette(palette, colorIndex);
355 }
356 }
357 }
358
359 // Peak indicator
360 int peakX = peak * WIDTH * audioGain.value() * autoGainValue;
361 peakX = fl::min(peakX, WIDTH - 1);
362
363 for (int y = HEIGHT/4; y < 3*HEIGHT/4; y++) {
364 int ledIndex = xyMap(peakX, y);
365 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
366 leds[ledIndex] = fl::CRGB::White;
367 }
368 }
369
370 // Beat indicator
371 if (isBeat && beatFlash) {
372 for (int x = 0; x < WIDTH; x++) {
373 int ledIndex1 = xyMap(x, 0);
374 int ledIndex2 = xyMap(x, HEIGHT - 1);
375 if (ledIndex1 >= 0 && ledIndex1 < NUM_LEDS) leds[ledIndex1] = fl::CRGB::White;
376 if (ledIndex2 >= 0 && ledIndex2 < NUM_LEDS) leds[ledIndex2] = fl::CRGB::White;
377 }
378 }
379}
380
381// Visualization: Matrix Rain
382void drawMatrixRain(float peak) {
383 // Shift everything down
384 for (int x = 0; x < WIDTH; x++) {
385 for (int y = HEIGHT - 1; y > 0; y--) {
386 int currentIndex = xyMap(x, y);
387 int aboveIndex = xyMap(x, y - 1);
388 if (currentIndex >= 0 && currentIndex < NUM_LEDS &&
389 aboveIndex >= 0 && aboveIndex < NUM_LEDS) {
390 leds[currentIndex] = leds[aboveIndex];
391 leds[currentIndex].fadeToBlackBy(40);
392 }
393 }
394 }
395
396 // Add new drops based on audio
397 int numDrops = peak * WIDTH * audioGain.value() * autoGainValue;
398 for (int i = 0; i < numDrops; i++) {
399 int x = random(WIDTH);
400 int ledIndex = xyMap(x, 0);
401 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
402 leds[ledIndex] = CHSV(96, 255, 255); // Green
403 }
404 }
405}
406
407// Visualization: Fire Effect (simplified for WebAssembly)
408void drawFireEffect(float peak) {
409 // Simple fire effect without buffer
410 clearDisplay();
411
412 // Add heat at bottom based on audio
413 int heat = 100 + (peak * 155 * audioGain.value() * autoGainValue);
414 heat = fl::min(heat, 255);
415
416 for (int x = 0; x < WIDTH; x++) {
417 for (int y = 0; y < HEIGHT; y++) {
418 // Simple gradient from bottom to top
419 int heatLevel = heat * (HEIGHT - y) / HEIGHT;
420 heatLevel = heatLevel * random(80, 120) / 100; // Add randomness
421 heatLevel = fl::min(heatLevel, 255);
422
423 int ledIndex = xyMap(x, y);
424 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
425 leds[ledIndex] = HeatColor(heatLevel);
426 }
427 }
428 }
429}
430
431// Visualization: Plasma Wave
432void drawPlasmaWave(float peak) {
433 static float time = 0; // okay static in header
434 time += 0.05f + (peak * 0.2f);
435
436 fl::CRGBPalette16 palette = getCurrentPalette();
437
438 for (int x = 0; x < WIDTH; x++) {
439 for (int y = 0; y < HEIGHT; y++) {
440 float value = fl::sinf(x * 0.1f + time) +
441 fl::sinf(y * 0.1f - time) +
442 fl::sinf((x + y) * 0.1f + time) +
443 fl::sinf(fl::sqrtf(x * x + y * y) * 0.1f - time);
444
445 value = (value + 4) / 8; // Normalize to 0-1
446 value *= audioGain.value() * autoGainValue;
447
448 uint8_t colorIndex = value * 255;
449 int ledIndex = xyMap(x, y);
450 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
451 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
452 }
453 }
454 }
455}
456
457void setup() {
458 Serial.begin(115200);
459 delay(1000);
460
461 Serial.println("Audio Reactive Visualizations");
462 Serial.println("Initializing...");
463 Serial.print("Display size: ");
464 Serial.print(WIDTH);
465 Serial.print("x");
466 Serial.println(HEIGHT);
467
468 // Initialize LEDs
470 FastLED.setBrightness(brightness.as_int());
471 FastLED.clear();
472 FastLED.show();
473
474 // Set up UI callbacks
475 brightness.onChanged([](float value) {
476 FastLED.setBrightness(value);
477 });
478
479 // Initialize pitch detection
480 pitchConfig.sample_rate_hz = SAMPLE_RATE;
481 pitchEngine = new fl::SoundToMIDIEngine(pitchConfig); // ok bare allocation
482 pitchEngine->onNoteOn = [](uint8_t note, uint8_t velocity) {
483 currentMIDINote = note;
484 currentVelocity = velocity;
485 noteIsOn = true;
486 Serial.print("Note ON: ");
487 Serial.print(note);
488 Serial.print(" (vel: ");
489 Serial.print(velocity);
490 Serial.println(")");
491 };
492 pitchEngine->onNoteOff = [](uint8_t note) {
493 noteIsOn = false;
494 Serial.print("Note OFF: ");
495 Serial.println(note);
496 };
497
498 Serial.println("Setup complete!");
499}
500
501void loop() {
502 // Check if audio is enabled
503 if (!enableAudio) {
504 // Show a simple test pattern
506 FastLED.show();
507 delay(20);
508 return;
509 }
510
511 // Process only one audio sample per frame to avoid accumulation
512 fl::audio::Sample sample = audio.next();
513 if (sample.isValid()) {
514 // Process pitch detection if enabled
516 // Convert int16_t samples to float for pitch detection
517 static float floatBuffer[FFT_SIZE];
518 size_t numSamples = fl::min(sample.pcm().size(), (size_t)FFT_SIZE);
519 for (size_t i = 0; i < numSamples; i++) {
520 floatBuffer[i] = sample.pcm()[i] / 32768.0f;
521 }
522 pitchEngine->processFrame(floatBuffer, numSamples);
523 }
524
525 // Update sound meter
526 soundMeter.processBlock(sample.pcm());
527
528 // Get audio levels
529 float rms = sample.rms() / 32768.0f;
530
531 // Calculate peak
532 int32_t maxSample = 0;
533 for (size_t i = 0; i < sample.pcm().size(); i++) {
534 int32_t absSample = fl::fabsf(sample.pcm()[i]);
535 if (absSample > maxSample) {
536 maxSample = absSample;
537 }
538 }
539 float peak = float(maxSample) / 32768.0f;
540 peakLevel = peakLevel * 0.9f + peak * 0.1f; // Smooth peak
541
542 // Update auto gain
544
545 // Beat detection
546 if (beatDetect) {
547 isBeat = detectBeat(peak);
548 }
549
550 // Get FFT data - create local Bins to avoid accumulation
552 sample.fft(&fftBins);
553
554 // Update color animation
555 hue += 1;
556
557 // Apply beat flash
558 if (isBeat && beatFlash) {
559 for (int i = 0; i < NUM_LEDS; i++) {
560 leds[i].fadeLightBy(-50); // Make brighter
561 }
562 }
563
564 // Draw selected visualization
565 switch (visualMode.as_int()) {
566 case 0: // Spectrum Bars
567 drawSpectrumBars(&fftBins, peakLevel);
568 break;
569
570 case 1: // Radial Spectrum
571 drawRadialSpectrum(&fftBins, peakLevel);
572 break;
573
574 case 2: // Waveform
575 drawWaveform(sample.pcm(), peakLevel);
576 break;
577
578 case 3: // VU Meter
580 break;
581
582 case 4: // Matrix Rain
584 break;
585
586 case 5: // Fire Effect
588 break;
589
590 case 6: // Plasma Wave
592 break;
593 }
594
595 // Add pitch visualizer overlay if enabled
597 // Display pitch as a horizontal line at a specific height
598 int noteY = HEIGHT - 4; // Near the top
599
600 // Map MIDI note to X position (common singing range: 40-88)
601 float notePos = fl::map_range<float, float>(currentMIDINote, 40.0f, 88.0f, 0.0f, 1.0f);
602 notePos = fl::clamp(notePos, 0.0f, 1.0f);
603 int noteX = notePos * (WIDTH - 1);
604
605 // Draw pitch indicator - brightness based on velocity
607 fl::CRGB pitchColor = fl::CRGB(255, 0, 255); // Magenta
608 pitchColor.fadeToBlackBy(255 - brightness);
609
610 // Draw a small cross at the pitch position
611 for (int dx = -2; dx <= 2; dx++) {
612 int x = noteX + dx;
613 if (x >= 0 && x < WIDTH) {
614 int ledIndex = xyMap(x, noteY);
615 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
616 leds[ledIndex] = pitchColor;
617 }
618 }
619 }
620 for (int dy = -2; dy <= 2; dy++) {
621 int y = noteY + dy;
622 if (y >= 0 && y < HEIGHT) {
623 int ledIndex = xyMap(noteX, y);
624 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
625 leds[ledIndex] = pitchColor;
626 }
627 }
628 }
629 }
630 }
631
632 FastLED.show();
633
634 // Add a small delay to prevent tight loops in WebAssembly
635 #ifdef __EMSCRIPTEN__
636 delay(1);
637 #endif
638}
639
#define COLOR_ORDER
fl::UIAudio audio("Audio Input")
fl::XYMap xyMap
#define NUM_LEDS
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
fl::UITitle title("Animartrix")
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define LED_PIN
int y
Definition simple.h:93
float rms(fl::span< const int16_t > data)
Definition simple.h:104
int x
Definition simple.h:92
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
uint8_t heat[NUM_LEDS]
Definition Fire2023.h:100
UINumberField palette("Palette", 0, 0, 2)
AudioAnalyzeFFT1024 fft
fl::UIDropdown visualMode("Visualization Mode", {"Spectrum Bars", "Radial Spectrum", "Waveform", "VU Meter", "Matrix Rain", "Fire Effect", "Plasma Wave"})
uint32_t lastBeatTime
Definition advanced.h:88
void drawRadialSpectrum(fl::audio::fft::Bins *fft, float)
Definition advanced.h:232
void drawMatrixRain(float peak)
Definition advanced.h:382
bool detectBeat(float energy)
Definition advanced.h:123
bool isBeat
Definition advanced.h:89
#define WIDTH
#define LED_TYPE
fl::CRGBPalette16 getCurrentPalette()
Definition advanced.h:109
static const int NUM_BANDS
Definition advanced.h:82
float fftSmooth[NUM_BANDS]
Definition advanced.h:83
void drawVUMeter(float rms, float peak)
Definition advanced.h:341
#define SAMPLE_RATE
void setup()
Definition advanced.h:457
fl::UISlider fadeSpeed("Fade Speed", 20, 0, 255, 1)
fl::SoundToMIDI pitchConfig
Definition advanced.h:102
uint8_t fireBuffer[WIDTH][HEIGHT]
Definition advanced.h:98
void drawFireEffect(float peak)
Definition advanced.h:408
#define FFT_SIZE
void updateAutoGain(float level)
Definition advanced.h:154
fl::UICheckbox beatDetect("Beat Detection", true)
uint8_t currentMIDINote
Definition advanced.h:104
float peakLevel
Definition advanced.h:91
fl::UICheckbox pitchDetectEnable("Pitch Detection", false)
fl::UISlider noiseFloor("Noise Floor", 0.1f, 0.0f, 1.0f, 0.01f)
fl::UICheckbox pitchVisualizer("Show Pitch Visualizer", false)
float beatAverage
Definition advanced.h:86
float beatVariance
Definition advanced.h:87
fl::UIDropdown colorPalette("Color Palette", {"Rainbow", "Heat", "Ocean", "Forest", "Party", "Lava", "Cloud"})
fl::UICheckbox autoGain("Auto Gain", true)
fl::UICheckbox enableAudio("Enable Audio", true)
uint8_t currentVelocity
Definition advanced.h:105
float autoGainValue
Definition advanced.h:90
fl::UICheckbox mirrorMode("Mirror Mode", false)
fl::UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
int beatHistoryIndex
Definition advanced.h:85
fl::UICheckbox beatFlash("Beat Flash", true)
uint8_t hue
Definition advanced.h:94
float beatHistory[20]
Definition advanced.h:84
void drawSpectrumBars(fl::audio::fft::Bins *fft, float)
Definition advanced.h:182
#define HEIGHT
void drawWaveform(const fl::span< const int16_t > &pcm, float)
Definition advanced.h:268
float plasma[WIDTH][HEIGHT]
Definition advanced.h:97
bool noteIsOn
Definition advanced.h:106
void drawPlasmaWave(float peak)
Definition advanced.h:432
fl::audio::SoundLevelMeter soundMeter(0.0, 0.0)
void clearDisplay()
Definition advanced.h:173
fl::UISlider beatSensitivity("Beat Sensitivity", 1.5f, 0.5f, 3.0f, 0.1f)
fl::SoundToMIDIEngine * pitchEngine
Definition advanced.h:103
void loop()
Definition advanced.h:501
constexpr fl::size size() const FL_NOEXCEPT
Definition span.h:458
void fadeToBlackBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
void fill_rainbow(CRGB *targetArray, int numToFill, fl::u8 initialhue, fl::u8 deltahue=5) FL_NOEXCEPT
Fill a range of LEDs with a rainbow of colors.
Definition fill.cpp.hpp:29
CRGB HeatColor(fl::u8 temperature)
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
fl::hsv8 CHSV
Definition chsv.h:11
#define FL_PI
Definition math.h:26
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
float sqrtf(float value) FL_NOEXCEPT
Definition math.h:453
fl::CRGB CRGB
Definition video.h:15
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
float powf(float base, float exponent) FL_NOEXCEPT
Definition math.h:436
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max) FL_NOEXCEPT
Definition math.h:174
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NOEXCEPT
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
float log10f(float value) FL_NOEXCEPT
Definition math.h:424
float fabsf(float value) FL_NOEXCEPT
Definition math.h:508
float cosf(float value) FL_NOEXCEPT
Definition math.h:358
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
#define FL_DISABLE_WARNING(warning)
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
CRGB & fadeToBlackBy(u8 fadefactor) FL_NOEXCEPT
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.cpp.hpp:111
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:646
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:510
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
#define Serial
Definition serial.h:304
Aggregator header for the fl/ui/ family of per-element UI types.