I need some help figuring out the best way to do things, and I thought maybe somebody here might have an elegant solution to my problem.
Succinctly: I've made a patch to perform some automated note number altering functions to use in conjunction with a hardware sequencer. I've set it up so that MIDI channels 1-14 are used to play sound sources, while MIDI channel 15 is used to define the note transformations that are applied to the other 14 channels. By having my note transformations "played" by the note on messages on ch. 15, I can then sequence the transformations very easily with my hardware.
Of course, the issue is how I'm going to deal with notes mutated between their "note on" and "note off" message transmissions. I could use midiflush, but that's less than ideal because I can't figure out how to automate it without it killing notes that I don't want killed.
So I'm trying to figure out a more selective approach...something like having something monitoring the unaltered midi notes and remembering the associated altered note last used with it, but I can't think of a way to do that that isn't vastly labor intensive.
channel 1 gets a note-on note 60
channel 15 sends an alteration message for subsequent notes on channel 1, adding 7 semitones
channel 1 gets a note-off for note 60, which is altered to 67
If I bang midiflush whenever there's activity on ch. 15, that's going to kill the note 60 prematurely. I expect ch. 15 to be pretty busy, so this isn't really an option. I can't move the notes on ch. 15 to a place where there's nothing I don't want killed.
So it seems to me I need to build something that says, "Hey, we've got a note 60 coming in. What note was 60 altered to last time? Spit a note off on that note in case its note off was lost." But that seems to necessitate keeping track of 127 notes on 14 channels, and doubling 99% of my note-off messages.
What other ways could I approach this? I appreciate any ideas.