|
wavelength 1.0.0
|
Reader of a Standard MIDI File that reports each track and event to a MidiReceiver. More...
#include <midireader.h>
Classes | |
| struct | Midi |
| One channel event waiting in mPending. More... | |
| struct | ChunkName |
| The four-character name of a chunk. More... | |
| struct | VarLen |
| A variable-length quantity, read seven bits a byte from the most significant. More... | |
Public Types | |
| enum | State { kStateHeader = 0 , kStateTrackStart = 1 , kStateEvent = 2 , kStateDone = 3 } |
| Values of mState. More... | |
| using | Compare = bool (*)(const Midi &left, const Midi &right) |
| Ordering of mPending. | |
Public Member Functions | |
| MidiReader (const char *pszFile, MidiReceiver *pReceiver) | |
| Open a MIDI file. | |
| MidiReader (char *pBuffer, int nSize, MidiReceiver *pReceiver) | |
| Read a MIDI file from memory. | |
| ~MidiReader () | |
| Close the stream. | |
| void | ReadAll () |
| Read the whole file. | |
| bool | ReadTrack () |
| Read up to the end of the next track. | |
| bool | ReadSteps (int nSteps) |
| Take a number of steps. | |
| bool | ReadFor (float fMs) |
| Take steps until a time has passed. | |
Static Public Member Functions | |
| static bool | CompareMidi (const Midi &left, const Midi &right) |
| Order channel events so note offs come first, then controllers, programs, channel pressure, pitch bends, key pressure, and note ons, and any other message last. | |
Reader of a Standard MIDI File that reports each track and event to a MidiReceiver.
The class is not polymorphic and has no RTTI. The name is inferred. The reader advances one step at a time: the header, the start of a track, or one event. Event positions are rescaled from the division of the file to 480 ticks per quarter note. The channel events of one position are collected and sorted with mCompare before they are reported.
| using MidiReader::Compare = bool (*)(const Midi &left, const Midi &right) |
Ordering of mPending.
The result is true when the first event sorts first.
| enum MidiReader::State |
| MidiReader::MidiReader | ( | const char * | pszFile, |
| MidiReceiver * | pReceiver ) |
Open a MIDI file.
| pszFile | The file. |
| pReceiver | The receiver of the tracks and events. |
| MidiReader::MidiReader | ( | char * | pBuffer, |
| int | nSize, | ||
| MidiReceiver * | pReceiver ) |
Read a MIDI file from memory.
| pBuffer | The contents of the file. The caller retains them. |
| nSize | The size of the contents in bytes. |
| pReceiver | The receiver of the tracks and events. |
| MidiReader::~MidiReader | ( | ) |
Close the stream.
Order channel events so note offs come first, then controllers, programs, channel pressure, pitch bends, key pressure, and note ons, and any other message last.
| left | The first event. |
| right | The second event. |
| void MidiReader::ReadAll | ( | ) |
Read the whole file.
| bool MidiReader::ReadTrack | ( | ) |
Read up to the end of the next track.
| bool MidiReader::ReadSteps | ( | int | nSteps | ) |
Take a number of steps.
| nSteps | The number of steps. |
| bool MidiReader::ReadFor | ( | float | fMs | ) |
Take steps until a time has passed.
| fMs | The time in milliseconds. |