Skip to content

Commit

Permalink
add support for pedal cc messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Young committed Feb 20, 2017
1 parent f67aefc commit 7c5e510
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
61 changes: 51 additions & 10 deletions quantum/process_keycode/process_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,43 +62,84 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
return false;
}
case MIDI_OCTAVE_MIN ... MIDI_OCTAVE_MAX:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.octave = keycode - MIDI_OCTAVE_MIN;
dprintf("midi octave %d\n", midi_config.octave);
}
return false;
case MI_OCTD:
if (record->event.pressed && midi_config.octave > 0)
if (record->event.pressed && midi_config.octave > 0) {
midi_config.octave--;
dprintf("midi octave %d\n", midi_config.octave);
}
return false;
case MI_OCTU:
if (record->event.pressed && midi_config.octave < (MIDI_OCTAVE_MAX - MIDI_OCTAVE_MIN))
if (record->event.pressed && midi_config.octave < (MIDI_OCTAVE_MAX - MIDI_OCTAVE_MIN)) {
midi_config.octave++;
dprintf("midi octave %d\n", midi_config.octave);
}
return false;
case MIDI_VELOCITY_MIN ... MIDI_VELOCITY_MAX:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.velocity = keycode - MIDI_VELOCITY_MIN;
dprintf("midi velocity %d\n", midi_config.velocity);
}
return false;
case MI_VELD:
if (record->event.pressed && midi_config.velocity > 0)
if (record->event.pressed && midi_config.velocity > 0) {
midi_config.velocity--;
dprintf("midi velocity %d\n", midi_config.velocity);
}
return false;
case MI_VELU:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.velocity++;
dprintf("midi velocity %d\n", midi_config.velocity);
}
return false;
case MIDI_CHANNEL_MIN ... MIDI_CHANNEL_MAX:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.channel = keycode - MIDI_CHANNEL_MIN;
dprintf("midi channel %d\n", midi_config.channel);
}
return false;
case MI_CHD:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.channel--;
dprintf("midi channel %d\n", midi_config.channel);
}
return false;
case MI_CHU:
if (record->event.pressed)
if (record->event.pressed) {
midi_config.channel++;
dprintf("midi channel %d\n", midi_config.channel);
}
return false;
case MI_OFF:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 0x7B, 0);
dprintf("midi off\n");
}
return false;
case MI_SUS:
//TODO
midi_send_cc(&midi_device, midi_config.channel, 0x40, record->event.pressed ? 127 : 0);
dprintf("midi sustain %d\n", record->event.pressed);
return false;
case MI_PORT:
midi_send_cc(&midi_device, midi_config.channel, 0x41, record->event.pressed ? 127 : 0);
dprintf("midi portamento %d\n", record->event.pressed);
return false;
case MI_SOST:
midi_send_cc(&midi_device, midi_config.channel, 0x42, record->event.pressed ? 127 : 0);
dprintf("midi sostenuto %d\n", record->event.pressed);
return false;
case MI_SOFT:
midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0);
dprintf("midi soft %d\n", record->event.pressed);
return false;
case MI_LEG:
midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0);
dprintf("midi legato %d\n", record->event.pressed);
return false;
};

Expand Down
11 changes: 6 additions & 5 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ enum quantum_keycodes {

#ifdef MIDI_ENABLE
// Midi
MIDI_ON,
MIDI_OFF,

MIDI_TONE_MIN,

Expand Down Expand Up @@ -221,7 +219,13 @@ enum quantum_keycodes {
MI_CHD, // previous channel
MI_CHU, // next channel

MI_OFF, // all notes off

MI_SUS, // sustain
MI_PORT, // portamento
MI_SOST, // sostenuto
MI_SOFT, // soft
MI_LEG, // legato
#endif

// Backlight functionality
Expand Down Expand Up @@ -394,9 +398,6 @@ enum quantum_keycodes {
#define BL_ON BL_9
#define BL_OFF BL_0

#define MI_ON MIDI_ON
#define MI_OFF MIDI_OFF

// GOTO layer - 16 layers max
// when:
// ON_PRESS = 1
Expand Down

0 comments on commit 7c5e510

Please sign in to comment.