USB MIDI device port (static class)
More...
USB MIDI device port (static class)
- Context
- Main loop only; not ISR-safe: the TinyUSB device stack is not reentrant.
Definition at line 45 of file midi.hpp.
#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, uint8_t port=0) |
| | Send a MidiEvent over USB MIDI (TX)
|
| |
| static uint32_t | write (const uint8_t *data, uint32_t len, uint8_t port=0) |
| | Write raw MIDI bytes to USB MIDI (TX)
|
| |
| static uint8_t | out_port_count () |
| | How many output ports this target has.
|
| |
◆ 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 24 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 26 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
-
- Returns
- true if all bytes were written, false if the buffer is full or the port does not exist
Definition at line 33 of file midi.cpp.
◆ write()
| uint32_t sbl::usb::MidiPort::write |
( |
const uint8_t * |
data, |
|
|
uint32_t |
len, |
|
|
uint8_t |
port = 0 |
|
) |
| |
|
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 |
| port | Output port, 0 to out_port_count() - 1 |
- Returns
- Number of bytes written (0 if the port does not exist)
Definition at line 47 of file midi.cpp.
◆ out_port_count()
| uint8_t sbl::usb::MidiPort::out_port_count |
( |
| ) |
|
|
static |
How many output ports this target has.
One on a USB device. A port existing does not mean anything is listening to it.
Definition at line 54 of file midi.cpp.
The documentation for this class was generated from the following files: