MidiMessageSequence Class Reference

A sequence of timestamped midi messages. More...

List of all members.

Classes

class  MidiEventHolder
 Structure used to hold midi events in the sequence. More...

Public Member Functions

 MidiMessageSequence ()
 Creates an empty midi sequence object.
 MidiMessageSequence (const MidiMessageSequence &other)
 Creates a copy of another sequence.
MidiMessageSequenceoperator= (const MidiMessageSequence &other)
 Replaces this sequence with another one.
 ~MidiMessageSequence ()
 Destructor.
void clear ()
 Clears the sequence.
int getNumEvents () const
 Returns the number of events in the sequence.
MidiEventHoldergetEventPointer (int index) const
 Returns a pointer to one of the events.
double getTimeOfMatchingKeyUp (int index) const
 Returns the time of the note-up that matches the note-on at this index.
int getIndexOfMatchingKeyUp (int index) const
 Returns the index of the note-up that matches the note-on at this index.
int getIndexOf (MidiEventHolder *event) const
 Returns the index of an event.
int getNextIndexAtTime (double timeStamp) const
 Returns the index of the first event on or after the given timestamp.
double getStartTime () const
 Returns the timestamp of the first event in the sequence.
double getEndTime () const
 Returns the timestamp of the last event in the sequence.
double getEventTime (int index) const
 Returns the timestamp of the event at a given index.
void addEvent (const MidiMessage &newMessage, double timeAdjustment=0)
 Inserts a midi message into the sequence.
void deleteEvent (int index, bool deleteMatchingNoteUp)
 Deletes one of the events in the sequence.
void addSequence (const MidiMessageSequence &other, double timeAdjustmentDelta, double firstAllowableDestTime, double endOfAllowableDestTimes)
 Merges another sequence into this one.
void updateMatchedPairs ()
 Makes sure all the note-on and note-off pairs are up-to-date.
void extractMidiChannelMessages (int channelNumberToExtract, MidiMessageSequence &destSequence, bool alsoIncludeMetaEvents) const
 Copies all the messages for a particular midi channel to another sequence.
void extractSysExMessages (MidiMessageSequence &destSequence) const
 Copies all midi sys-ex messages to another sequence.
void deleteMidiChannelMessages (int channelNumberToRemove)
 Removes any messages in this sequence that have a specific midi channel.
void deleteSysExMessages ()
 Removes any sys-ex messages from this sequence.
void addTimeToMessages (double deltaTime)
 Adds an offset to the timestamps of all events in the sequence.
void createControllerUpdatesForTime (int channelNumber, double time, OwnedArray< MidiMessage > &resultMessages)
 Scans through the sequence to determine the state of any midi controllers at a given time.
void swapWith (MidiMessageSequence &other) throw ()
 Swaps this sequence with another one.

Static Public Member Functions

static
juce_UseDebuggingNewOperator
int 
compareElements (const MidiMessageSequence::MidiEventHolder *first, const MidiMessageSequence::MidiEventHolder *second) throw ()

Detailed Description

A sequence of timestamped midi messages.

This allows the sequence to be manipulated, and also to be read from and written to a standard midi file.

See also:
MidiMessage, MidiFile

Constructor & Destructor Documentation

MidiMessageSequence::MidiMessageSequence (  ) 

Creates an empty midi sequence object.

MidiMessageSequence::MidiMessageSequence ( const MidiMessageSequence other  ) 

Creates a copy of another sequence.

MidiMessageSequence::~MidiMessageSequence (  ) 

Destructor.


Member Function Documentation

MidiMessageSequence& MidiMessageSequence::operator= ( const MidiMessageSequence other  ) 

Replaces this sequence with another one.

void MidiMessageSequence::clear (  ) 

Clears the sequence.

int MidiMessageSequence::getNumEvents (  )  const

Returns the number of events in the sequence.

MidiEventHolder* MidiMessageSequence::getEventPointer ( int  index  )  const

Returns a pointer to one of the events.

double MidiMessageSequence::getTimeOfMatchingKeyUp ( int  index  )  const

Returns the time of the note-up that matches the note-on at this index.

If the event at this index isn't a note-on, it'll just return 0.

See also:
MidiMessageSequence::MidiEventHolder::noteOffObject
int MidiMessageSequence::getIndexOfMatchingKeyUp ( int  index  )  const

Returns the index of the note-up that matches the note-on at this index.

If the event at this index isn't a note-on, it'll just return -1.

See also:
MidiMessageSequence::MidiEventHolder::noteOffObject
int MidiMessageSequence::getIndexOf ( MidiEventHolder event  )  const

Returns the index of an event.

int MidiMessageSequence::getNextIndexAtTime ( double  timeStamp  )  const

Returns the index of the first event on or after the given timestamp.

