Teensy 4.1 core updated for C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 satır
992B

  1. #ifndef MIDIUSB_h
  2. #define MIDIUSB_h
  3. // For compatibility with Arduino's MIDIUSB library
  4. #ifdef __cplusplus
  5. #if !defined(USB_MIDI)
  6. #error "Please select MIDI in Tools > USB Type to use MIDIUSB.h"
  7. #endif
  8. #include "usb_api.h"
  9. typedef struct {
  10. struct {
  11. uint8_t header;
  12. uint8_t byte1;
  13. uint8_t byte2;
  14. uint8_t byte3;
  15. };
  16. } midiEventPacket_t;
  17. class MIDI_
  18. {
  19. public:
  20. constexpr MIDI_(void) { }
  21. uint32_t available(void) {
  22. return usbMIDI.midiusb_available();
  23. }
  24. midiEventPacket_t read(void) {
  25. midiEventPacket_t event;
  26. usbMIDI.midiusb_read((uint8_t *)&event);
  27. return event;
  28. }
  29. void flush(void) {
  30. usbMIDI.send_now();
  31. }
  32. void sendMIDI(midiEventPacket_t event) {
  33. usbMIDI.send_raw(event.header, event.byte1, event.byte2, event.byte3);
  34. }
  35. size_t write(const uint8_t *buffer, size_t size) {
  36. // TODO - is this really needed?
  37. return 0;
  38. }
  39. operator bool() {
  40. // TODO - is this really needed?
  41. return true;
  42. }
  43. };
  44. extern MIDI_ MidiUSB;
  45. #endif // __cplusplus
  46. #endif // MIDIUSB_h