NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
A forward iterator for moving along a MIDIMultiTrack. More...
#include <multitrack.h>
Public Member Functions | |
MIDIMultiTrackIterator (MIDIMultiTrack *mlt) | |
The constructor creates the object and attaches it to the given MIDIMultiTrack. More... | |
void | Reset () |
Syncs num_tracks with the multitrack and resets time to 0. Does not reset time shift mode. More... | |
MIDIClockTime | GetCurrentTime () const |
Gets the current time of the iterator. More... | |
bool | GetTimeShiftMode () const |
Returns true if time shifting is on. More... | |
MIDIMultiTrackIteratorState & | GetState () |
Gets the current MIDIMultiTrackIteratorState. More... | |
const MIDIMultiTrackIteratorState & | GetState () const |
Gets the current MIDIMultiTrackIteratorState. More... | |
void | SetTimeShiftMode (bool f) |
Turns time shifting on and off. More... | |
void | SetEnable (unsigned int trk_num, bool f) |
Enable or disable a track. More... | |
void | SetState (const MIDIMultiTrackIteratorState &s) |
Sets the given MIDIMultiTrackIteratorState as current state. More... | |
bool | GoToTime (MIDIClockTime time) |
Goes to the given time, which becomes the current time, and sets then the current event as the first event (in any track) with time greater or equal to time. More... | |
bool | GetNextEvent (int *track, MIDITimedMessage **msg) |
Gets the next event in the multitrack in temporal order and updates the iterator state. More... | |
bool | GetNextEventOnTrack (int track, MIDITimedMessage **msg) |
Gets the next event in the multitrack on track track and updates the iterator state. More... | |
bool | GetNextEventTime (MIDIClockTime *t) const |
Gets the time of the next event in the multitrack (it can be different from current time if at current time there are not events). More... | |
A forward iterator for moving along a MIDIMultiTrack.
It defines a current time (initially 0) and a current event, and stores its status in a MIDIMultiTrackIteratorState object. You can jump to any time in the multitrack and get its events in chronological order, starting with the first event with time greater than or equal to the current time, regardless of their track. This class also handles the time shifting of track events. You can set a different time shift amount for every track with the MIDITrack::SetTimeShift() method, and turn time shifting on and off with the SetTimeShiftMode() of this class. See also MIDISequencer::SetTimeShiftMode().
MIDIMultiTrackIterator::MIDIMultiTrackIterator | ( | MIDIMultiTrack * | mlt | ) |
The constructor creates the object and attaches it to the given MIDIMultiTrack.
void MIDIMultiTrackIterator::Reset | ( | ) |
Syncs num_tracks with the multitrack and resets time to 0. Does not reset time shift mode.
|
inline |
Gets the current time of the iterator.
|
inline |
Returns true if time shifting is on.
|
inline |
Gets the current MIDIMultiTrackIteratorState.
You can save and then restore it for a faster processing in GoTo operations (admitting the contents of the multitrack are not changed).
|
inline |
Gets the current MIDIMultiTrackIteratorState.
You can save and then restore it for a faster processing in GoTo operations (admitting the contents of the multitrack are not changed).
|
inline |
Turns time shifting on and off.
If time shifting is off events are sorted according to their time, otherwise an offset (positive or negative) is added to channel and sysex events time (other events time remain unchanged).
void MIDIMultiTrackIterator::SetEnable | ( | unsigned int | trk_num, |
bool | f | ||
) |
Enable or disable a track.
If you know that a track contains events which you want to ignore you can exclude it for more speed.
trk_num | the number of the track |
f | true for enabling, false for disabling. |
|
inline |
Sets the given MIDIMultiTrackIteratorState as current state.
bool MIDIMultiTrackIterator::GoToTime | ( | MIDIClockTime | time | ) |
Goes to the given time, which becomes the current time, and sets then the current event as the first event (in any track) with time greater or equal to time.
If there are more events with same time in different tracks their order is not defined, as the iterator tries to rotate across the tracks rather than to get first all events in a single track. However, temporal order is always granted.
bool MIDIMultiTrackIterator::GetNextEvent | ( | int * | track, |
MIDITimedMessage ** | msg | ||
) |
Gets the next event in the multitrack in temporal order and updates the iterator state.
If the time shifting mode is on the events are sorted according to their shifted time.
track | the track of the event, if valid. |
*msg | a pointer to the event in the MidiMultiTrack |
bool MIDIMultiTrackIterator::GetNextEventOnTrack | ( | int | track, |
MIDITimedMessage ** | msg | ||
) |
Gets the next event in the multitrack on track track and updates the iterator state.
track | the track of the event, if valid. |
*msg | a pointer to the event in the MidiMultiTrack |
bool MIDIMultiTrackIterator::GetNextEventTime | ( | MIDIClockTime * | t | ) | const |
Gets the time of the next event in the multitrack (it can be different from current time if at current time there are not events).
This does not change the iterator state.
t | here we get the time of next event, if valid. If the time shifting mode is on it is the shifted time. |