Add CC (Control Change) handling for Loopy Pro LED control
This commit is contained in:
+31
-1
@@ -43,7 +43,7 @@ void AppTask::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AppTask::process_midi_event(const MidiEvent& event) {
|
void AppTask::process_midi_event(const MidiEvent& event) {
|
||||||
Serial.printf("[APP] MIDI IN: Type=%d Ch=%d Note=%d Vel=%d\n",
|
Serial.printf("[APP] MIDI IN: Type=%d Ch=%d Data1=%d Data2=%d\n",
|
||||||
event.type, event.channel, event.data1, event.data2);
|
event.type, event.channel, event.data1, event.data2);
|
||||||
|
|
||||||
uint8_t led_index = 0xFF;
|
uint8_t led_index = 0xFF;
|
||||||
@@ -51,6 +51,8 @@ void AppTask::process_midi_event(const MidiEvent& event) {
|
|||||||
uint8_t midi_note = event.data1;
|
uint8_t midi_note = event.data1;
|
||||||
uint8_t midi_velocity = event.data2;
|
uint8_t midi_velocity = event.data2;
|
||||||
|
|
||||||
|
// Handle NOTE_ON/NOTE_OFF for LED control (Launchpad standard)
|
||||||
|
if (event.type == MidiEvent::NOTE_ON || event.type == MidiEvent::NOTE_OFF) {
|
||||||
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
if (pad_mapping[i].midi_channel == midi_channel &&
|
if (pad_mapping[i].midi_channel == midi_channel &&
|
||||||
pad_mapping[i].midi_note == midi_note) {
|
pad_mapping[i].midi_note == midi_note) {
|
||||||
@@ -72,6 +74,34 @@ void AppTask::process_midi_event(const MidiEvent& event) {
|
|||||||
Serial.printf("[APP] MIDI Ch%d Note%d Vel%d - no LED mapping\n",
|
Serial.printf("[APP] MIDI Ch%d Note%d Vel%d - no LED mapping\n",
|
||||||
midi_channel, midi_note, midi_velocity);
|
midi_channel, midi_note, midi_velocity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Handle CC for LED control (Loopy Pro uses CC)
|
||||||
|
else if (event.type == MidiEvent::CONTROL_CHANGE) {
|
||||||
|
uint8_t cc_num = event.data1;
|
||||||
|
uint8_t cc_val = event.data2;
|
||||||
|
|
||||||
|
// Map CC number to pad index (CC 0-9 for pads 0-9, or CC 36-45 for notes 36-45)
|
||||||
|
// Try both mappings
|
||||||
|
if (cc_num < NUM_PADS) {
|
||||||
|
led_index = cc_num; // CC 0-9
|
||||||
|
} else if (cc_num >= 36 && cc_num < 36 + NUM_PADS) {
|
||||||
|
led_index = cc_num - 36; // CC 36-45
|
||||||
|
}
|
||||||
|
|
||||||
|
if (led_index < NUM_PADS) {
|
||||||
|
led_driver->set_led_state(
|
||||||
|
pad_mapping[led_index].midi_note,
|
||||||
|
pad_mapping[led_index].midi_channel,
|
||||||
|
cc_val // CC value = velocity/color
|
||||||
|
);
|
||||||
|
|
||||||
|
Serial.printf("[APP] CC -> LED: Ch%d CC%d Val%d -> LED%d\n",
|
||||||
|
midi_channel, cc_num, cc_val, led_index);
|
||||||
|
} else {
|
||||||
|
Serial.printf("[APP] CC Ch%d CC%d Val%d - no LED mapping\n",
|
||||||
|
midi_channel, cc_num, cc_val);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user