diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-07-24 22:07:43 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-07-24 22:07:43 -0400 |
| commit | 8b94e26d7c3b30cc57d710a11e5651d15e8e3b20 (patch) | |
| tree | 365c257a28cafbb40e1b430db810e2fa4101d7e1 /quantum | |
| parent | 4aa7d2e20627020c74172c0173b6d9700b84ff9b (diff) | |
| download | qmk_firmware-8b94e26d7c3b30cc57d710a11e5651d15e8e3b20.tar.gz qmk_firmware-8b94e26d7c3b30cc57d710a11e5651d15e8e3b20.zip | |
Fixes midi functionality
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/keymap_common.c | 2 | ||||
| -rw-r--r-- | quantum/process_keycode/process_midi.c | 24 |
2 files changed, 13 insertions, 13 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index d0a8312c1..833e5a8f8 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #include "quantum.h" | 30 | #include "quantum.h" |
| 31 | 31 | ||
| 32 | #ifdef MIDI_ENABLE | 32 | #ifdef MIDI_ENABLE |
| 33 | #include "keymap_midi.h" | 33 | #include "process_midi.h" |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | extern keymap_config_t keymap_config; | 36 | extern keymap_config_t keymap_config; |
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 | ||
