Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::midi Namespace Reference

MIDI parser, encoder, SMF and sequencer. More...

Detailed Description

MIDI parser, encoder, SMF and sequencer.

Classes

struct  MidiEvent
 
class  Parser
 MIDI byte stream parser — state machine with running status. More...
 
class  Sequencer
 
struct  SmfEvent
 One event from a track, with its absolute tick. More...
 
class  SmfReader
 
class  SmfTrack
 A cursor over one track chunk. More...
 

Typedefs

using MidiCallback = void(*)(const MidiEvent &event)
 Callback type for parsed MIDI events.
 

Enumerations

enum class  SmfError : uint8_t {
  None , NotSmf , BadHeader , UnsupportedFormat ,
  SmpteDivision , TooManyTracks , Truncated
}
 
enum class  MessageType : uint8_t {
  NoteOff = 0x80 , NoteOn = 0x90 , PolyPressure = 0xA0 , ControlChange = 0xB0 ,
  ProgramChange = 0xC0 , ChannelPressure = 0xD0 , PitchBend = 0xE0 , Clock = 0xF8 ,
  Start = 0xFA , Continue = 0xFB , Stop = 0xFC , ActiveSensing = 0xFE ,
  SystemReset = 0xFF , SysEx = 0xF0 , SysExEnd = 0xF7 , TimeCode = 0xF1 ,
  SongPosition = 0xF2 , SongSelect = 0xF3 , TuneRequest = 0xF6 , None = 0x00
}
 

Functions

template<typename UartDriver >
void poll (Parser &parser)
 Poll UART for MIDI bytes and feed them to the parser.
 
uint8_t expected_data_bytes (uint8_t status)
 Number of data bytes expected for a channel message status byte.
 

Typedef Documentation

◆ MidiCallback

using sbl::midi::MidiCallback = typedef void(*)(const MidiEvent& event)

Callback type for parsed MIDI events.

Definition at line 145 of file types.hpp.

Enumeration Type Documentation

◆ SmfError

enum class sbl::midi::SmfError : uint8_t
strong
Enumerator
None 
NotSmf 

no MThd header chunk at the start

BadHeader 

header too short, zero division, or format 0 with more than one track

UnsupportedFormat 

format 2

SmpteDivision 

division in SMPTE frames rather than ticks per quarter note

TooManyTracks 

more tracks than SmfReader::MAX_TRACKS

Truncated 

a chunk runs past the end of the data, or tracks are missing

Definition at line 33 of file smf_reader.hpp.

◆ MessageType

enum class sbl::midi::MessageType : uint8_t
strong
Enumerator
NoteOff 
NoteOn 
PolyPressure 
ControlChange 
ProgramChange 
ChannelPressure 
PitchBend 
Clock 
Start 
Continue 
Stop 
ActiveSensing 
SystemReset 
SysEx 
SysExEnd 
TimeCode 
SongPosition 
SongSelect 
TuneRequest 
None 

Definition at line 12 of file types.hpp.

Function Documentation

◆ poll()

template<typename UartDriver >
void sbl::midi::poll ( Parser &  parser)
inline

Poll UART for MIDI bytes and feed them to the parser.

Drains all available bytes from the UART RX buffer. Non-blocking — returns immediately if no data available.

Template Parameters
UartDriverUART driver class with available() and read_byte()
Note
ISR-safe — drains available bytes from ring buffer, no blocking.

Definition at line 30 of file input.hpp.

References sbl::midi::Parser::push().

◆ expected_data_bytes()

uint8_t sbl::midi::expected_data_bytes ( uint8_t  status)
inline

Number of data bytes expected for a channel message status byte.

Definition at line 148 of file types.hpp.

Referenced by sbl::midi::Parser::push().