Actually, thinking this over again, one of the problems I'd like to solve is being able to hold multiple notes and return to the most recent notes after notes are released.
My first thought is to have an array, the size of which is equal to the number of practical midi note values.
When a note comes in, it's place in the array would be replaced with a number derived from a counter, which would increase with each note on.
This way the sequence of note-ons would be stored in the array.
A note off message would reset the array value to zero
the counter would reset when all notes were off.
This would need to scan the entire array in order to find the most recent note on every legato note off.
I considered a setup where note numbers would be stored in an array starting at zero index, and increasing with each fresh note, but I feel that this would require some dynamic reentry if notes were released out of order, and that is slightly intimidating.
Before I dive into this, does anyone see any immediate problems with this approach?