diff options
Diffstat (limited to 'quantum/process_keycode/process_midi.c')
| -rw-r--r-- | quantum/process_keycode/process_midi.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index d6ab9c626..8784e64f3 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | #include "process_midi.h" | 1 | #include "process_midi.h" |
| 2 | 2 | ||
| 3 | bool midi_activated = false; | 3 | bool midi_activated = false; |
| 4 | uint8_t starting_note = 0x0C; | 4 | uint8_t midi_starting_note = 0x0C; |
| 5 | int offset = 7; | 5 | int midi_offset = 7; |
| 6 | 6 | ||
| 7 | bool process_midi(uint16_t keycode, keyrecord_t *record) { | 7 | bool process_midi(uint16_t keycode, keyrecord_t *record) { |
| 8 | if (keycode == MI_ON && record->event.pressed) { | 8 | if (keycode == MI_ON && record->event.pressed) { |
| @@ -20,42 +20,42 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { | |||
| 20 | if (midi_activated) { | 20 | if (midi_activated) { |
| 21 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | 21 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { |
| 22 | if (record->event.pressed) { | 22 | if (record->event.pressed) { |
| 23 | starting_note++; // Change key | 23 | midi_starting_note++; // Change key |
| 24 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 24 | midi_send_cc(&midi_device, 0, 0x7B, 0); |
| 25 | } | 25 | } |
| 26 | return false; | 26 | return false; |
| 27 | } | 27 | } |
| 28 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | 28 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { |
| 29 | if (record->event.pressed) { | 29 | if (record->event.pressed) { |
| 30 | starting_note--; // Change key | 30 | midi_starting_note--; // Change key |
| 31 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 31 | midi_send_cc(&midi_device, 0, 0x7B, 0); |
| 32 | } | 32 | } |
| 33 | return false; | 33 | return false; |
| 34 | } | 34 | } |
| 35 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | 35 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { |
| 36 | offset++; // Change scale | 36 | midi_offset++; // Change scale |
| 37 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 37 | midi_send_cc(&midi_device, 0, 0x7B, 0); |
| 38 | return false; | 38 | return false; |
| 39 | } | 39 | } |
| 40 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | 40 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { |
| 41 | offset--; // Change scale | 41 | midi_offset--; // Change scale |
| 42 | midi_send_cc(&midi_device, 0, 0x7B, 0); | 42 | midi_send_cc(&midi_device, 0, 0x7B, 0); |
| 43 | return false; | 43 | return false; |
| 44 | } | 44 | } |
| 45 | // basic | 45 | // basic |
| 46 | // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); | 46 | // uint8_t note = (midi_starting_note + SCALE[record->event.key.col + midi_offset])+12*(MATRIX_ROWS - record->event.key.row); |
| 47 | // advanced | 47 | // advanced |
| 48 | // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); | 48 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+12*(MATRIX_ROWS - record->event.key.row); |
| 49 | // guitar | 49 | // guitar |
| 50 | uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); | 50 | uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+5*(MATRIX_ROWS - record->event.key.row); |
| 51 | // violin | 51 | // violin |
| 52 | // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); | 52 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+7*(MATRIX_ROWS - record->event.key.row); |
| 53 | 53 | ||
| 54 | if (record->event.pressed) { | 54 | if (record->event.pressed) { |
| 55 | // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | 55 | // midi_send_noteon(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); |
| 56 | midi_send_noteon(&midi_device, 0, note, 127); | 56 | midi_send_noteon(&midi_device, 0, note, 127); |
| 57 | } else { | 57 | } else { |
| 58 | // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); | 58 | // midi_send_noteoff(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); |
| 59 | midi_send_noteoff(&midi_device, 0, note, 127); | 59 | midi_send_noteoff(&midi_device, 0, note, 127); |
| 60 | } | 60 | } |
| 61 | 61 | ||
