| 113 | } |
| 114 | |
| 115 | void 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 | |
| 148 | void KeyboardState::HandleNoteOff(uint8_t midi_note, uint8_t /*velocity*/, uint32_t now_ms) { |
| 149 | #ifdef DEBUG_KEYBOARD |
nothing calls this directly
no test coverage detected