Working with specified random

Nov 24, 2011 at 3:25pm

Working with specified random

Hello,

I am trying to build something that will do the following:

If i have 5 toggles, where 1st toggle (if enabled) will output 1, the 2nd toggle (if enabled) will output 2, and so on till the 5th toggle. What i want to do from here, is to get a list from all of the enabled toggles, so if toggle 1, 3, 5 are enabled, i would get those numbers stored.

Now this is the part which i can not figure out: i want to make a random object, which will generate random numbers from 1 to 5, and IF it generates a number that does not match that list from the toggles i mentioned earlier – lets say random generates 2, I want the end result to select the closest number that is stored from those 5 toggles.

So lets say i have toggles 1, 3 and 5 enabled, and random generates 2, then the end result would be either 1 or 3, if random generates 4, then either 3 or 5 will be the end result.

My knowledge of max/msp is not great, i have tried to do this with IF object and tabble object, but i cant seem to complete what set forth to making.

I appreciate your help,

pfke

#60220
Nov 24, 2011 at 3:43pm

[if] is not wrong, but i would use [zl nth] and not table.

#216781
Nov 24, 2011 at 3:52pm

You think that this whole thing could be done in a much more simple way. What i mean is, random object generates a range of numbers, but ultimately all i really want to do, is to have certain numbers, which then could be randomly selected.

Thanks for the help, i have help file for zl allready opened :)

#216782
Nov 24, 2011 at 6:02pm

one way to use an “indexing list” to pick from a “values list”:

– Pasted Max Patch, click to expand. –
#216783
Nov 24, 2011 at 10:28pm

Wicked!

That patch you attached, does exactly what i was aiming for, thanks for the post, mate, ill have a good study on that patch :)

#216784

You must be logged in to reply to this topic.