I've created two objects that work together. One gathers the notes being played on it's input, the other functions to scale note CV's to the notes that are allowed. If no notes have been played, all notes are allowed.
There's a "clear" input to clear and start over.
Note though, that instead of the harmony factory-module's way to directly translate incoming notes to the amount of notes in the scale (if allowed 4 notes, the input will use 0,1,2,3 to play these notes, 4,5,6,7 would be next octave, no matter what their actual note-value is, resulting in a messed up order of your keys). This module will look at what the closest note allowed is below the actual played note, keeping the octave the same.
Eg. if only notes 0 and 6 are on, playing note 0 up to 11 would result in: 0,0,0,0,0,0,6,6,6,6,6,6
Also, if you'ld want the factory-kind of way of ordering the notes, you should have a look at the midi-tab in the object patcher of this harmony factory-module. Here it is shown which midi-notes control the on/off state of each of the 12 notes.
ps. it's 12 o'clock now. I haven't synced my library yet as I also want to make the other option of 'most played notes'. As this would need a different approach.
I might perhaps do the "most played notes" version later on. Maybe I'm a bit too tired from my sleep-shift at work to get my head around it and to get it being useful, but at the moment I don't really see how I could make this practical for live use.. To me, the first version seems way more useful..