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

◆ setup()

void setup ( )

Definition at line 457 of file advanced.h.

457 {
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}
#define COLOR_ORDER
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define LED_PIN
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
#define WIDTH
#define LED_TYPE
#define SAMPLE_RATE
fl::SoundToMIDI pitchConfig
Definition advanced.h:102
uint8_t currentMIDINote
Definition advanced.h:104
uint8_t currentVelocity
Definition advanced.h:105
#define HEIGHT
bool noteIsOn
Definition advanced.h:106
fl::SoundToMIDIEngine * pitchEngine
Definition advanced.h:103
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98
unsigned char uint8_t
Definition s16x16x4.h:209
#define Serial
Definition serial.h:304

References brightness, COLOR_ORDER, currentMIDINote, currentVelocity, FastLED, HEIGHT, LED_PIN, LED_TYPE, leds, noteIsOn, NUM_LEDS, pitchConfig, pitchEngine, SAMPLE_RATE, Serial, and WIDTH.