Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
sbl::usb::MidiPort Class Reference

USB MIDI device port (static class) More...

#include <midi.hpp>

Collaboration diagram for sbl::usb::MidiPort:

Static Public Member Functions

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)
 

Detailed Description

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.

Member Function Documentation

◆ 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
bufBuffer to receive MIDI bytes
max_lenMaximum bytes to read
Returns
Number of bytes read (0 if nothing available)

Definition at line 25 of file midi.cpp.

◆ send()

bool sbl::usb::MidiPort::send ( const sbl::midi::MidiEvent event)
static

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
eventThe 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
dataRaw MIDI bytes to send
lenNumber 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: