MD_MIDIFile Standard MIDI File Processing 2.6
Library to play Standard MIDI Files (SMF)
MD_MFTrack Class Reference

#include <MD_MIDIFile.h>

+ Collaboration diagram for MD_MFTrack:

Public Member Functions

 MD_MFTrack (void)
 
 ~MD_MFTrack (void)
 
Methods for track file data
bool getEndOfTrack (void)
 
uint32_t getLength (void)
 
Methods for data handling
void close (void)
 
bool getNextEvent (MD_MIDIFile *mf, uint16_t tickCount)
 
int load (uint8_t trackId, MD_MIDIFile *mf)
 
void restart (void)
 
void syncTime (void)
 
Methods for debugging
void dump (void)
 

Protected Member Functions

void parseEvent (MD_MIDIFile *mf)
 
void reset (void)
 

Protected Attributes

uint8_t _trackId
 the id for this track
 
uint32_t _length
 length of track in bytes
 
uint32_t _startOffset
 start of the track in bytes from start of file
 
uint32_t _currOffset
 offset from start of the track for the next read of SD data
 
bool _endOfTrack
 true when we have reached end of track or we have encountered an undefined event
 
uint32_t _elapsedTicks
 the total number of elapsed ticks since last event
 
midi_event _mev
 data for MIDI callback function - persists between calls for run-on messages
 

Detailed Description

Object definition for a SMF MIDI track. This object is not invoked by user code.

Constructor & Destructor Documentation

◆ MD_MFTrack()

MD_MFTrack::MD_MFTrack ( void  )

Class Constructor

Instantiate a new instance of the class.

Returns
No return data.

◆ ~MD_MFTrack()

MD_MFTrack::~MD_MFTrack ( void  )

Class Destructor

Released allocated memory and does the necessary to clean up once the object is no longer required.

Returns
No return data.

Member Function Documentation

◆ close()

void MD_MFTrack::close ( void  )

Close the track

Stop processing the track and reset it to start conditions.

Returns
No return data.

◆ dump()

void MD_MFTrack::dump ( void  )

Dump the track header data to the debug stream

During debugging, this method provides a formatted dump of data to the debug output stream.

The DUMP_DATA macro define must be set to 1 to enable this method.

Returns
No return data.

◆ getEndOfTrack()

bool MD_MFTrack::getEndOfTrack ( void  )

Get end of track status

The method is used to test whether a track has reached the end. Once a track reached the end it stops being processed for MIDI events.

Returns
true if end of track has been reached.

◆ getLength()

uint32_t MD_MFTrack::getLength ( void  )

Get the length of the track in bytes

The length of a track is specified in the track header. This method returns the total length of the track in bytes.

Returns
the total track length (bytes).

◆ getNextEvent()

bool MD_MFTrack::getNextEvent ( MD_MIDIFile mf,
uint16_t  tickCount 
)

Get and process the next sequential MIDI or SYSEX event

Each track is made up of a sequence of MIDI and SYSEX events that are processed in sequential order using this method. An event will not be processed if the track is at end of track or insufficient time has elapsed for the next event to be triggered. Once processed the track position is advanced to the next event to be processed.

Parameters
mfpointer to the MIDI file object calling this track.
tickCountthe number of ticks since this method was last called for this track.
Returns
true if an event was found and processed.

◆ load()

int MD_MFTrack::load ( uint8_t  trackId,
MD_MIDIFile mf 
)

Load the definition of a track

Before it can be processed, each track must be initialise to its start conditions by invoking this method.

Parameters
trackIdthe identifying number for the track [0..MIDI_MAX_TRACKS-1].
mfpointer to the MIDI file object calling this track.
Returns
Error code with one of these values
  • -1 if successful
  • 0 if the track header is not in the correct format
  • 1 if the track chunk is past the end of file

◆ parseEvent()

void MD_MFTrack::parseEvent ( MD_MIDIFile mf)
protected

Process the event from the physical file

Read and process the next event for this track from the file.

Parameters
mfpointer tho the MIDIFile object with the file to process.
Returns
No return data.

◆ reset()

void MD_MFTrack::reset ( void  )
protected

Initialize the class all in one place

Returns
No return data.

◆ restart()

void MD_MFTrack::restart ( void  )

Reset the track to the start of the data in the file

Sets up the track to start playing from the beginning again.

Returns
No return data.

◆ syncTime()

void MD_MFTrack::syncTime ( void  )

Reset the start time for this track

This is used to resynchronize a track when it has been paused.

Returns
No return data.

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