MD_MIDIFile Standard MIDI File Processing 2.6
Library to play Standard MIDI Files (SMF)
|
#include <MD_MIDIFile.h>
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 | |
Object definition for a SMF MIDI track. This object is not invoked by user code.
MD_MFTrack::MD_MFTrack | ( | void | ) |
Class Constructor
Instantiate a new instance of the class.
MD_MFTrack::~MD_MFTrack | ( | void | ) |
Class Destructor
Released allocated memory and does the necessary to clean up once the object is no longer required.
void MD_MFTrack::close | ( | void | ) |
Close the track
Stop processing the track and reset it to start conditions.
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.
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.
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.
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.
mf | pointer to the MIDI file object calling this track. |
tickCount | the number of ticks since this method was last called for this track. |
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.
trackId | the identifying number for the track [0..MIDI_MAX_TRACKS-1]. |
mf | pointer to the MIDI file object calling this track. |
|
protected |
Process the event from the physical file
Read and process the next event for this track from the file.
mf | pointer tho the MIDIFile object with the file to process. |
|
protected |
Initialize the class all in one place
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.
void MD_MFTrack::syncTime | ( | void | ) |
Reset the start time for this track
This is used to resynchronize a track when it has been paused.