process_midi.h (1576B)
1 /* Copyright 2016 Jack Humbert 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17 #pragma once 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "action.h" 22 #include "quantum_keycodes.h" 23 24 #ifdef MIDI_ENABLE 25 26 # ifdef MIDI_BASIC 27 void process_midi_basic_noteon(uint8_t note); 28 void process_midi_basic_noteoff(uint8_t note); 29 void process_midi_all_notes_off(void); 30 # endif 31 32 void midi_task(void); 33 34 # ifdef MIDI_ADVANCED 35 typedef union { 36 uint32_t raw; 37 struct { 38 uint8_t octave : 4; 39 int8_t transpose : 4; 40 uint8_t velocity : 7; 41 uint8_t channel : 4; 42 uint8_t modulation_interval : 4; 43 }; 44 } midi_config_t; 45 46 extern midi_config_t midi_config; 47 48 void midi_init(void); 49 bool process_midi(uint16_t keycode, keyrecord_t *record); 50 51 # define MIDI_INVALID_NOTE 0xFF 52 # define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) 53 54 uint8_t midi_compute_note(uint16_t keycode); 55 # endif // MIDI_ADVANCED 56 57 #endif // MIDI_ENABLE