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

Method HandleNoteOn

examples/LuminescentGrand/shared/Keyboard.cpp:115–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void KeyboardState::HandleNoteOn(uint8_t midi_note, uint8_t velocity, int color_selector_value, uint32_t now_ms) {
116 if (0 == velocity) {
117 // Some keyboards signify "NoteOff" with a velocity of zero.
118 HandleNoteOff(midi_note, velocity, now_ms);
119 return;
120 }
121
122#ifdef DEBUG_KEYBOARD
123 dprint("HandleNoteOn:");
124
125 dprint("midi_note = ");
126 dprint(midi_note);
127
128 dprint(", velocity = ");
129 dprintln(velocity);
130 #endif
131
132 float brightness = ToBrightness(velocity);
133
134 dprint("brightness: "); dprintln(brightness);
135
136 ColorHSV pixel_color_hsv = SelectColor(midi_note, brightness,
137 color_selector_value);
138
139 // TODO: Give a key access to the Keyboard owner, therefore it could inspect the
140 // sustained variable instead of passing it here.
141 Key* key = GetKey(midi_note);
142
143 dprint("key indx: "); dprintln(key->mIdx);
144
145 key->SetOn(velocity, pixel_color_hsv, now_ms);
146}
147
148void KeyboardState::HandleNoteOff(uint8_t midi_note, uint8_t /*velocity*/, uint32_t now_ms) {
149#ifdef DEBUG_KEYBOARD

Callers

nothing calls this directly

Calls 3

ToBrightnessFunction · 0.85
SelectColorFunction · 0.85
SetOnMethod · 0.80

Tested by

no test coverage detected