Skip to content

Commit abcff3f

Browse files
committed
MIDI: Add raw USB packet interface
Add methods to send and retrieve a full 4-byte USB MIDI packet: bool send(const MIDIPacket* packet); bool receive(MIDIPacket* packet);
1 parent 950fc6b commit abcff3f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Adafruit_USBD_MIDI.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ void Adafruit_USBD_MIDI::flush(void) {
114114
// MIDI Library doen't use flush
115115
}
116116

117+
bool Adafruit_USBD_MIDI::send(const uint8_t packet[4])
118+
{
119+
return tud_midi_send(packet);
120+
}
121+
122+
bool Adafruit_USBD_MIDI::receive(uint8_t packet[4])
123+
{
124+
return tud_midi_receive(packet);
125+
}
126+
117127
#endif

src/Adafruit_USBD_MIDI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class Adafruit_USBD_MIDI : public Stream, Adafruit_USBD_Interface {
4747
virtual int peek(void);
4848
virtual void flush(void);
4949

50+
// Raw MIDI USB packet interface.
51+
bool send(const uint8_t packet[4]);
52+
bool receive(uint8_t packet[4]);
53+
5054
// from Adafruit_USBD_Interface
5155
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t *buf,
5256
uint16_t bufsize);

0 commit comments

Comments
 (0)