diff options
| author | Gabriel Young <gabeplaysdrums@live.com> | 2017-02-18 03:43:30 -0800 |
|---|---|---|
| committer | Gabriel Young <gabeplaysdrums@live.com> | 2017-02-19 16:42:04 -0800 |
| commit | f67aefc522dd8b72711e7fc5280e1cae1470d1c5 (patch) | |
| tree | e0ac5e37316754910f93849203f1a4ff7a7b467f /quantum/process_keycode | |
| parent | a4163466cb09144a96e2ea7bc697af1af8a5e770 (diff) | |
| download | qmk_firmware-f67aefc522dd8b72711e7fc5280e1cae1470d1c5.tar.gz qmk_firmware-f67aefc522dd8b72711e7fc5280e1cae1470d1c5.zip | |
remove disabled code
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_midi.c | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index 4fbb28816..2ce7418ea 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c | |||
| @@ -1,11 +1,5 @@ | |||
| 1 | #include "process_midi.h" | 1 | #include "process_midi.h" |
| 2 | 2 | ||
| 3 | #if 0 | ||
| 4 | bool midi_activated = false; | ||
| 5 | uint8_t midi_starting_note = 0x0C; | ||
| 6 | int midi_offset = 7; | ||
| 7 | #endif | ||
| 8 | |||
| 9 | typedef union { | 3 | typedef union { |
| 10 | uint16_t raw; | 4 | uint16_t raw; |
| 11 | struct { | 5 | struct { |
| @@ -19,33 +13,9 @@ midi_config_t midi_config; | |||
| 19 | 13 | ||
| 20 | #define MIDI_INVALID_NOTE 0xFF | 14 | #define MIDI_INVALID_NOTE 0xFF |
| 21 | 15 | ||
| 22 | #define MIDI_USE_NOTE_ON_ARRAY | ||
| 23 | |||
| 24 | #ifdef MIDI_USE_NOTE_ON_ARRAY | ||
| 25 | |||
| 26 | #define MIDI_MAX_NOTES_ON 10 | ||
| 27 | |||
| 28 | typedef struct { | ||
| 29 | uint8_t note; | ||
| 30 | uint8_t tone; | ||
| 31 | } midi_notes_on_array_entry_t; | ||
| 32 | |||
| 33 | typedef struct { | ||
| 34 | uint8_t length; | ||
| 35 | midi_notes_on_array_entry_t values[MIDI_MAX_NOTES_ON]; | ||
| 36 | } midi_notes_on_array_t; | ||
| 37 | |||
| 38 | static midi_notes_on_array_t notes_on; | ||
| 39 | |||
| 40 | #else | ||
| 41 | |||
| 42 | #define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) | 16 | #define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) |
| 43 | static uint8_t tone_status[MIDI_TONE_COUNT]; | 17 | static uint8_t tone_status[MIDI_TONE_COUNT]; |
| 44 | 18 | ||
| 45 | #endif | ||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | inline uint8_t compute_velocity(uint8_t setting) | 19 | inline uint8_t compute_velocity(uint8_t setting) |
| 50 | { | 20 | { |
| 51 | return (setting + 1) * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN + 1)); | 21 | return (setting + 1) * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN + 1)); |
| @@ -74,49 +44,13 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) | |||
| 74 | uint8_t channel = midi_config.channel; | 44 | uint8_t channel = midi_config.channel; |
| 75 | uint8_t tone = keycode - MIDI_TONE_MIN; | 45 | uint8_t tone = keycode - MIDI_TONE_MIN; |
| 76 | uint8_t velocity = compute_velocity(midi_config.velocity); | 46 | uint8_t velocity = compute_velocity(midi_config.velocity); |
| 77 | #ifdef MIDI_USE_NOTE_ON_ARRAY | ||
| 78 | if (record->event.pressed && notes_on.length < MIDI_MAX_NOTES_ON) { | ||
| 79 | #else | ||
| 80 | if (record->event.pressed) { | 47 | if (record->event.pressed) { |
| 81 | #endif | ||
| 82 | uint8_t note = 12 * midi_config.octave + tone; | 48 | uint8_t note = 12 * midi_config.octave + tone; |
| 83 | midi_send_noteon(&midi_device, channel, note, velocity); | 49 | midi_send_noteon(&midi_device, channel, note, velocity); |
| 84 | dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity); | 50 | dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity); |
| 85 | |||
| 86 | #ifdef MIDI_USE_NOTE_ON_ARRAY | ||
| 87 | |||
| 88 | notes_on.values[notes_on.length].note = note; | ||
| 89 | notes_on.values[notes_on.length].tone = tone; | ||
| 90 | notes_on.length++; | ||
| 91 | |||
| 92 | #else | ||
| 93 | |||
| 94 | tone_status[tone] = note; | 51 | tone_status[tone] = note; |
| 95 | |||
| 96 | #endif | ||
| 97 | } | 52 | } |
| 98 | else { | 53 | else { |
| 99 | |||
| 100 | #ifdef MIDI_USE_NOTE_ON_ARRAY | ||
| 101 | |||
| 102 | for (uint8_t i = 0; i < notes_on.length; i++) { | ||
| 103 | uint8_t note = notes_on.values[i].note; | ||
| 104 | if (tone == notes_on.values[i].tone) { | ||
| 105 | midi_send_noteoff(&midi_device, channel, note, velocity); | ||
| 106 | dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity); | ||
| 107 | |||
| 108 | for (uint8_t j=i; j < notes_on.length - 1; j++) | ||
| 109 | { | ||
| 110 | notes_on.values[j] = notes_on.values[j + 1]; | ||
| 111 | } | ||
| 112 | |||
| 113 | notes_on.length--; | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | #else | ||
| 119 | |||
| 120 | uint8_t note = tone_status[tone]; | 54 | uint8_t note = tone_status[tone]; |
| 121 | if (note != MIDI_INVALID_NOTE) | 55 | if (note != MIDI_INVALID_NOTE) |
| 122 | { | 56 | { |
| @@ -124,8 +58,6 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) | |||
| 124 | dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity); | 58 | dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity); |
| 125 | } | 59 | } |
| 126 | tone_status[tone] = MIDI_INVALID_NOTE; | 60 | tone_status[tone] = MIDI_INVALID_NOTE; |
| 127 | |||
| 128 | #endif | ||
| 129 | } | 61 | } |
| 130 | return false; | 62 | return false; |
| 131 | } | 63 | } |
| @@ -170,66 +102,5 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) | |||
| 170 | return false; | 102 | return false; |
| 171 | }; | 103 | }; |
| 172 | 104 | ||
| 173 | #if 0 | ||
| 174 | if (keycode == MI_ON && record->event.pressed) { | ||
| 175 | midi_activated = true; | ||
| 176 | #ifdef AUDIO_ENABLE | ||
| 177 | music_scale_user(); | ||
| 178 | #endif | ||
| 179 | return false; | ||
| 180 | } | ||
| 181 | |||
| 182 | if (keycode == MI_OFF && record->event.pressed) { | ||
| 183 | midi_activated = false; | ||
| 184 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 185 | return false; | ||
| 186 | } | ||
| 187 | |||
| 188 | if (midi_activated) { | ||
| 189 | if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 190 | if (record->event.pressed) { | ||
| 191 | midi_starting_note++; // Change key | ||
| 192 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 193 | } | ||
| 194 | return false; | ||
| 195 | } | ||
| 196 | if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { | ||
| 197 | if (record->event.pressed) { | ||
| 198 | midi_starting_note--; // Change key | ||
| 199 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 200 | } | ||
| 201 | return false; | ||
| 202 | } | ||
| 203 | if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 204 | midi_offset++; // Change scale | ||
| 205 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 206 | return false; | ||
| 207 | } | ||
| 208 | if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { | ||
| 209 | midi_offset--; // Change scale | ||
| 210 | midi_send_cc(&midi_device, 0, 0x7B, 0); | ||
| 211 | return false; | ||
| 212 | } | ||
| 213 | // basic | ||
| 214 | // uint8_t note = (midi_starting_note + SCALE[record->event.key.col + midi_offset])+12*(MATRIX_ROWS - record->event.key.row); | ||
| 215 | // advanced | ||
| 216 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+12*(MATRIX_ROWS - record->event.key.row); | ||
| 217 | // guitar | ||
| 218 | uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+5*(MATRIX_ROWS - record->event.key.row); | ||
| 219 | // violin | ||
| 220 | // uint8_t note = (midi_starting_note + record->event.key.col + midi_offset)+7*(MATRIX_ROWS - record->event.key.row); | ||
| 221 | |||
| 222 | if (record->event.pressed) { | ||
| 223 | // midi_send_noteon(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); | ||
| 224 | midi_send_noteon(&midi_device, 0, note, 127); | ||
| 225 | } else { | ||
| 226 | // midi_send_noteoff(&midi_device, record->event.key.row, midi_starting_note + SCALE[record->event.key.col], 127); | ||
| 227 | midi_send_noteoff(&midi_device, 0, note, 127); | ||
| 228 | } | ||
| 229 | |||
| 230 | if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through | ||
| 231 | return false; | ||
| 232 | } | ||
| 233 | #endif | ||
| 234 | return true; | 105 | return true; |
| 235 | } | 106 | } |
