NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
Holds an array of pointers to MIDITrack objects to be played simultaneously. More...
#include <multitrack.h>
Inherited by MIDIEditMultiTrack.
Public Member Functions | |
MIDIMultiTrack (unsigned int num_tracks=0, unsigned int cl_p_b=DEFAULT_CLKS_PER_BEAT) | |
The constructor creates an object with given number of tracks (default no track) and base MIDI clocks per beat. More... | |
MIDIMultiTrack (const MIDIMultiTrack &mlt) | |
The copy constructor. More... | |
virtual | ~MIDIMultiTrack () |
The destructor: The MIDIMultiTrack owns its tracks, so they are destroyed by this. More... | |
MIDIMultiTrack & | operator= (const MIDIMultiTrack &mlt) |
The assignment operator. More... | |
void | Reset (unsigned int num_tracks=0) |
Deletes all the tracks in the Multitrack, resizes it to the given number of tracks and resets clks_per_beat. More... | |
void | ClearTracks (bool mantain_end=false) |
Clears tracks events but mantains the tracks and their parameters. More... | |
unsigned int | GetClksPerBeat () const |
Returns the MIDI clocks per beat of all tracks (i.e. the number of MIDI ticks in a quarter note). More... | |
MIDITrack * | GetTrack (unsigned int trk_num) |
Returns the pointer to the track. More... | |
const MIDITrack * | GetTrack (unsigned int trk_num) const |
Returns the pointer to the track. More... | |
int | GetTrackNum (MIDITrack *trk) const |
Returns the number of the pointed track, -1 if the track is not in the multitrack. More... | |
unsigned int | GetNumTracks () const |
Returns the number of allocated tracks. More... | |
unsigned int | GetNumTracksWithEvents () const |
Returns the number of tracks with events (other than EOT). More... | |
unsigned int | GetNumEvents () const |
Returns the total number of MIDI events in the multitrack (for every track there is at least the EOT). More... | |
MIDIClockTime | GetEndTime () const |
Returns the end time of the longest track. More... | |
bool | IsValidTrackNumber (unsigned int trk_num) const |
Returns true if trk_num is in thee range 0 ... GetNumTracks() - 1. More... | |
bool | IsEmpty () const |
Returns true if there are no events in the tracks and the end time is 0. More... | |
void | SetClksPerBeat (unsigned int cl_p_b) |
Changes the value of the clock per beat parameter for the tracks, updating the times of all MIDI events. More... | |
bool | SetEndTime (MIDIClockTime end_time) |
Sets the time of the data end event to end_time. More... | |
void | ShrinkEndTime () |
Sets the time of the data end event equal to the time of the last event of every track. More... | |
void | AssignEventsToTracks (const MIDITrack *src) |
This function is useful in dealing with MIDI format 0 files (with all events in an unique track). More... | |
void | AssignEventsToTracks (unsigned int trk_num=0) |
The same as previous, but argument is the track number in the multitrack object himself. More... | |
bool | InsertTrack (int trk_num=-1) |
Inserts a new empty track at position trk_num (trk_num must be in the range 0 ... GetNumTracks() - 1). More... | |
bool | InsertTrack (const MIDITrack *trk, int trk_num=-1) |
Inserts a copy of the given track at position trk_num (trk_num must be in the range 0 ... GetNumTracks() - 1). More... | |
bool | DeleteTrack (int trk_num=-1) |
Deletes the track trk_num and its events. More... | |
bool | MoveTrack (int from, int to) |
Moves a track from the position from to the position to. More... | |
bool | SetTrack (const MIDITrack *trk, unsigned int trk_num) |
Copies the track trk into the position trk_num of the MIDIMultiTrack. More... | |
bool | InsertEvent (unsigned int trk_num, const MIDITimedMessage &msg, tInsMode _ins_mode=INSMODE_DEFAULT) |
Inserts the event msg in the track trk_num. More... | |
bool | InsertNote (unsigned int trk_num, const MIDITimedMessage &msg, MIDIClockTime len, tInsMode _ins_mode=INSMODE_DEFAULT) |
Inserts a Note On and a Note Off event into the track trk_num. See MIDITrack::InsertNote() for details. More... | |
bool | DeleteEvent (unsigned int trk_num, const MIDITimedMessage &msg) |
Deletes the event msg from the track trk_num. See MIDITrack::DeleteEvent() for details. More... | |
bool | DeleteNote (unsigned int trk_num, const MIDITimedMessage &msg) |
Deletes the note msg (msg must be a Note On) from the track _trk_num. See MIDITrack::DeleteNote() for details. More... | |
void | EditCopy (MIDIClockTime start, MIDIClockTime end, int tr_start, int tr_end, MIDIEditMultiTrack *edit) |
void | EditCut (MIDIClockTime start, MIDIClockTime end, MIDIEditMultiTrack *edit) |
void | EditClear (MIDIClockTime start, MIDIClockTime end, int tr_start, int tr_end) |
void | EditInsert (MIDIClockTime start, int tr_start, int times, MIDIEditMultiTrack *edit) |
void | EditReplace (MIDIClockTime start, int tr_start, int times, bool sysex, MIDIEditMultiTrack *edit) |
Protected Attributes | |
unsigned int | clks_per_beat |
The common clock per beat timing parameter for all tracks (this is the number of MIDI ticks for a quarter note). More... | |
Holds an array of pointers to MIDITrack objects to be played simultaneously.
Every track contains MIDITimedMessage objects representing MIDI events, and all tracks share the same timing (i.e. the events are temporized according to the same MIDI clock per beat). Typically track 0 is the master track and contains only non-channel MIDI events (time, tempo, markers ...) while other tracks contain the channel events. The MIDIMultiTrack object owns its tracks, so deleting it frees them also. You need to embed this into a MIDISequencer for playing the tracks. Moreover, a MIDIMultiTrackIterator class is supplied for moving along events in temporal order regardless the track number.
MIDIMultiTrack::MIDIMultiTrack | ( | unsigned int | num_tracks = 0 , |
unsigned int | cl_p_b = DEFAULT_CLKS_PER_BEAT |
||
) |
The constructor creates an object with given number of tracks (default no track) and base MIDI clocks per beat.
num_tracks | The number of tracks of the multitrack. The tracks are created by the constructor and they are are initially empty (contain only the EOT message at time 0). The default is no track |
cl_p_b | The number of MIDI ticks per quarter note. All tracks share this to convert the raw MIDIClockTime stored in their MIDITimedMessage objects into musical values. |
MIDIMultiTrack::MIDIMultiTrack | ( | const MIDIMultiTrack & | mlt | ) |
The copy constructor.
|
virtual |
The destructor: The MIDIMultiTrack owns its tracks, so they are destroyed by this.
MIDIMultiTrack & MIDIMultiTrack::operator= | ( | const MIDIMultiTrack & | mlt | ) |
The assignment operator.
void MIDIMultiTrack::Reset | ( | unsigned int | num_tracks = 0 | ) |
Deletes all the tracks in the Multitrack, resizes it to the given number of tracks and resets clks_per_beat.
void MIDIMultiTrack::ClearTracks | ( | bool | mantain_end = false | ) |
Clears tracks events but mantains the tracks and their parameters.
If mantain_end is true doesn't change the time of EOT events, otherwise sets them to 0.
|
inline |
Returns the MIDI clocks per beat of all tracks (i.e. the number of MIDI ticks in a quarter note).
|
inline |
Returns the pointer to the track.
trk_num | The track number |
|
inline |
Returns the pointer to the track.
trk_num | The track number |
int MIDIMultiTrack::GetTrackNum | ( | MIDITrack * | trk | ) | const |
Returns the number of the pointed track, -1 if the track is not in the multitrack.
|
inline |
Returns the number of allocated tracks.
unsigned int MIDIMultiTrack::GetNumTracksWithEvents | ( | ) | const |
Returns the number of tracks with events (other than EOT).
unsigned int MIDIMultiTrack::GetNumEvents | ( | ) | const |
Returns the total number of MIDI events in the multitrack (for every track there is at least the EOT).
If you want to know if the MIDIMultiTrack is empty, use GetNumTracksWithEvents() instead.
MIDIClockTime MIDIMultiTrack::GetEndTime | ( | ) | const |
Returns the end time of the longest track.
|
inline |
Returns true if trk_num is in thee range 0 ... GetNumTracks() - 1.
|
inline |
Returns true if there are no events in the tracks and the end time is 0.
void MIDIMultiTrack::SetClksPerBeat | ( | unsigned int | cl_p_b | ) |
Changes the value of the clock per beat parameter for the tracks, updating the times of all MIDI events.
This may lead to loss in precision or rounding error if the new clocks per beat is not a multiple of the old, so it's better to call this function before inserting any event in the multitrack.
cl_p_b | see the constructor |
bool MIDIMultiTrack::SetEndTime | ( | MIDIClockTime | end_time | ) |
Sets the time of the data end event to end_time.
If there are events of other type after end_time the function fails and returns false.
void MIDIMultiTrack::ShrinkEndTime | ( | ) |
Sets the time of the data end event equal to the time of the last event of every track.
void MIDIMultiTrack::AssignEventsToTracks | ( | const MIDITrack * | src | ) |
This function is useful in dealing with MIDI format 0 files (with all events in an unique track).
It remakes the MIDIMultiTrack object with 17 tracks (src track can be a member of multitrack object himself), moves src track channel events to tracks 1-16 according their channel, and all other types of events to track 0. This is automatically called when loading a MIDI format 0 file.
|
inline |
The same as previous, but argument is the track number in the multitrack object himself.
bool MIDIMultiTrack::InsertTrack | ( | int | trk_num = -1 | ) |
Inserts a new empty track at position trk_num (trk_num must be in the range 0 ... GetNumTracks() - 1).
If trk_num == -1 appends the track at the end.
bool MIDIMultiTrack::InsertTrack | ( | const MIDITrack * | trk, |
int | trk_num = -1 |
||
) |
Inserts a copy of the given track at position trk_num (trk_num must be in the range 0 ... GetNumTracks() - 1).
If trk_num == -1 appends the track at the end.
bool MIDIMultiTrack::DeleteTrack | ( | int | trk_num = -1 | ) |
Deletes the track trk_num and its events.
(trk_num must be in the range 0 ... GetNumTracks() - 1). If trk_num == -1 deletes the last track.
bool MIDIMultiTrack::MoveTrack | ( | int | from, |
int | to | ||
) |
Moves a track from the position from to the position to.
( from and to must be in the range 0 ... GetNumTracks() - 1).
bool MIDIMultiTrack::SetTrack | ( | const MIDITrack * | trk, |
unsigned int | trk_num | ||
) |
Copies the track trk into the position trk_num of the MIDIMultiTrack.
Old content is overwritten, and trk_num must be in the range 0 ... GetNumTracks() - 1).
bool MIDIMultiTrack::InsertEvent | ( | unsigned int | trk_num, |
const MIDITimedMessage & | msg, | ||
tInsMode | _ins_mode = INSMODE_DEFAULT |
||
) |
Inserts the event msg in the track trk_num.
See MIDITrack::InsertEvent() for details.
bool MIDIMultiTrack::InsertNote | ( | unsigned int | trk_num, |
const MIDITimedMessage & | msg, | ||
MIDIClockTime | len, | ||
tInsMode | _ins_mode = INSMODE_DEFAULT |
||
) |
Inserts a Note On and a Note Off event into the track trk_num. See MIDITrack::InsertNote() for details.
bool MIDIMultiTrack::DeleteEvent | ( | unsigned int | trk_num, |
const MIDITimedMessage & | msg | ||
) |
Deletes the event msg from the track trk_num. See MIDITrack::DeleteEvent() for details.
bool MIDIMultiTrack::DeleteNote | ( | unsigned int | trk_num, |
const MIDITimedMessage & | msg | ||
) |
Deletes the note msg (msg must be a Note On) from the track _trk_num. See MIDITrack::DeleteNote() for details.
|
protected |
The common clock per beat timing parameter for all tracks (this is the number of MIDI ticks for a quarter note).