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

◆ setup()

void setup ( )

Definition at line 115 of file simple.h.

115 {
116 Serial.begin(115200);
117 // auto screenmap = frameBufferXY.toScreenMap();
118 // screenmap.setDiameter(.2);
119 // FastLED.addLeds<NEOPIXEL, 2>(framebuffer,
120 // NUM_LEDS).setScreenMap(screenmap);
121 auto screenmap = ledsXY.toScreenMap();
122 screenmap.setDiameter(.2);
123
124 decayTimeSeconds.onChanged([](float value) {
125 audioFadeTracker.setDecayTime(value);
126 FL_WARN("Fade time seconds: " << value);
127 });
128 attackTimeSeconds.onChanged([](float value) {
129 audioFadeTracker.setAttackTime(value);
130 FL_WARN("Attack time seconds: " << value);
131 });
132 outputTimeSec.onChanged([](float value) {
133 audioFadeTracker.setOutputTime(value);
134 FL_WARN("Output time seconds: " << value);
135 });
136
137 // Initialize pitch detection
138 pitchConfig.sample_rate_hz = 44100.0f;
139 pitchEngine = new fl::SoundToMIDIEngine(pitchConfig); // ok bare allocation
140 pitchEngine->onNoteOn = [](uint8_t note, uint8_t velocity) {
141 currentMIDINote = note;
142 noteIsOn = true;
143 Serial.print("Note ON: ");
144 Serial.print(note);
145 Serial.print(" vel: ");
146 Serial.println(velocity);
147 };
148 pitchEngine->onNoteOff = [](uint8_t note) {
149 noteIsOn = false;
150 Serial.print("Note OFF: ");
151 Serial.println(note);
152 };
153
154 FastLED.addLeds<NEOPIXEL, PIN_DATA>(leds, ledsXY.getTotal())
155 .setScreenMap(screenmap);
156}
#define PIN_DATA
fl::CRGB leds[NUM_LEDS]
fl::ScreenMap screenmap
fl::MaxFadeTracker audioFadeTracker(attackTimeSeconds.value(), decayTimeSeconds.value(), outputTimeSec.value(), 44100)
fl::UISlider decayTimeSeconds("Fade time Seconds",.1, 0, 4,.02)
fl::UISlider outputTimeSec("outputTimeSec",.17, 0, 2,.01)
fl::UISlider attackTimeSeconds("Attack time Seconds",.1, 0, 4,.02)
fl::XYMap ledsXY(WIDTH/2, HEIGHT/2, IS_SERPINTINE)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::SoundToMIDI pitchConfig
Definition advanced.h:102
uint8_t currentMIDINote
Definition advanced.h:104
bool noteIsOn
Definition advanced.h:106
fl::SoundToMIDIEngine * pitchEngine
Definition advanced.h:103
#define FL_WARN(X)
Definition log.h:276
unsigned char uint8_t
Definition s16x16x4.h:209
#define Serial
Definition serial.h:304

References attackTimeSeconds(), audioFadeTracker(), currentMIDINote, decayTimeSeconds(), FastLED, FL_WARN, leds, ledsXY(), noteIsOn, outputTimeSec(), PIN_DATA, pitchConfig, pitchEngine, screenmap, and Serial.

+ Here is the call graph for this function: