Different RandSeed for the same SynthDef

Hello, if I have a SynthDef with a 30 randomized params, how can I decide to control the first 15 params by a specific RandSeed and the 15 other by another one ? So far, I am just able to use one RandSeed for all the synth.
Thanks a lot

Anyone please ? Impossible de find any examples on the documentation or on the forums. So like:

SynthDef(\Rand, {

/// one RandSeed for thoses :
var aaa =  rrand(1, 10);    
var aaa2 = rrand(10, 20);

/// another RandSeed for thoses :
var bbb  = rrand(100, 1000); 
var bbb2 = rrand(1000, 2000);

/// but both staying in the same SynthDef



Why would you want to do this? Randomness is supposed to be uniform, so it makes no difference to the distribution if you change the seed, or get the next value.

The reason why you would want to set a random seed in the first place is so that many synths can have the same random value for each subsequent call to the random number generator. If many synths are sharing the same parameters, then it would be better to generate all the values at once, store them, then initialise the synths with the same values.

You’re slightly mistaken about how this is working: rrand is called when you BUILD the SynthDef - this is controlled by thisThread.randSeed - setting this seed will control the seed value for future calls to rrand, so you can do something like this:

thisThread.randSeed = 10;
var aaa =  rrand(1, 10);    
var aaa2 = rrand(10, 20);

thisThread.randSeed = 11;
var bbb  = rrand(100, 1000); 
var bbb2 = rrand(1000, 2000);

These random values are now hard-coded into your SynthDef structure - not sure if this is desired or not.

RandSeed resets the random seed used for UGen’s for a Synth while it’s running. This would apply to things like TRand and WhiteNoise. You can’t straightforwardly use two RandSeed UGens in your SynthDef, since UGens aren’t necessarily run in the order that you specify them in code, so placing a RandSeed in between your two sets of parameters may not mean much - and in any case, random values are random values, changing the seed in between will just result in more random values :). If you want reproducible “random” values for a group of parameters, I’ve used a pattern like this:

SynthDef(\random, {
   var baseSeed, makeRand, seed1, seed1, a, b, c,d;
   baseSeed = rrand(0, 1000); // this can be deterministic also....
   makeRand  = {
        |min, max, seed|
        baseSeed = baseSeed  + 1;
        Hasher.ar(baseSeed + (seed * 1000)).linlin(-1, 1, min, max)
   seed1 = \seed1.kr(10);
   seed2 = \seed2.kr(11);

   a = makeRand.(0, 100, seed1);
   b = makeRand.(0, 400, seed1);
   c = makeRand.(0, 10, seed2);
   d = makeRand.(-0.3, 0.3, seed2);

Hasher produces a (deterministic) random number based on an input value. Your input value is a combination of (1) a synth-global value you increment each time you run the function (so that each makeRand call produces a different value), and (2) a seed value you pass in. With this setup, you can bump a seed to re-randomize ALL the values that use that seed. Your values will be random, but depend on baseSeed - this can be hard-coded (so the “random” values are the same ever time), or also randomized in whatever controlled way you want.


That’s clear, thank you taking your time to clarify this.