This is something that still has me totally baffled…
I have solved this for my EWI since it’s a monophonic instrument, but not my keyboard controller.
I’m thinking of the classic analog monosynth behavior, where if you have any key pressed, the sound will sustain and if you have multiple keys pressed, it remembers the order they were played in for note off messages so when you release a key, the frequency goes back to the most recent, still active MIDI note number. The velocity is set from the first note of a “slur group” (no idea what else to call it, hope that makes sense).
I’m fairly new to sclang, so examples are helpful if it’s not too much to ask…
Here’s what I think I might need to do but I don’t really know how or if this is right:
- make a function that puts the active notes into an array in the order noteOn is received
- first noteOn sets envelope gate to 1 (synthDef initialized with gate=0) and velocity; these values are set until no notes are active, at which point the gate closes and then a new velocity value is set with the next noteOn and the gate is reopened. DoneAction:0 on the Env to keep synthDef alive
- function sets the freq of a synthdef to the last MIDI note number value in the array
- noteOff messages remove corresponding MIDI notes from the array
Is this the right direction? And if so how would I set up the array?
Apologies if this is posted incorrectly or if I overlooked a previous topic that answers this… I did look for one but was unable to find anything.