Hi,
I'm looking for a way to generate a row, lets say of 12 elements (0-11), in a random order, but without repetition of the elements. If I use [random 12] I obviously can have the same number more than once. Any suggestion?
Thanks!
ymotion
-
Random rows
-
OK, I found the object for that : [urn]
-
i had a go with vanilla and lists to make that. I didn't test it to see how completely random it ends up being, but from what i see, it seems to work ok.
this is not an exact copy of [urn], but i never liked the way that object worked, so this is just a concise vanilla patch that outputs a list of n integers with random non-repeated values up to value n-1.
you can write the list values to a table if you want to read them using [tabread]
-
(oh, you probably wanna take the [print] object off if you use that...)
-
Hi mod,
Wow, that's a great solution. beautiful.
Why is it vanilla? I mean, I don't exactly what vanilla is, but it works on my Pd which is not.
What's the [f $0] stands for? I know that the [f $1] is the first creation argument in the abstraction...Thanks a lot
y -
it's vanilla because it uses just the basic PD objects, and doesn't rely on any external libraries from pd-extended etc. That makes it easier to use with IOS applications, etc, where licensing is an issue.
[f $0] is just a float of the $0 value. This value is unique to every individual patch or abstraction loaded in pd at one time. So, for example, if you have some abstraction named [sampleANDhold] or something like that; then every new instance of that abstraction loaded after PD is opened will have a different $0 value. Usually $0 starts at about 1000, and counts up from there. The main thing though, is that every new patch or abstraction opened will have a new $0 value until you close PD and open it again.
So, the reason why i use $0 in this patch, is to seed the [random] object.
If every instance of this abstraction uses a different $0 value, then every instance will use a different seed for [random]
otherwise, it would give the same 'random' sequence every time it is used.
-
Hi mod,
Thanks a lot for a very clear explanation. Got it.