File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
modules/juce_audio_basics/midi Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -235,14 +235,14 @@ void MidiMessageSequence::sort() noexcept
235235 [] (const MidiEventHolder* a, const MidiEventHolder* b) { return a->message .getTimeStamp () < b->message .getTimeStamp (); });
236236}
237237
238- void MidiMessageSequence::updateMatchedPairs () noexcept
238+ void MidiMessageSequence::updateMatchedPairs (bool regardNoteOnEventsWithVel0AsNoteOff ) noexcept
239239{
240240 for (int i = 0 ; i < list.size (); ++i)
241241 {
242242 auto * meh = list.getUnchecked (i);
243243 auto & m1 = meh->message ;
244244
245- if (m1.isNoteOn ())
245+ if (m1.isNoteOn (!regardNoteOnEventsWithVel0AsNoteOff ))
246246 {
247247 meh->noteOffObject = nullptr ;
248248 auto note = m1.getNoteNumber ();
@@ -256,13 +256,13 @@ void MidiMessageSequence::updateMatchedPairs() noexcept
256256
257257 if (m.getNoteNumber () == note && m.getChannel () == chan)
258258 {
259- if (m.isNoteOff ())
259+ if (m.isNoteOff (regardNoteOnEventsWithVel0AsNoteOff ))
260260 {
261261 meh->noteOffObject = meh2;
262262 break ;
263263 }
264264
265- if (m.isNoteOn ())
265+ if (m.isNoteOn (!regardNoteOnEventsWithVel0AsNoteOff ))
266266 {
267267 auto newEvent = new MidiEventHolder (MidiMessage::noteOff (chan, note));
268268 list.insert (j, newEvent);
Original file line number Diff line number Diff line change @@ -230,8 +230,11 @@ class JUCE_API MidiMessageSequence
230230 Call this after re-ordering messages or deleting/adding messages, and it
231231 will scan the list and make sure all the note-offs in the MidiEventHolder
232232 structures are pointing at the correct ones.
233+
234+ @param regardNoteOnEventWithVel0AsNoteOff if true, note-on events with velocity 0
235+ will be regarded as note-off
233236 */
234- void updateMatchedPairs () noexcept ;
237+ void updateMatchedPairs (bool regardNoteOnEventsWithVel0AsNoteOff = true ) noexcept ;
235238
236239 /* * Forces a sort of the sequence.
237240 You may need to call this if you've manually modified the timestamps of some
You can’t perform that action at this time.
0 commit comments