var ModwheelBypassedChordHold ("Modwheel bypasses Chord Hold") : Parameter "Off", "On" = "On" PitchbendStopsChord ("Pitchbend Wheel stops chord") : Parameter "Off", "On" = "On" StopNotesInRange ("Stop chords on notes in custom range") : Parameter "Off", "On" = "On" LowestNote ("Lowest Note") : Parameter AsNoteNames C1..C5 = "C2" HighestNote ("Highest Note") : Parameter AsNoteNames C1..C5 = "C3" StopSustain ("Stop Immediatly") : Parameter = 0.0 var PressedNotes : NoteTracker // Keep track of all note events SustainedNotes : NoteTracker // Just keep track of note on events that were actually played ModwheelValue : integer Function StopNotesInRangeEnabled () returns boolean result = StopNotesInRange == "On" End Function AutoSustainIsActive () returns boolean result = ModwheelValue <= 64 End Function StopAllNotes() NoteTracker_StopAllPendingNotes(SustainedNotes) SustainedNotes.NoteTracker_Clear() end Initialization SetInfoMessage("Chord Hold Plugin") SetDisplayMessage("2021 by Lukas Ruschitzka") PressedNotes.NoteTracker_Clear() SustainedNotes.NoteTracker_Clear() end On NoteEvent(m : NoteMessage) var ChordName : string oldCount : integer // Stop all notes if note in custom note range is played if BetweenNotes(NoteNameToNoteNumber(LowestNote), m, NoteNameToNoteNumber(HighestNote)) && StopNotesInRangeEnabled() then if m.IsNoteOn() then StopAllNotes() end else oldCount = PressedNotes.NoteTracker_NoteOnCount() PressedNotes.NoteTracker_GotNote(m) // Just keep track of notes if (PressedNotes.NoteTracker_NoteOnCount() == 1) && (oldCount == 0) then //We are starting a new chord so stop all pending notes NoteTracker_StopAllPendingNotes(SustainedNotes) end if IsNoteOn(m) then SendNow(m) end if IsNoteOff(m) then if AutoSustainIsActive() then SustainedNotes.NoteTracker_GotNoteOn(GetNoteNumber(m)) else SendNow(m) end end end end On PitchBendEvent(m : PitchBendMessage) StopAllNotes() end On ControlChangeEvent(m : ControlChangeMessage) var ccNumber : integer ccValue : integer ccNumber = GetCCNumber(m) ccValue = GetCCValue(m) if ccNumber == 1 then ModwheelValue = ccValue if !AutoSustainIsActive() then if PressedNotes.NoteTracker_NoteOnCount() == 0 then StopAllNotes() end end else SendNow(m) end end On ParameterValueChanged matching StopSustain if StopSustain > 0.5 then StopAllNotes() StopSustain = 0.0 // Reset for next time end End