diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index ded0dce4f6..effefbbb4f 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -28,10 +28,7 @@ MidiMessageSequence::MidiMessageSequence() MidiMessageSequence::MidiMessageSequence (const MidiMessageSequence& other) { - list.ensureStorageAllocated (other.list.size()); - - for (int i = 0; i < other.list.size(); ++i) - list.add (new MidiEventHolder (other.list.getUnchecked(i)->message)); + list.addCopiesOf (other.list); } MidiMessageSequence& MidiMessageSequence::operator= (const MidiMessageSequence& other) diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h index c44e448be5..d91ed8b246 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h @@ -43,10 +43,10 @@ public: MidiMessageSequence(); /** Creates a copy of another sequence. */ - MidiMessageSequence (const MidiMessageSequence& other); + MidiMessageSequence (const MidiMessageSequence&); /** Replaces this sequence with another one. */ - MidiMessageSequence& operator= (const MidiMessageSequence& other); + MidiMessageSequence& operator= (const MidiMessageSequence&); /** Destructor. */ ~MidiMessageSequence(); @@ -66,13 +66,12 @@ public: /** Destructor. */ ~MidiEventHolder(); - /** The message itself, whose timestamp is used to specify the event's time. - */ + /** The message itself, whose timestamp is used to specify the event's time. */ MidiMessage message; /** The matching note-off event (if this is a note-on event). - If this isn't a note-on, this pointer will be null. + If this isn't a note-on, this pointer will be nullptr. Use the MidiMessageSequence::updateMatchedPairs() method to keep these note-offs up-to-date after events have been moved around in the sequence @@ -83,7 +82,7 @@ public: private: //============================================================================== friend class MidiMessageSequence; - MidiEventHolder (const MidiMessage& message); + MidiEventHolder (const MidiMessage&); JUCE_LEAK_DETECTOR (MidiEventHolder) }; @@ -98,17 +97,13 @@ public: MidiEventHolder* getEventPointer (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 MidiMessageSequence::MidiEventHolder::noteOffObject */ double getTimeOfMatchingKeyUp (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 MidiMessageSequence::MidiEventHolder::noteOffObject */ int getIndexOfMatchingKeyUp (int index) const; @@ -117,7 +112,6 @@ public: int getIndexOf (MidiEventHolder* event) 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. */ @@ -125,19 +119,16 @@ public: //============================================================================== /** Returns the timestamp of the first event in the sequence. - @see getEndTime */ double getStartTime() const; /** Returns the timestamp of the last event in the sequence. - @see getStartTime */ double getEndTime() const; /** Returns the timestamp of the event at a given index. - If the index is out-of-range, this will return 0.0 */ double getEventTime (int index) const; @@ -190,7 +181,7 @@ public: //============================================================================== /** 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 + 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. */ @@ -216,7 +207,6 @@ public: bool alsoIncludeMetaEvents) const; /** Copies all midi sys-ex messages to another sequence. - @param destSequence this is the sequence to which any sys-exes in this sequence will be added @see extractMidiChannelMessages @@ -224,17 +214,14 @@ public: void extractSysExMessages (MidiMessageSequence& destSequence) const; /** Removes any messages in this sequence that have a specific midi channel. - @param channelNumberToRemove the midi channel to look for, in the range 1 to 16 */ void deleteMidiChannelMessages (int channelNumberToRemove); - /** Removes any sys-ex messages from this sequence. - */ + /** Removes any sys-ex messages from this sequence. */ void deleteSysExMessages(); /** Adds an offset to the timestamps of all events in the sequence. - @param deltaTime the amount to add to each timestamp. */ void addTimeToMessages (double deltaTime); @@ -264,12 +251,12 @@ public: //============================================================================== /** Swaps this sequence with another one. */ - void swapWith (MidiMessageSequence& other) noexcept; + void swapWith (MidiMessageSequence&) noexcept; private: //============================================================================== friend class MidiFile; - OwnedArray list; + OwnedArray list; JUCE_LEAK_DETECTOR (MidiMessageSequence) };