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
sbl::midi::Parser Class Reference

MIDI byte stream parser - state machine with running status. More...

Detailed Description

MIDI byte stream parser - state machine with running status.

Context
All public methods are ISR-safe: O(1) state machine with no hardware I/O. Callback is invoked synchronously from push().

Definition at line 41 of file parser.hpp.

#include <parser.hpp>

Public Member Functions

void set_callback (MidiCallback cb)
 Set the callback for parsed MIDI events.
 
void set_channel (uint8_t ch)
 Set channel filter.
 
void push (uint8_t byte)
 Feed one byte from UART RX.
 
void push (const uint8_t *data, uint16_t len)
 Feed multiple bytes.
 

Member Function Documentation

◆ set_callback()

void sbl::midi::Parser::set_callback ( MidiCallback  cb)
inline

Set the callback for parsed MIDI events.

Context
ISR-safe: stores a function pointer, no I/O.

Definition at line 47 of file parser.hpp.

◆ set_channel()

void sbl::midi::Parser::set_channel ( uint8_t  ch)
inline

Set channel filter.

Parameters
chChannel 0-15, or 0xFF for omni (receive all channels)
Context
ISR-safe: stores a byte, no I/O.

Definition at line 54 of file parser.hpp.

◆ push() [1/2]

void sbl::midi::Parser::push ( uint8_t  byte)
inline

Feed one byte from UART RX.

State machine processes the byte and dispatches complete messages via the callback. System Real-Time messages are dispatched immediately, even mid-message.

Context
ISR-safe: O(1) state machine, no blocking or I/O.

Definition at line 65 of file parser.hpp.

References sbl::midi::expected_data_bytes().

Referenced by sbl::midi::drain(), and push().

◆ push() [2/2]

void sbl::midi::Parser::push ( const uint8_t *  data,
uint16_t  len 
)
inline

Feed multiple bytes.

Context
ISR-safe: O(n) loop over push(), no blocking or I/O.

Definition at line 165 of file parser.hpp.

References push().


The documentation for this class was generated from the following file: