process_midi.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef PROCESS_MIDI_H
  17. #define PROCESS_MIDI_H
  18. #include "quantum.h"
  19. #ifdef MIDI_ENABLE
  20. #ifdef MIDI_BASIC
  21. void process_midi_basic_noteon(uint8_t note);
  22. void process_midi_basic_noteoff(uint8_t note);
  23. void process_midi_all_notes_off(void);
  24. #endif
  25. #ifdef MIDI_ADVANCED
  26. typedef union {
  27. uint32_t raw;
  28. struct {
  29. uint8_t octave :4;
  30. int8_t transpose :4;
  31. uint8_t velocity :4;
  32. uint8_t channel :4;
  33. uint8_t modulation_interval :4;
  34. };
  35. } midi_config_t;
  36. midi_config_t midi_config;
  37. void midi_init(void);
  38. void midi_task(void);
  39. bool process_midi(uint16_t keycode, keyrecord_t *record);
  40. #define MIDI_INVALID_NOTE 0xFF
  41. #define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1)
  42. uint8_t midi_compute_note(uint16_t keycode);
  43. #endif // MIDI_ADVANCED
  44. #endif // MIDI_ENABLE
  45. #endif