NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
MIDITrackIterator Class Reference

Forward iterator for moving along a MIDITrack. More...

#include <track.h>

Public Member Functions

 MIDITrackIterator (MIDITrack *trk)
 The constructor. You must specify the track which the iterator is attached to. More...
 
void Reset ()
 Sets the current time to 0, updating the iterator status. More...
 
MIDITrackGetTrack ()
 Returns a pointer to the track the iterator is attached to. More...
 
const MIDITrackGetTrack () const
 Returns a pointer to the track the iterator is attached to. More...
 
void SetTrack (MIDITrack *trk)
 Sets the iterator track (causes a reset). More...
 
MIDIClockTime GetCurrentTime () const
 Returns the current time of the iterator. More...
 
unsigned int GetCurrentEventNum () const
 Returns the current event number in the track. More...
 
int16_t GetProgram () const
 Returns the current track program (-1 if not set). More...
 
int16_t GetControl (unsigned char c) const
 Returns the current value for the given control (-1 if not set). More...
 
int16_t GetBender () const
 Returns the current bender value. More...
 
int GetNotesOn () const
 Returns the number of notes on at current time. More...
 
bool IsNoteOn (unsigned char n) const
 Returns true if the given note is on at current time. More...
 
bool IsPedalOn () const
 Returns true if the hold pedal is on at current time. More...
 
bool FindNoteOff (unsigned char note, MIDITimedMessage **msg)
 Finds the next MIDITimedMessage in the track corresponding to the note off for the given note. More...
 
bool FindPedalOff (MIDITimedMessage **msg)
 Finds the next hold pedal off MIDITimedMessage in the track. More...
 
bool GoToTime (MIDIClockTime time)
 Goes to the given time, which becomes the current time. More...
 
bool GetNextEvent (MIDITimedMessage **msg)
 Returns the next event in the track. More...
 
bool GetNextEventTime (MIDIClockTime *t) const
 Gets the time of the next event in the track. More...
 
bool EventIsNow (const MIDITimedMessage &msg)
 Returns true if at the current time there is an event of the same kind of msg (see MIDITimedMessage::IsSameKind()). More...
 

Detailed Description

Forward iterator for moving along a MIDITrack.

It defines a current time (initially 0) and a current event. You can move to any time in the track: when moving, it keeps track of program, bender, control changes and notes on.

Constructor & Destructor Documentation

◆ MIDITrackIterator()

MIDITrackIterator::MIDITrackIterator ( MIDITrack trk)

The constructor. You must specify the track which the iterator is attached to.

Member Function Documentation

◆ Reset()

void MIDITrackIterator::Reset ( )

Sets the current time to 0, updating the iterator status.

◆ GetTrack() [1/2]

MIDITrack * MIDITrackIterator::GetTrack ( )
inline

Returns a pointer to the track the iterator is attached to.

◆ GetTrack() [2/2]

const MIDITrack * MIDITrackIterator::GetTrack ( ) const
inline

Returns a pointer to the track the iterator is attached to.

◆ SetTrack()

void MIDITrackIterator::SetTrack ( MIDITrack trk)

Sets the iterator track (causes a reset).

◆ GetCurrentTime()

MIDIClockTime MIDITrackIterator::GetCurrentTime ( ) const
inline

Returns the current time of the iterator.

◆ GetCurrentEventNum()

unsigned int MIDITrackIterator::GetCurrentEventNum ( ) const
inline

Returns the current event number in the track.

◆ GetProgram()

int16_t MIDITrackIterator::GetProgram ( ) const
inline

Returns the current track program (-1 if not set).

◆ GetControl()

int16_t MIDITrackIterator::GetControl ( unsigned char  c) const
inline

Returns the current value for the given control (-1 if not set).

◆ GetBender()

int16_t MIDITrackIterator::GetBender ( ) const
inline

Returns the current bender value.

◆ GetNotesOn()

int MIDITrackIterator::GetNotesOn ( ) const
inline

Returns the number of notes on at current time.

◆ IsNoteOn()

bool MIDITrackIterator::IsNoteOn ( unsigned char  n) const
inline

Returns true if the given note is on at current time.

◆ IsPedalOn()

bool MIDITrackIterator::IsPedalOn ( ) const
inline

Returns true if the hold pedal is on at current time.

◆ FindNoteOff()

bool MIDITrackIterator::FindNoteOff ( unsigned char  note,
MIDITimedMessage **  msg 
)

Finds the next MIDITimedMessage in the track corresponding to the note off for the given note.

Parameters
[in]note: the note on
[out]msg: a pointer to the note off message
Returns
true if msg is valid, false otherwise (a note off was not found).

◆ FindPedalOff()

bool MIDITrackIterator::FindPedalOff ( MIDITimedMessage **  msg)

Finds the next hold pedal off MIDITimedMessage in the track.

Parameters
[out]msg: a pointer to the pedal off message
Returns
true if msg is valid, false otherwise (a pedal off was not found).

◆ GoToTime()

bool MIDITrackIterator::GoToTime ( MIDIClockTime  time)

Goes to the given time, which becomes the current time.

This sets the current event to the first event in the track with time greater or equal to time.

◆ GetNextEvent()

bool MIDITrackIterator::GetNextEvent ( MIDITimedMessage **  msg)

Returns the next event in the track.

Parameters
*msga pointer to the event in the MidiMultiTrack
Returns
true if there is effectively a next event (we aren't at the end of the track), false otherwise (and **msg doesn't contain a valid value).

◆ GetNextEventTime()

bool MIDITrackIterator::GetNextEventTime ( MIDIClockTime t) const

Gets the time of the next event in the track.

It can be different from current time if at current time there are not events.

Parameters
there we get the time of next event, if valid.
Returns
true if there is effectively a next event (we aren't at the end of the track), false otherwise (*t doesn't contain a valid time).

◆ EventIsNow()

bool MIDITrackIterator::EventIsNow ( const MIDITimedMessage msg)

Returns true if at the current time there is an event of the same kind of msg (see MIDITimedMessage::IsSameKind()).

The time of msg is ignored.


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