Hold note until different note is played plugin
Hello all,
I'm trying to make a small max patch to process a midi drum multipad input (every strike on a pad create a short midi note, note off is triggered after a fixed amount of time)
What I want to do is to hold the note triggered by one pad during a short period of time (i.e. 300ms) and keep sustaining it if I hit the same pad before the hold period ends without generating another midi note everytime I hit the pad. Or end the sustained note and trigger a new note only when I start hitting another pad. I also want notes to stop sustaining if I don't hit a note before the 300ms.
The patch is sort of working, but sometimes there are stucked sustained notes, that only disappear if I hit two pads at the same time, strange... I can't figure out why, I debugged everything, but I can't understand what's happening inside the "sustain" function...
If someone had any clue, I'll be deeply grateful.
Thanks in advance
Ivan
this would be my approach without sustain. I didn´t know that there is a sustain object.