OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::MidiMessageSequence Class Reference

`#include <juce_MidiMessageSequence.h>`

## Classes
class | MidiEventHolder

## Public Member Functions
| MidiMessageSequence ()
| MidiMessageSequence (const MidiMessageSequence &)
MidiMessageSequence & | operator= (const MidiMessageSequence &)
| MidiMessageSequence (MidiMessageSequence &&) noexcept
MidiMessageSequence & | operator= (MidiMessageSequence &&) noexcept
| ~MidiMessageSequence ()
void | clear ()
int | getNumEvents () const noexcept
MidiEventHolder * | getEventPointer (int index) const noexcept
MidiEventHolder ** | begin () noexcept
MidiEventHolder *const * | begin () const noexcept
MidiEventHolder ** | end () noexcept
MidiEventHolder *const * | end () const noexcept
double | getTimeOfMatchingKeyUp (int index) const noexcept
int | getIndexOfMatchingKeyUp (int index) const noexcept
int | getIndexOf (const MidiEventHolder *event) const noexcept
int | getNextIndexAtTime (double timeStamp) const noexcept
double | getStartTime () const noexcept
double | getEndTime () const noexcept
double | getEventTime (int index) const noexcept
MidiEventHolder * | addEvent (const MidiMessage &newMessage, double timeAdjustment=0)
MidiEventHolder * | addEvent (MidiMessage &&newMessage, double timeAdjustment=0)
void | deleteEvent (int index, bool deleteMatchingNoteUp)
void | addSequence (const MidiMessageSequence &other, double timeAdjustmentDelta, double firstAllowableDestTime, double endOfAllowableDestTimes)
void | addSequence (const MidiMessageSequence &other, double timeAdjustmentDelta)
void | updateMatchedPairs () noexcept
void | sort () noexcept
void | extractMidiChannelMessages (int channelNumberToExtract, MidiMessageSequence &destSequence, bool alsoIncludeMetaEvents) const
void | extractSysExMessages (MidiMessageSequence &destSequence) const
void | deleteMidiChannelMessages (int channelNumberToRemove)
void | deleteSysExMessages ()
void | addTimeToMessages (double deltaTime) noexcept
void | createControllerUpdatesForTime (int channelNumber, double time, Array< MidiMessage > &resultMessages)
void | swapWith (MidiMessageSequence &) noexcept

## 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

Definition at line 37 of file juce_MidiMessageSequence.h.

## Constructor & Destructor Documentation

## ◆ MidiMessageSequence() [1/3]

juce::MidiMessageSequence::MidiMessageSequence | ( |  | ) |

Creates an empty midi sequence object.

Definition at line 31 of file juce_MidiMessageSequence.cpp.

## ◆ MidiMessageSequence() [2/3]

juce::MidiMessageSequence::MidiMessageSequence | ( | const MidiMessageSequence & | other | ) |

Creates a copy of another sequence.

Definition at line 35 of file juce_MidiMessageSequence.cpp.

## ◆ MidiMessageSequence() [3/3]

juce::MidiMessageSequence::MidiMessageSequence | ( | MidiMessageSequence && | other | ) |
| noexcept

Move constructor

Definition at line 55 of file juce_MidiMessageSequence.cpp.

## ◆ ~MidiMessageSequence()

juce::MidiMessageSequence::~MidiMessageSequence | ( |  | ) |

Destructor.

Definition at line 66 of file juce_MidiMessageSequence.cpp.

## Member Function Documentation

## ◆ addEvent() [1/2]

MidiMessageSequence::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

  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

Definition at line 172 of file juce_MidiMessageSequence.cpp.

Referenced by extractMidiChannelMessages(), and extractSysExMessages().

## ◆ addEvent() [2/2]

MidiMessageSequence::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

  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

Definition at line 177 of file juce_MidiMessageSequence.cpp.

## ◆ addSequence() [1/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

  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

