understanding poly~ and mc.poly~

ufk's icon

I want to execute a portion of a code, several times, each time with different values, all fired at the same time.

I'm learning max and I want that whenever i get a notein, to execute my portion of code a dynamic (10-100) amount of times with the notein parameters.

I learned the poly~ is the way to go.
I created a sub-patch called ufk-arpeggiator-sound-pitch, so when I create a "poly~ ufk-arpeggiator-sound-pitch 10",, it creates 10 instances of my sub-patch.

I replaced my sub-patch with 'in' and 'out' elements to go along with the poly~ format and I do get the inlets and outlets shown... but the thing is that i'm still a bit confused about how poly works.

in my case that I work with midi notes, there is no reason to use mc.poly~ over poly~ right ?
when I send one midi note to the poly~, it executes all 10 replication of itself? how does it work ?

in general my vision that that it does execute 10 replications of itself.. and each replication can have slightly different values.. and that each midi note executes all replications.. but I'm probably wrong :)

I have 3 variables, delay, pitch and volume. to each instance I want to have different initialised parameters.

any information regarding this issue would be greatly appreciated.

thank you

Florent Ghys's icon

before Max8, poly~ was the best way to go if you wanted to do something multiple times
to my understanding, mc is a sort of easier way to deal with poly~
give mc a try and post a patch if you're having issues



ufk's icon

i still fail to understand the difference between one or 10 instances of mc.poly~ and it's proper usage.

this is the code that i used mc.poly~ on with 10 instances

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


is there a way inside the mc.poly~ code to know which instance is it and based on that to change some values?

does it mean that when data comes into the inlets of the mc.poly~ elements all of the instances are executed at the same time?

when a midi note comes in, I want to create several voices, each one of them changes the pitch, delay and velocity a bit. is this the right direction ?

in general I would prefer that the user will have a knob to decide how many voices instead of me placing it in mc.poly~ as a parameter

Florent Ghys's icon

sorry I wish I could help mc but I don't this stuff well

it could be very easy to implement this with a regular poly~ though: "poly~ mypatch 10" and then you send a message target $1 before sending anything to the inlets.
target 0 send the message to all instances, target 1 to the first instance only, target 2 to the second...

ufk's icon

ohh that's good!!! thanks didn't know about the target messages.
it seems like what I need can be easier implemented if I'll add nodejs code or java code.

I'll create an array of objects for the delay, pitch and velocity that should be appended to the original value.
i'll do a foreach loop on each item in the array and send a target message with the array index id+1 and then send the relevant values to the poly~. does that seem like a proper way to resolve this?

can it be done purely in max ?

Florent Ghys's icon

if you want to work with arrays, check out the coll object

ufk's icon

tanks again! coll looks great, is there a way to tell coll to send all the messages at once?
I noticed that on each bang message, it sends one item in the list

Roman Thilenius's icon

you can do "dump" or you can do [uzi 200] to [coll]

ufk's icon

yay! i'm so excited to continue learning max.. looks like that's all I need for now.
thank you so much for everything