You are correct about the name, it is misleading. I like your suggestion better.
The script keeps track of the notes I’ve enabled, i.e. triads in a programmable inversion, based on a single root note. So when I modify the inversion between the root note’s NoteOn and NoteOff, I disable the wrong chord notes (except for the root) and the original third and fifth remain on.
Also, if I enable a C major triad and subsequently an E minor triad (before releasing the C) I get a Cmaj7, where the E and G are enabled again. If I then release the C, all notes of its triad are released (C-E-G) and only the B remains on. I’d prefer, that in that case only the C is released and the Em (E-G-B) remains on.
For bookkeeping, the note numbers of each NoteOn event and the (then valid) inversion are stored in two arrays (noteOnEvents and inversionEvents). When a key is released, its note is necessarily in the noteOnEvents array (as far as I know it is not possible to receive a NoteOff message without having received the corresponding NoteOn message, first).
I find its index with IndexOf() and use it to recover the corresponding inversion, such that the correct chord notes are released. This happens conditionally, see the C and Em example above. Next, the event must be deleted from the noteOnEvents and inversionEvents arrays, otherwise the arrays would overflow after 128 NoteOn events, and what’s worse the same NoteOn may occur multiple times with different inversions.
I realize that what I’m doing is probably already supported in some way by the NoteTracker, but I couldn’t find information about it.