USB MIDI device port (static class)
More...
#include <midi.hpp>
|
| static bool | connected () |
| | Check if USB MIDI interface is mounted by host.
|
| |
| static uint32_t | read (uint8_t *buf, uint32_t max_len) |
| | Read decoded MIDI bytes from USB (RX)
|
| |
| static bool | send (const sbl::midi::MidiEvent &event) |
| | Send a MidiEvent over USB MIDI (TX)
|
| |
| static uint32_t | write (const uint8_t *data, uint32_t len) |
| | Write raw MIDI bytes to USB MIDI (TX)
|
| |
USB MIDI device port (static class)
All methods are safe to call from main loop context. Not ISR-safe — TinyUSB device stack is not reentrant.
Definition at line 36 of file midi.hpp.
◆ connected()
| bool sbl::usb::MidiPort::connected |
( |
| ) |
|
|
static |
Check if USB MIDI interface is mounted by host.
- Returns
- true if host has enumerated and configured the MIDI interface
Definition at line 21 of file midi.cpp.
◆ read()
| uint32_t sbl::usb::MidiPort::read |
( |
uint8_t * |
buf, |
|
|
uint32_t |
max_len |
|
) |
| |
|
static |
Read decoded MIDI bytes from USB (RX)
TinyUSB unpacks 4-byte USB MIDI Event Packets into standard MIDI byte stream. Feed the output directly to sbl::midi::Parser::push().
- Parameters
-
| buf | Buffer to receive MIDI bytes |
| max_len | Maximum bytes to read |
- Returns
- Number of bytes read (0 if nothing available)
Definition at line 25 of file midi.cpp.
◆ send()
Send a MidiEvent over USB MIDI (TX)
Converts the event to standard MIDI bytes and writes them via tud_midi_stream_write(), which handles USB packet framing.
- Parameters
-
| event | The MIDI event to send |
- Returns
- true if all bytes were written, false if buffer full
Definition at line 30 of file midi.cpp.
◆ write()
| uint32_t sbl::usb::MidiPort::write |
( |
const uint8_t * |
data, |
|
|
uint32_t |
len |
|
) |
| |
|
static |
Write raw MIDI bytes to USB MIDI (TX)
TinyUSB packs bytes into 4-byte USB MIDI Event Packets.
- Parameters
-
| data | Raw MIDI bytes to send |
| len | Number of bytes |
- Returns
- Number of bytes written
Definition at line 40 of file midi.cpp.
The documentation for this class was generated from the following files: