process_midi.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #pragma once
  17. #include "quantum.h"
  18. #ifdef MIDI_ENABLE
  19. # ifdef MIDI_BASIC
  20. void process_midi_basic_noteon(uint8_t note);
  21. void process_midi_basic_noteoff(uint8_t note);
  22. void process_midi_all_notes_off(void);
  23. # endif
  24. void midi_task(void);
  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 : 7;
  32. uint8_t channel : 4;
  33. uint8_t modulation_interval : 4;
  34. };
  35. } midi_config_t;
  36. extern midi_config_t midi_config;
  37. void midi_init(void);
  38. bool process_midi(uint16_t keycode, keyrecord_t *record);
  39. # define MIDI_INVALID_NOTE 0xFF
  40. # define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1)
  41. uint8_t midi_compute_note(uint16_t keycode);
  42. # endif // MIDI_ADVANCED
  43. #endif // MIDI_ENABLE