hey folks! looking for some advice here. i have a custom instrument setup where i can switch between timbres based on a certain key range. there are eight ranges of four MIDI notes each and any one of these regions can be assigned to the base instrument, running on MIDI channel 1, or any one of five other instruments (running on channels 2-6). the switching method basically works as it's supposed to, but there are two strange behaviors
if i play quickly it can result in stuck notes as i switch between instruments. i have a method where i can send note off data to instruments via the interface, which mostly works to turn notes off, but not 100% of the time.
if i hold a note in one region down assigned to one instrument, and then quickly play another assigned to a different instrument, it will sometimes get confused and apply the sound from the first to the second. so if i have a piano timbre in the first region and play a key assigned to a synth timbre the piano will play notes in the second region as well for a time. i've found that if i play notes in a third different region it resets itself properly and the next time i play the second region it will be properly assigned. so in this case somehow the channel switching seems to be happening too late occasionally.
these bugs can sometimes result in interesting happy accidents, but as i work with it more (as well as playing faster or switching quickly between timbres) i want to have it be more consistent in response.
anyway here's my keyrouter object. the active region is set by the inlet. the output is rearranged to put the channel first so i can route it to the correct instrument. there's probably some kind of race condition that behaves properly when the region and timbre switching is clean (playing more staccato or detached) but if notes are held down or the speed of switching increases it starts dropping noteoffs. any input or info appreciated!