Definition at line 193 of file juce_MidiMessageSequence.cpp.

## ◆ addSequence() [2/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

  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)

Definition at line 205 of file juce_MidiMessageSequence.cpp.

## ◆ addTimeToMessages()

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

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

Parameters

  deltaTime | the amount to add to each timestamp.

Definition at line 272 of file juce_MidiMessageSequence.cpp.

## ◆ begin() [1/2]

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

Iterator for the list of MidiEventHolders

Definition at line 91 of file juce_MidiMessageSequence.cpp.

## ◆ begin() [2/2]

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

Iterator for the list of MidiEventHolders

Definition at line 90 of file juce_MidiMessageSequence.cpp.

## ◆ clear()

void juce::MidiMessageSequence::clear | ( |  | ) |

Clears the sequence.

Definition at line 75 of file juce_MidiMessageSequence.cpp.

## ◆ 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

  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.

Definition at line 312 of file juce_MidiMessageSequence.cpp.

## ◆ 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

  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

Definition at line 182 of file juce_MidiMessageSequence.cpp.

## ◆ deleteMidiChannelMessages()

void juce::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

Definition at line 297 of file juce_MidiMessageSequence.cpp.

## ◆ deleteSysExMessages()

void juce::MidiMessageSequence::deleteSysExMessages | ( |  | ) |

Removes any sys-ex messages from this sequence.

Definition at line 304 of file juce_MidiMessageSequence.cpp.

## ◆ end() [1/2]

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

Iterator for the list of MidiEventHolders

Definition at line 93 of file juce_MidiMessageSequence.cpp.

## ◆ end() [2/2]

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

Iterator for the list of MidiEventHolders

Definition at line 92 of file juce_MidiMessageSequence.cpp.

## ◆ 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

  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

Definition at line 280 of file juce_MidiMessageSequence.cpp.

## ◆ extractSysExMessages()

void juce::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

Definition at line 290 of file juce_MidiMessageSequence.cpp.

## ◆ getEndTime()

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

Returns the timestamp of the last event in the sequence.

See also
  getStartTime

Definition at line 144 of file juce_MidiMessageSequence.cpp.

## ◆ getEventPointer()

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

Returns a pointer to one of the events.

Definition at line 85 of file juce_MidiMessageSequence.cpp.

## ◆ 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

Definition at line 149 of file juce_MidiMessageSequence.cpp.

## ◆ getIndexOf()

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

Returns the index of an event.

Definition at line 121 of file juce_MidiMessageSequence.cpp.

## ◆ 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

Definition at line 104 of file juce_MidiMessageSequence.cpp.

Referenced by MidiMessageSequence().

## ◆ 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.

Definition at line 126 of file juce_MidiMessageSequence.cpp.

## ◆ getNumEvents()

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

Returns the number of events in the sequence.

Definition at line 80 of file juce_MidiMessageSequence.cpp.

## ◆ getStartTime()

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

Returns the timestamp of the first event in the sequence.

See also
  getEndTime

Definition at line 139 of file juce_MidiMessageSequence.cpp.

## ◆ 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

Definition at line 95 of file juce_MidiMessageSequence.cpp.

## ◆ operator=() [1/2]

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

Replaces this sequence with another one.

Definition at line 48 of file juce_MidiMessageSequence.cpp.

## ◆ operator=() [2/2]

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

Move assignment operator

Definition at line 60 of file juce_MidiMessageSequence.cpp.

## ◆ 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.

Definition at line 225 of file juce_MidiMessageSequence.cpp.

## ◆ swapWith()

void juce::MidiMessageSequence::swapWith | ( | MidiMessageSequence & | other | ) |
| noexcept

Swaps this sequence with another one.

Definition at line 70 of file juce_MidiMessageSequence.cpp.

## ◆ 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.

Definition at line 231 of file juce_MidiMessageSequence.cpp.

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

- juce_MidiMessageSequence.h
- juce_MidiMessageSequence.cpp