updateMatchedPairs not doing what it's supposed to do?

Hi everyone,

Perhaps I completely misunderstand the purpose of MidiMessageSequence::updateMatchedPairs but my assumption was that this function is supposed to “fix” note-on messages that do not have a matching note-off and therefore will cause a hanging note when played back in a sequencer.

I wrote this example piece of code below. After calling updateMatchedPairs, nothing really changes in the sequence object even though I expected it to either remove the note-on or append a note-off (both could be reasonable solutions for fixing a hanging note).

juce::MidiMessageSequence sequence;
sequence.addEvent(juce::MidiMessage::noteOn(1, 60, 1.0f), 0);
DBG(sequence.getNumEvents()); // 1
sequence.updateMatchedPairs();
DBG(sequence.getNumEvents()); // 1

Could anyone explain to me what is going on here?

Thank you very much,
Jelle

No, but with only one event in your sequence, stepping into ‘updateMatchedPairs’ with the debugger should be simple, and the problem made obvious. :nerd_face:

1 Like

From the docs, it looks like the main purpose of updateMatchedPairs is to update MidiEventHolder::noteOffObject for each note-on event. Extra note-offs will only be inserted if there are two note-ons in a row on the same note + channel.

1 Like