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

Function setup

examples/Audio/advanced/advanced.h:457–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
469 FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_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

Callers

nothing calls this directly

Calls 9

delayFunction · 0.50
beginMethod · 0.45
printlnMethod · 0.45
printMethod · 0.45
setBrightnessMethod · 0.45
as_intMethod · 0.45
clearMethod · 0.45
showMethod · 0.45
onChangedMethod · 0.45

Tested by

no test coverage detected