JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::MidiMessageSequence Class Reference

A sequence of timestamped midi messages. More...

#include <juce_MidiMessageSequence.h>

Collaboration diagram for juce::MidiMessageSequence:

Classes

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

Public Member Functions

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

Private Member Functions

MidiEventHolderaddEvent (MidiEventHolder *, double)
 

Private Attributes

OwnedArray< MidiEventHolderlist
 

Friends

class MidiFile
 

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

{Audio}

Constructor & Destructor Documentation

◆ MidiMessageSequence() [1/3]

juce::MidiMessageSequence::MidiMessageSequence ( )

Creates an empty midi sequence object.

◆ MidiMessageSequence() [2/3]

juce::MidiMessageSequence::MidiMessageSequence ( const MidiMessageSequence )

Creates a copy of another sequence.

◆ MidiMessageSequence() [3/3]

juce::MidiMessageSequence::MidiMessageSequence ( MidiMessageSequence &&  )
noexcept

Move constructor.

◆ ~MidiMessageSequence()

juce::MidiMessageSequence::~MidiMessageSequence ( )

Destructor.

Member Function Documentation

◆ addEvent() [1/3]

MidiEventHolder* juce::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
newMessagethe new message to add (an internal copy will be made)
timeAdjustmentan optional value to add to the timestamp of the message that will be inserted
See also
updateMatchedPairs

◆ addEvent() [2/3]

MidiEventHolder* juce::MidiMessageSequence::addEvent ( 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
newMessagethe new message to add (an internal copy will be made)
timeAdjustmentan optional value to add to the timestamp of the message that will be inserted
See also
updateMatchedPairs

◆ addEvent() [3/3]

MidiEventHolder* juce::MidiMessageSequence::addEvent ( MidiEventHolder ,
double   
)
private

◆ addSequence() [1/2]

void juce::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
otherthe sequence to add from
timeAdjustmentDeltaan amount to add to the timestamps of the midi events as they are read from the other sequence
firstAllowableDestTimeevents will not be added if their time is earlier than this time. (This is after their time has been adjusted by the timeAdjustmentDelta)
endOfAllowableDestTimesevents 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)

◆ addSequence() [2/2]

void juce::MidiMessageSequence::addSequence ( const MidiMessageSequence other,
double  timeAdjustmentDelta 
)

Merges another sequence into this one.

Remember to call updateMatchedPairs() after using this method.

Parameters
otherthe sequence to add from
timeAdjustmentDeltaan amount to add to the timestamps of the midi events as they are read from the other sequence

◆ addTimeToMessages()

void juce::MidiMessageSequence::addTimeToMessages ( double  deltaTime)
noexcept

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

Parameters
deltaTimethe amount to add to each timestamp.

◆ begin()

MidiEventHolder** juce::MidiMessageSequence::begin ( ) const
noexcept

Iterator for the list of MidiEventHolders.

◆ clear()

void juce::MidiMessageSequence::clear ( )

Clears the sequence.

◆ createControllerUpdatesForTime()

void juce::MidiMessageSequence::createControllerUpdatesForTime ( int  channelNumber,
double  time,
Array< 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
channelNumberthe midi channel to look for, in the range 1 to 16. Controllers for other channels will be ignored.
timethe 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
resultMessagesan 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.

◆ deleteEvent()

void juce::MidiMessageSequence::deleteEvent ( int  index,
bool  deleteMatchingNoteUp 
)

Deletes one of the events in the sequence.

Remember to call updateMatchedPairs() after removing events.

Parameters
indexthe index of the event to delete
deleteMatchingNoteUpwhether to also remove the matching note-off if the event you're removing is a note-on

◆ deleteMidiChannelMessages()

void juce::MidiMessageSequence::deleteMidiChannelMessages ( int  channelNumberToRemove)

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

Parameters
channelNumberToRemovethe midi channel to look for, in the range 1 to 16

◆ deleteSysExMessages()

void juce::MidiMessageSequence::deleteSysExMessages ( )

Removes any sys-ex messages from this sequence.

◆ end()

MidiEventHolder** juce::MidiMessageSequence::end ( ) const
noexcept

Iterator for the list of MidiEventHolders.

◆ extractMidiChannelMessages()

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

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

Parameters
channelNumberToExtractthe midi channel to look for, in the range 1 to 16
destSequencethe sequence that the chosen events should be copied to
alsoIncludeMetaEventsif true, any meta-events (which don't apply to a specific channel) will also be copied across.
See also
extractSysExMessages

◆ extractSysExMessages()

void juce::MidiMessageSequence::extractSysExMessages ( MidiMessageSequence destSequence) const

Copies all midi sys-ex messages to another sequence.

Parameters
destSequencethis is the sequence to which any sys-exes in this sequence will be added
See also
extractMidiChannelMessages

◆ getEndTime()

double juce::MidiMessageSequence::getEndTime ( ) const
noexcept

Returns the timestamp of the last event in the sequence.

See also
getStartTime

◆ getEventPointer()

MidiEventHolder* juce::MidiMessageSequence::getEventPointer ( int  index) const
noexcept

Returns a pointer to one of the events.

◆ getEventTime()

double juce::MidiMessageSequence::getEventTime ( int  index) const
noexcept

Returns the timestamp of the event at a given index.

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

◆ getIndexOf()

int juce::MidiMessageSequence::getIndexOf ( const MidiEventHolder event) const
noexcept

Returns the index of an event.

◆ getIndexOfMatchingKeyUp()

int juce::MidiMessageSequence::getIndexOfMatchingKeyUp ( int  index) const
noexcept

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

◆ getNextIndexAtTime()

int juce::MidiMessageSequence::getNextIndexAtTime ( double  timeStamp) const
noexcept

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.

◆ getNumEvents()

int juce::MidiMessageSequence::getNumEvents ( ) const
noexcept

Returns the number of events in the sequence.

◆ getStartTime()

double juce::MidiMessageSequence::getStartTime ( ) const
noexcept

Returns the timestamp of the first event in the sequence.

See also
getEndTime

◆ getTimeOfMatchingKeyUp()

double juce::MidiMessageSequence::getTimeOfMatchingKeyUp ( int  index) const
noexcept

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

◆ operator=() [1/2]

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

Replaces this sequence with another one.

◆ operator=() [2/2]

MidiMessageSequence& juce::MidiMessageSequence::operator= ( MidiMessageSequence &&  )
noexcept

Move assignment operator.

◆ sort()

void juce::MidiMessageSequence::sort ( )
noexcept

Forces a sort of the sequence.

You may need to call this if you've manually modified the timestamps of some events such that the overall order now needs updating.

◆ swapWith()

void juce::MidiMessageSequence::swapWith ( MidiMessageSequence )
noexcept

Swaps this sequence with another one.

◆ updateMatchedPairs()

void juce::MidiMessageSequence::updateMatchedPairs ( )
noexcept

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

Call this after re-ordering messages 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.

Friends And Related Function Documentation

◆ MidiFile

friend class MidiFile
friend

Member Data Documentation

◆ list

OwnedArray<MidiEventHolder> juce::MidiMessageSequence::list
private

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