Thanks @oid, I tried [spoly] but still dont't full y understood how it is working. Maybe I am not clear using english, but what I am searching to do is simply tagging the first 4 id depending on their leading symbol, and then keeping only 4 or more last active ones because I don't want to have too many active ID's.
-
[poly] for anything
-
@60hz Maybe? spoly3.pd This one keeps the symbols and just prepends the voice number. If that is not what you are looking for then tell me exactly what those 6 messages it prints out should be for the input in the screenshot.
Also fixed a bug, the note off bit still was not right.
Edit: noticed I forgot to connect a wire on that last update.
-
@60hz Realized my testing methodology was flawed and there was a bug which could cause it to fail, fixed that and had some time so cleaned it up and added the [clear( and {stop( messages, default value of 99 voices if run without arguments and an inlet for number of voices although that is done simple and brute force by stopping all voices and clearing memory first. Still not clear if you wanted the symbol to be replaced by the voice number or the voice number to be prepended though or if I am still missing what you are after. Updated in the original post.
-
Hey, this is fun!
My needs are slightly different in that I usually can't tell when a voice is going to become free to be allocated again, so I make it the voice's responsibility to tell me when it's available. Voices also have to figure out when to retrigger, which happens during voice stealing but also when commands are routed back to the voice that's currently handling a previous instance. Here's pseudo code for my allocator:
next command is issued has it already been assigned a voice? yes: send next command to that same voice no: are there free voices? yes: record that that command is being handled by that voice note the order that that voice was allocated send next command to that voice no: find the oldest allocated voice record that that command is being handled by that voice note the order that that voice was (re)allocated send next command to that voice when a voice becomes free add it back into the list of available voices clear whatever command it was previously associated with clear whatever order that it was last allocated
And then inside each voice:
next command comes in what state are we in? stopped: trigger the action, go to running state running: retrigger the action when the action is finished, go to stopped state and tell the allocator you are available
-
@jameslo said:
Hey, this is fun!
It is, spent the last few days reworking the massive abstraction I simplified the above from. Never even considered having the voice free itself when done, seems obvious now that you brought it up and easy to implement. Thanks for that one.
-
great @oid, it's working well now! (the one updated from https://forum.pdpatchrepo.info/topic/14537/poly-for-anything/16 because I think spoly3.pd was faulty)
Thanks also @jameslo for this very nice patch! It's more than I need but it is very useful.
I really think this kind of multipurpose abstraction should be shiped in puredata, along with [clone] to fullfill basic need and be consistent with Miller clone logic.