LMMS
Loading...
Searching...
No Matches
water::MidiMessageSequence Class Reference

#include <MidiMessageSequence.h>

Classes

class  MidiEventHolder

Public Member Functions

 MidiMessageSequence ()
 MidiMessageSequence (const MidiMessageSequence &)
MidiMessageSequenceoperator= (const MidiMessageSequence &)
 ~MidiMessageSequence ()
void clear ()
int getNumEvents () const noexcept
MidiEventHoldergetEventPointer (int index) const noexcept
double getStartTime () const noexcept
double getEndTime () const noexcept
double getEventTime (int index) const noexcept
MidiEventHolderaddEvent (const MidiMessage &newMessage, double timeAdjustment=0)
void addSequence (const MidiMessageSequence &other, double timeAdjustmentDelta)
void updateMatchedPairs () noexcept
void sort () noexcept
void swapWith (MidiMessageSequence &) noexcept

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

Constructor & Destructor Documentation

◆ MidiMessageSequence() [1/2]

water::MidiMessageSequence::MidiMessageSequence ( )

Creates an empty midi sequence object.

◆ MidiMessageSequence() [2/2]

water::MidiMessageSequence::MidiMessageSequence ( const MidiMessageSequence & other)

Creates a copy of another sequence.

◆ ~MidiMessageSequence()

water::MidiMessageSequence::~MidiMessageSequence ( )

Destructor.

Member Function Documentation

◆ addEvent()

MidiMessageSequence::MidiEventHolder * water::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

◆ addSequence()

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

◆ clear()

void water::MidiMessageSequence::clear ( )

Clears the sequence.

◆ getEndTime()

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

Returns the timestamp of the last event in the sequence.

See also
getStartTime

◆ getEventPointer()

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

Returns a pointer to one of the events.

◆ getEventTime()

double water::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

◆ getNumEvents()

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

Returns the number of events in the sequence.

◆ getStartTime()

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

Returns the timestamp of the first event in the sequence.

See also
getEndTime

◆ operator=()

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

Replaces this sequence with another one.

◆ sort()

void water::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 water::MidiMessageSequence::swapWith ( MidiMessageSequence & other)
noexcept

Swaps this sequence with another one.

◆ updateMatchedPairs()

void water::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.

◆ MidiFile

friend class MidiFile
friend

Member Data Documentation

◆ list

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

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