Forums > MaxMSP

Working with specified random

Nov 24 2011 | 3:25 pm


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,


Nov 24 2011 | 3:43 pm

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

Nov 24 2011 | 3:52 pm

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 :)

Nov 24 2011 | 6:02 pm

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

-- Pasted Max Patch, click to expand. --

Nov 24 2011 | 10:28 pm


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

Viewing 5 posts - 1 through 5 (of 5 total)

Forums > MaxMSP