If the time is beyond the end of the sequence, this will return the number of events.

double MidiMessageSequence::getStartTime (  )  const

Returns the timestamp of the first event in the sequence.

See also:
getEndTime
double MidiMessageSequence::getEndTime (  )  const

Returns the timestamp of the last event in the sequence.

See also:
getStartTime
double MidiMessageSequence::getEventTime ( int  index  )  const

Returns the timestamp of the event at a given index.

If the index is out-of-range, this will return 0.0

void MidiMessageSequence::addEvent ( const MidiMessage newMessage,
double  timeAdjustment = 0 
)

Inserts a midi message into the sequence.

The index at which the new message gets inserted will depend on its timestamp, because the sequence is kept sorted.

Remember to call updateMatchedPairs() after adding note-on events.

Parameters:
newMessage the new message to add (an internal copy will be made)
timeAdjustment an optional value to add to the timestamp of the message that will be inserted
See also:
updateMatchedPairs
void MidiMessageSequence::deleteEvent ( int  index,
bool  deleteMatchingNoteUp 
)

Deletes one of the events in the sequence.

Remember to call updateMatchedPairs() after removing events.

Parameters:
index the index of the event to delete
deleteMatchingNoteUp whether to also remove the matching note-off if the event you're removing is a note-on
void MidiMessageSequence::addSequence ( const MidiMessageSequence other,
double  timeAdjustmentDelta,
double  firstAllowableDestTime,
double  endOfAllowableDestTimes 
)

Merges another sequence into this one.

Remember to call updateMatchedPairs() after using this method.

Parameters:
other the sequence to add from
timeAdjustmentDelta an amount to add to the timestamps of the midi events as they are read from the other sequence
firstAllowableDestTime events will not be added if their time is earlier than this time. (This is after their time has been adjusted by the timeAdjustmentDelta)
endOfAllowableDestTimes events will not be added if their time is equal to or greater than this time. (This is after their time has been adjusted by the timeAdjustmentDelta)
void MidiMessageSequence::updateMatchedPairs (  ) 

Makes sure all the note-on and note-off pairs are up-to-date.

Call this after moving messages about or deleting/adding messages, and it will scan the list and make sure all the note-offs in the MidiEventHolder structures are pointing at the correct ones.

void MidiMessageSequence::extractMidiChannelMessages ( int  channelNumberToExtract,
MidiMessageSequence destSequence,
bool  alsoIncludeMetaEvents 
) const

Copies all the messages for a particular midi channel to another sequence.

Parameters:
channelNumberToExtract the midi channel to look for, in the range 1 to 16
destSequence the sequence that the chosen events should be copied to
alsoIncludeMetaEvents if true, any meta-events (which don't apply to a specific channel) will also be copied across.
See also:
extractSysExMessages
void MidiMessageSequence::extractSysExMessages ( MidiMessageSequence destSequence  )  const

Copies all midi sys-ex messages to another sequence.

Parameters:
destSequence this is the sequence to which any sys-exes in this sequence will be added
See also:
extractMidiChannelMessages
void MidiMessageSequence::deleteMidiChannelMessages ( int  channelNumberToRemove  ) 

Removes any messages in this sequence that have a specific midi channel.

Parameters:
channelNumberToRemove the midi channel to look for, in the range 1 to 16
void MidiMessageSequence::deleteSysExMessages (  ) 

Removes any sys-ex messages from this sequence.

void MidiMessageSequence::addTimeToMessages ( double  deltaTime  ) 

Adds an offset to the timestamps of all events in the sequence.

Parameters:
deltaTime the amount to add to each timestamp.
void MidiMessageSequence::createControllerUpdatesForTime ( int  channelNumber,
double  time,
OwnedArray< MidiMessage > &  resultMessages 
)

Scans through the sequence to determine the state of any midi controllers at a given time.

This will create a sequence of midi controller changes that can be used to set all midi controllers to the state they would be in at the specified time within this sequence.

As well as controllers, it will also recreate the midi program number and pitch bend position.

Parameters:
channelNumber the midi channel to look for, in the range 1 to 16. Controllers for other channels will be ignored.
time the time at which you want to find out the state - there are no explicit units for this time measurement, it's the same units as used for the timestamps of the messages
resultMessages an array to which midi controller-change messages will be added. This will be the minimum number of controller changes to recreate the state at the required time.
void MidiMessageSequence::swapWith ( MidiMessageSequence other  )  throw ()

Swaps this sequence with another one.

static juce_UseDebuggingNewOperator int MidiMessageSequence::compareElements ( const MidiMessageSequence::MidiEventHolder first,
const MidiMessageSequence::MidiEventHolder second 
) throw () [static]

For internal use only.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:14 2010 for JUCE by  doxygen 1.6.3