Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
midi.hpp File Reference

USB MIDI device interface. More...

Detailed Description

USB MIDI device interface.

Provides bidirectional USB MIDI 1.0 via TinyUSB's MIDI device class. Operates on cable 0 (single virtual cable).

RX path: tud_midi_stream_read() -> raw MIDI bytes -> feed to sbl::midi::Parser TX path: MidiEvent -> raw MIDI bytes -> tud_midi_stream_write()

Output ports. A USB device has one cable, so hardware targets have one output port and port is always 0. A target that offers more says so through out_port_count(): the workbench gives an app several, which is what a multi-voice sequencer sends into.

Requires CFG_TUD_MIDI=1 in tusb_config.h and the composite CDC+MIDI descriptor in usb_descriptors.c.

Usage:

// RX: poll in main loop (or sbl::midi::drain<sbl::usb::MidiPort>(parser))
uint8_t buf[64];
uint32_t n = sbl::usb::MidiPort::read(buf, sizeof(buf));
parser.push(buf, n);
// TX: send events
static uint32_t read(uint8_t *buf, uint32_t max_len)
Read decoded MIDI bytes from USB (RX)
Definition midi.cpp:26
static bool send(const sbl::midi::MidiEvent &event, uint8_t port=0)
Send a MidiEvent over USB MIDI (TX)
Definition midi.cpp:33

Definition in file midi.hpp.

#include <cstdint>
#include <sbl/protocol/midi/types.hpp>

Go to the source code of this file.

Classes

class  sbl::usb::MidiPort
 USB MIDI device port (static class) More...
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::usb
 USB device classes.