Poly~ voice stealing with long sustained (adsr~) notes

musoise's icon

Hi all,
Is it possible for poly~ to steal voices from voices that have already had their respective 'note off', rather than just steal the longest-held note? So, for example, say I have a 4-voice patch with the adsr sustain set to 7000ms. Voice 1 is continually held but voices 2 thru 4 are quick short stabs with a long sustain. Is it possible for poly~ to only target this pool of three voices whilst voice 1 is still in use? I keep trying to think of ways of approaching this but I get nowhere.

Any help is appreciated!!

Jean-Francois Charles's icon

I believe that with steal on, poly~ will forward a note message to the oldest activated voice, even when marked busy. But when your "voice started a long time ago" receives the note message, you don't have to play a new note! You can yourself decide that the voice, if it has been playing the note for, say, more than 1 second, then will not play a new note if it receives a request while busy, but rather forward the message out of the poly~, and you will feed it back to the poly~. The beautiful problem is that poly~ will then forward it to the oldest triggered voice, and... unfortunately, it's the same voice... that won't work.
Unless before forwarding the note message out of the poly~, the "voice triggered a long time ago" triggers itself again with a quick busy-off / busy-on...
That should work, except if I'm missing something, which is likely, since I haven't tried it (yet).

musoise's icon

Thanks for the reply! That might work, a pseudo-reset of the mute flag on the active voice so that it sends it to, say, the second oldest voice rather than the first? It may be that the problem I originally had may still occur, since from what I can tell poly's voice stealing algorithm steals voices no matter if midi key that is triggering them is still held down or not. So if you played four notes - and still had them held down - and then played a fifth, with voice stealing it would take that first held note. A best way to say is, can poly~ have some sort of adaptive voice stealing whereby it knows the max polyphony and temporarily shuts off when it reaches that max?

Jean-Francois Charles's icon

Let me rephrase to make sure I understand: you want to authorize stealing only when less than 4 keys are pressed. That is, you want steal off when the number of pressed keys is 4, steal on when the number of keys pressed is less than 4. So, if I understand, you want to authorize stealing only during the "Release" part of your voice synthesis.
Well, if that's what you want, it might be enough to do something like that, paying attention at the sequence of events (when you give the steal to your poly~).

Max Patch
Copy patch and select New From Clipboard in Max.

musoise's icon

Thanks! Yeah, that's sort of what I want it to do. Can poly~ do targeted voice stealing? So, voices 1, 3 & 4 are held down and voice 2 is in the 'release' phase so poly~ only steals voice 2 whilst 1, 3 & 4 are yet to receive their 'note off'?

Jean-Francois Charles's icon

Nope, I'm afraid poly~ will target the oldest "busy" voice.
Another approach to your problem would be to not use steal at all, but instead, to un-busy a voice as soon as it's released. That will simply allow a new midinote or note message to get in. Then, it's your job to design the voice so that there is no click, etc. Basically, you would have to do the same "in-voice" work when you allow stealing, so, in my opinion, it would be easier to proceed this way: you don't use steal, you unbusy a voice as soon as it's in the release phase, and you deal with incoming new note if/when than happens.

musoise's icon

Yeah, I think that is the way to go. Thanks for your help, though! So far I've used a mixture of coll, counter and various "+" and "==" to create a note-off history that removes itself at the end of sustain phase meaning I can leave the voice stealing function alone. Within poly~ itself I am using routepass as a way of a voice 'validator' from the thispoly~ object so I can target the oldest note-off still its sustain phase, if there are no voices available at that time. If my logic is right, it will work, otherwise more trial and error!