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::SmfTrack Class Reference

A cursor over one track chunk. More...

Detailed Description

A cursor over one track chunk.

peek() decodes the next event without consuming it; pop() consumes it. A malformed event ends the track and sets error(). The file's bytes must outlive the cursor.

Definition at line 49 of file smf_reader.hpp.

#include <smf_reader.hpp>

Public Member Functions

 SmfTrack ()=default
 An empty cursor: peek() returns nullptr.
 
 SmfTrack (const uint8_t *data, uint32_t length)
 A cursor at the start of a track chunk's body.
 
void rewind ()
 Return to the track's first event and clear error()
 
const SmfEvent * peek ()
 The next event, or nullptr when the track has ended.
 
void pop ()
 Consume the event peek() returned.
 
bool done () const
 True once the track has ended and its last event was popped.
 
bool error () const
 True if a malformed event ended the track.
 

Constructor & Destructor Documentation

◆ SmfTrack()

sbl::midi::SmfTrack::SmfTrack ( const uint8_t *  data,
uint32_t  length 
)
inline

A cursor at the start of a track chunk's body.

Parameters
dataFirst byte after the MTrk chunk header
lengthBody length in bytes

Definition at line 59 of file smf_reader.hpp.

References rewind().

Member Function Documentation

◆ rewind()

void sbl::midi::SmfTrack::rewind ( )
inline

Return to the track's first event and clear error()

Definition at line 62 of file smf_reader.hpp.

Referenced by SmfTrack().

◆ peek()

const SmfEvent * sbl::midi::SmfTrack::peek ( )
inline

The next event, or nullptr when the track has ended.

Definition at line 72 of file smf_reader.hpp.

Referenced by sbl::midi::Sequencer< Outputs >::advance().

◆ pop()

void sbl::midi::SmfTrack::pop ( )
inline

Consume the event peek() returned.

Definition at line 80 of file smf_reader.hpp.

Referenced by sbl::midi::Sequencer< Outputs >::advance().

◆ done()

bool sbl::midi::SmfTrack::done ( ) const
inline

True once the track has ended and its last event was popped.

Definition at line 83 of file smf_reader.hpp.

◆ error()

bool sbl::midi::SmfTrack::error ( ) const
inline

True if a malformed event ended the track.

Definition at line 85 of file smf_reader.hpp.


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