Better random number generation
Hi, I'm trying to create a plugin that has a random seed on each new instance.
As of now, all "random" objects on all instances of a plugin share the same seed on load.
I need each instance to start with a unique(ish) seed, and I'm failing to see a way to do that.
Any thoughts?
[random] accepts a seed argument.
[set seed 0] should work for you. See help file.
The problem is that on a project load all instances of the plugin are loaded at the same time, and since the seed 0 works based on the system time, all instances have the same random numbers generated.
Use a single zero-seeded random to generate a sequence of numbers to use as seeds for the other random objects??
They're all separate instances of a plugin
Hey, how's this?
Thanks Nouserid, this is an interesting example I'll try incorporating!
Would you mind explaining the concept here?
You're welcome :) The argument #0 in the loadmess object will generate a unique number for each instance of an abstraction or bpatcher. It works with lots of other objects too!
This actually doesn't work in RNBO; it's an invalid argument.
I use this for all my random number generation (seems to work fine in RNBO too).
[expr (random(-32768, 32767) + 32768) / 65536.]