Browse Source

Added another MidiMessageSequence::addSequence method

tags/2021-05-28
jules 10 years ago
parent
commit
08788c3e05
2 changed files with 26 additions and 6 deletions
  1. +16
    -5
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp
  2. +10
    -1
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.h

+ 16
- 5
modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp View File

@@ -156,23 +156,34 @@ struct MidiMessageSequenceSorter
}
};
void MidiMessageSequence::addSequence (const MidiMessageSequence& other, double timeAdjustment)
{
for (int i = 0; i < other.list.size(); ++i)
{
const MidiMessage& m = other.list.getUnchecked(i)->message;
MidiEventHolder* const newOne = new MidiEventHolder (m);
newOne->message.addToTimeStamp (timeAdjustment);
list.add (newOne);
}
sort();
}
void MidiMessageSequence::addSequence (const MidiMessageSequence& other,
double timeAdjustment,
double firstAllowableTime,
double endOfAllowableDestTimes)
{
firstAllowableTime -= timeAdjustment;
endOfAllowableDestTimes -= timeAdjustment;
for (int i = 0; i < other.list.size(); ++i)
{
const MidiMessage& m = other.list.getUnchecked(i)->message;
const double t = m.getTimeStamp();
const double t = m.getTimeStamp() + timeAdjustment;
if (t >= firstAllowableTime && t < endOfAllowableDestTimes)
{
MidiEventHolder* const newOne = new MidiEventHolder (m);
newOne->message.setTimeStamp (timeAdjustment + t);
newOne->message.setTimeStamp (t);
list.add (newOne);
}


+ 10
- 1
modules/juce_audio_basics/midi/juce_MidiMessageSequence.h View File

@@ -160,7 +160,6 @@ public:
void deleteEvent (int index, bool deleteMatchingNoteUp);
/** Merges another sequence into this one.
Remember to call updateMatchedPairs() after using this method.
@param other the sequence to add from
@@ -178,6 +177,16 @@ public:
double firstAllowableDestTime,
double endOfAllowableDestTimes);
/** Merges another sequence into this one.
Remember to call updateMatchedPairs() after using this method.
@param other the sequence to add from
@param timeAdjustmentDelta an amount to add to the timestamps of the midi events
as they are read from the other sequence
*/
void addSequence (const MidiMessageSequence& other,
double timeAdjustmentDelta);
//==============================================================================
/** Makes sure all the note-on and note-off pairs are up-to-date.


Loading…
Cancel
Save