Switch Not Delivering All Note Offs

Langston Kelly's icon

Langston Kelly

4月 20 2022 | 4:05 午後

Hello,

I am building a MIDI effect which turns each note played into a major 7 chord and plays a different inversion of the chord based on the position (above, below, or same) of the note currently being played in comparison with the note played before with some variation. It seems to all be set up correctly except the switch, which I am using to switch between chord inversions, isn't delivering all note offs leaving some notes to ring out as if sustained.

I've set up a few zl.streams monitoring the output of the chord inversions, switch, and midiformat. I can see that while all note offs are being properly sent from the chords, they simply aren't making it through the switch. I have even added a pipe with a 120 ms delay between the switch and the if/then statements which control the switch with the thought that maybe the switch is just switching too fast. There seems to have been some minor improvement, but it is not enough. Increasing the delay doesn't seem to help either.

Anyone not how to fix this?

Max Patch
Copy patch and select New From Clipboard in Max.

Bill 2's icon

Bill 2

4月 20 2022 | 4:32 午後

My guess without looking at your patch (it's 2:30am so I'm outta here!) is that you're changing the switch position before the note-offs have a chance to get through. If that's the case I'd use [offer] to fix it. G'nite!

Andy Maskell's icon

Andy Maskell

4月 20 2022 | 6:39 午後

I've tested this on my laptop running Max 8.2.2 under Windows 10. It appears to work perfectly WITHOUT the pipe. The pipe is actually doing the opposite to what you might imagine and is causing the switch to change AFTER the notes have started passing through it. Indeed, using the debugger, I can assure you that the logic flow is correct in that the switch value changes before any of the incoming notes reaches it without the pipe.

What I have noticed though is that there is a lot of lag occurring between pressing a key and the notes coming out. This might be because the notes are passing through all 5 chord patchers before anything goes through the switch.

I suggest that instead of using a switch after the chord patchers that you use a gate before them:

Beyond that, I've noticed that if a second key is pressed before the first is released that there are still hung notes because the switch/gate has changed before the note off messages have passed through. So I suggest adding a midiflush before the midiout and hitting it with a bang when the switch/gate value changes. This ensures that all playing notes are sent a note off before the next chord comes through:

Here is a revised patch with the changes added:

Max Patch
Copy patch and select New From Clipboard in Max.

Langston Kelly's icon

Langston Kelly

4月 21 2022 | 12:06 午後

Wow guys, thanks for such a fast and thorough response. And Andy, thanks for taking the time to explain and update this for me. It works great!

Andy Maskell's icon

Andy Maskell

4月 21 2022 | 2:02 午後

You're welcome! Every challenge is a learning experience.