1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00
This commit is contained in:
無常 2025-12-24 00:49:10 +00:00 committed by GitHub
commit accb9ea266
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -235,14 +235,14 @@ void MidiMessageSequence::sort() noexcept
[] (const MidiEventHolder* a, const MidiEventHolder* b) { return a->message.getTimeStamp() < b->message.getTimeStamp(); }); [] (const MidiEventHolder* a, const MidiEventHolder* b) { return a->message.getTimeStamp() < b->message.getTimeStamp(); });
} }
void MidiMessageSequence::updateMatchedPairs() noexcept void MidiMessageSequence::updateMatchedPairs(bool regardNoteOnEventsWithVel0AsNoteOff) noexcept
{ {
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
auto* meh = list.getUnchecked (i); auto* meh = list.getUnchecked (i);
auto& m1 = meh->message; auto& m1 = meh->message;
if (m1.isNoteOn()) if (m1.isNoteOn(!regardNoteOnEventsWithVel0AsNoteOff))
{ {
meh->noteOffObject = nullptr; meh->noteOffObject = nullptr;
auto note = m1.getNoteNumber(); auto note = m1.getNoteNumber();
@ -256,13 +256,13 @@ void MidiMessageSequence::updateMatchedPairs() noexcept
if (m.getNoteNumber() == note && m.getChannel() == chan) if (m.getNoteNumber() == note && m.getChannel() == chan)
{ {
if (m.isNoteOff()) if (m.isNoteOff(regardNoteOnEventsWithVel0AsNoteOff))
{ {
meh->noteOffObject = meh2; meh->noteOffObject = meh2;
break; break;
} }
if (m.isNoteOn()) if (m.isNoteOn(!regardNoteOnEventsWithVel0AsNoteOff))
{ {
auto newEvent = new MidiEventHolder (MidiMessage::noteOff (chan, note)); auto newEvent = new MidiEventHolder (MidiMessage::noteOff (chan, note));
list.insert (j, newEvent); list.insert (j, newEvent);

View file

@ -230,8 +230,11 @@ public:
Call this after re-ordering messages 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 will scan the list and make sure all the note-offs in the MidiEventHolder
structures are pointing at the correct ones. structures are pointing at the correct ones.
@param regardNoteOnEventWithVel0AsNoteOff if true, note-on events with velocity 0
will be regarded as note-off
*/ */
void updateMatchedPairs() noexcept; void updateMatchedPairs(bool regardNoteOnEventsWithVel0AsNoteOff = true) noexcept;
/** Forces a sort of the sequence. /** Forces a sort of the sequence.
You may need to call this if you've manually modified the timestamps of some You may need to call this if you've manually modified the timestamps of some