Sequencing randSeed

Hey, im building a sequencer creating sets of durations, repetitions and pitches and would like to sequence combinations of sets I like with their corresponding seed value in a pattern. But at the moment, i have to evaluate the function twice to get an updated set of values (see in the post window). why is that?
a.) How do i implement a Sequence of Seed Values in the pattern?
b.) is it possible to generate multiple seeds a the same time, for the ~getRandomSet and for the parameters of the fm Synthdef which are generated by random number generators and sequence them individually in a Pattern?

(
~getRandomSet = {
	arg set;
	var numSteps = rrand(10,30);
	set = set ? ();
	set.putAll((
		durations: {exprand(0.1,2)}!numSteps,
		repetitions: {5.rand}!numSteps,
		notes: {rrand(-24,24)}!numSteps,
        // added motif here
		motif: {rrand(-12,12)}!5
	))
};

// 1. set the seed
thisThread.randSeed = ~seed;

~seed = 1403411654;
//~seed = 1403251255;

// 2. generate some data
a = ~getRandomSet.();
)

(
Pdef(\fm,
	Pn(
		Pfindur(6,
			Pseed(~seed,
				Pbind(
					\instrument, \fm,

				),
			),
		), inf
	),
).play(t, quant:1);
)

You need to set the seed before using the variable.

You can sequence your choices by sequencing the numbers for the seed that produce them.

// repeat several times
Pseed(1000, Pfunc(~getRandomSet)).iter.next

Pseed(2000, Pfunc(~getRandomSet)).iter.next


Pseq([1000, 2000]).collect { |x|
	thisThread.randSeed = x;
	~getRandomSet.()
}.iter.nextN(2).postcs

thanks so much @dkmayer.
how is it implemented in the existing Pseed/Pbind combination?

Pseed(~seed,
				Pbind(
					\instrument, \fm,

This looks a bit tricky. Also your example is not reproducable, so I have to assume some things. As you probably want to have the event accessible in the Pbind I’d take a Pchain (<>) inside.
This would produce the same set data for each Pfindur, but it would also hold the random values in each Pbind.

(
~getRandomSet = {
	arg set;
	var numSteps = rrand(10,30);
	set = set ? ();
	set.putAll((
		durations: {exprand(0.1,2)}!numSteps,
		repetitions: {5.rand}!numSteps,
		notes: {rrand(-24,24)}!numSteps,
        // added motif here
		motif: {rrand(-12,12)}!5
	))
};

x = Pseed(
	Pseq([1, 2, 3], inf),
	Pfindur(
		1,
		Pstutter(inf, Pfunc(~getRandomSet)) <>
		Pbind(
			\dur, Pwhite(0.1, 0.3),
			\midinote, Pfunc { rrand(60.0, 90) }
		)
	)
).trace.play
)

x.stop

just a quick update, here is the complete pattern:

(
Pdef(\fm,
	Pn(
		Pfindur(6,
			Pseed(~seed,
				Pbind(
					\instrument, \fm,

					\legato, Pfunc({rrand(0.01,1.0)}),
					\atk, 0.02,

					\gainEnv, Pfunc{|e|
						var rel = (1 - e.atk);
						Env.perc(e.atk, rel);
					},
					
					\dur, 0.5 * (Pn(Plazy{ Pstutter(Pseq(a.repetitions,1), Pseq(a.durations,1)) },inf)),

					\octave, Pstutter(3, Pseq([3,4,5], inf)),
					\scale, Scale.minor(\just),
					\degree, Pn(Plazy{ Prout {
						a.notes.do{
							arg note,i;
							var repetitions = a.repetitions.wrapAt(i);
							repetitions.do {
								arg j;
								(note + a.motif.wrapAt(j)).yield};
						}
					}}, inf,
					),

					\amp, 0.75,
					\pan, Pwhite(-0.75,0.75,inf),
					\out, 0,
				),
			),
		), inf
	),
).play(t, quant:1);
)

Then it should work as I have described. To take over the data from the Function-generated Event you can, e.g., do this:

.) as described in my example with Pchain the data would occur in each Event newly produced by the Pbind / EventStreamPlayer. Then you can access within Pbind with Pkey or e.g., Plazy / Pfunc { |ev| ev[\motif] ... }

.) or you pass the data via a variable as you initially intended. Then the variable setting a = ... must happen in ~getRandomSet

I have tried out both ways but unfortunately I have not been succesful yet.
when i put a in ~getRandomSet I dont get a new set when i change ~seed.
When i use the Pchain like in your example Im not sure how Prout in \degree has to be changed accordingly because ~getRandomSet is no longer stored in the variable a. I was trying Pkey(\notes).do{ is this right?

				\dur, 0.5 * (Pn(Plazy{ Pstutter(Pseq(a.repetitions,1), Pseq(a.durations,1)) },inf)),

				\degree, Pn(Plazy{ Prout {
					a.notes.do{
						arg note,i;
						var repetitions = a.repetitions.wrapAt(i);
						repetitions.do {
							arg j;
							(note + a.motif.wrapAt(j)).yield};
					}
				}}, inf,
				),

You are posting a small snippet of code (also the last code that you posted was not reproducable as you didn’t post the SynthDef \fm). There might be 1000 things that could go wrong. How should anyone know ?
I could only guess is that Pseed(~seed, ... might be a source of error, as ~seed is only evaluated once, you might want to have Pfunc { ~seed }.

(
~seed = 100;

Pbind(
	\midinote, Pn(Pseed(Pfunc { ~seed }, Pwhite(60, 90, 5)), 5),
	\dur, 0.2
).play
)

// change

~seed = 200

~seed = 500

Im sorry here is the full code including the SynthDef:

(
t = TempoClock.new(60/60).permanent_(true);


SynthDef(\fm, {
	arg out=0, pan=0, amp=0.25, freq=111,
	mInd1=0.5, mInd2=0.5, mInd3=0.5, mInd4=0.5, mInd5=0.5, mInd6=0.5;

	var sig, cascade_0, cascade_1;

	//Buchla LPG
	var lpgoffset=0, lpgfilterscale=0.4, vcaness=0.75;

	//amp envelope
	var gainEnv = \gainEnv.kr(Env.newClear(8).asArray);
	gainEnv = EnvGen.kr(gainEnv, doneAction:2);

	cascade_0 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio3.kr(1), pi * 0.5).range(0, mInd3) ) * \amp_3.kr(0.5);
	cascade_0 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio2.kr(1), pi * 0.5).range(0, mInd2) + cascade_0.range(0,mInd2)) * \amp_2.kr(0.5);
	cascade_0 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio1.kr(1), pi * 0.5).range(0, mInd1) + cascade_0.range(0,mInd1)) * \amp_1.kr(0.5);


	cascade_1 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio6.kr(1), pi * 0.5).range(0, mInd6) + LocalIn.ar(1).range(0, mInd6)) * \amp_6.kr(0.5);
	cascade_1 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio5.kr(1), pi * 0.5).range(0, mInd5) + cascade_1.range(0,mInd5)) * \amp_5.kr(0.5);
	cascade_1 = SinOsc.ar(freq, SinOsc.ar(freq * \ratio4.kr(1), pi * 0.5).range(0, mInd4) + cascade_1.range(0,mInd4)) * \amp_4.kr(0.5);

	LocalOut.ar(cascade_1 * \fb.kr(0.9));

	sig = Mix([cascade_0, cascade_1]);
	sig = LeakDC.ar(sig);

	sig = sig * gainEnv;

	sig = LPG.ar(
        input: sig,
        controlinput: gainEnv,
        controloffset: lpgoffset,
        controlscale: lpgfilterscale,
		vca: vcaness,
		resonance: \res.kr(1.1),
        lowpassmode:1,
        linearity:1
    );

	sig = SoftClipAmp8.ar(sig, 0.5);
	sig = Pan2.ar(sig, pan, amp);
	sig = sig + NHHall.ar(sig, 0.4);
	Out.ar(out, sig)
}).add;
)

(
~getRandomSet = {
	arg set;
	var numSteps = rrand(10,30);
	set = set ? ();
	set.putAll((
		durations: {exprand(0.1,2)}!numSteps,
		repetitions: {5.rand}!numSteps,
		notes: {rrand(-24,24)}!numSteps,
        // added motif here
		motif: {rrand(-12,12)}!5
	));
};
)

(
~seed = 1403411654;
//~seed = 1403251255;

thisThread.randSeed = ~seed;

a = ~getRandomSet.();

Pdef(\fm,
	Pn(
		Pfindur(6,
			Pseed(Pn(Plazy({~seed}),inf),
				Pbind(
					\instrument, \fm,

					\legato, Pfunc({rrand(0.01,1.0)}),
					\atk, 0.02,

					\gainEnv, Pfunc{|e|
						var rel = (1 - e.atk);
						Env.perc(e.atk, rel);
					},

					\durMul, 0.5, //multiply duration
					\dur, Pkey(\durMul) * (Pn(Plazy{ Pstutter(Pseq(a.repetitions,1), Pseq(a.durations,1)) },inf)),

					\octave, Pstutter(3, Pseq([3,4,5], inf)),
					\scale, Scale.minor(\just),
					\degree, Pn(Plazy{ Prout {
						a.notes.do{
							arg note,i;
							var repetitions = a.repetitions.wrapAt(i);
							repetitions.do {
								arg j;
								(note + a.motif.wrapAt(j)).yield};
						}
					}}, inf,
					),

					//Buchla LPG Parameters
					\lpgoffset, Pfunc({LFSaw.kr(0.1).range(0.0,0.1)}),
					\lpgfilterscale, Pfunc({LFNoise2.kr(0.1).range(0.4,0.95)}),
					\vcaness, Pfunc({LFNoise2.kr(1).unipolar}),
					\res, 1.1,

					//FM Parameters
					\ratio3, 0,
					\ratio2, 0,
					\ratio1, 0,

					\ratio6, 0.251,
					\ratio5, 0,
					\ratio4, 0,

					\mInd3, 1.462,
					\mInd2, 1.938,
					\mInd1, 2.873,

					\mInd6, 1.065,
					\mInd5, 1.793,
					\mInd4, 3.283,

					\amp3, 0.629,
					\amp2, 0.241,
					\amp1, 0.288,

					\amp6, 0.780,
					\amp5, 0.034,
					\amp4, 0.433,

					\fb, 0.9,

					\amp, 0.75,
					\pan, Pwhite(-0.75,0.75,inf),
					\out, 0,
				),
			),
		), inf
	),
).play(t, quant:1);
)

Ok, you need the seed for the generation of a. Then I’d omit Pseed, e.g.

(
~seed = 1403411654;
//~seed = 1403251255;

	
~makeSeed = { |seed|
	thisThread.randSeed = seed;
	a = ~getRandomSet.();
};

~makeSeed.(~seed);

Pdef(\fm,
	Pn(
		Pfindur(2,
			Pbind(
					\instrument, \fm,

					\legato, Pfunc({rrand(0.01,1.0)}),
					\atk, 0.02,

					\gainEnv, Pfunc{|e|
						var rel = (1 - e.atk);
						Env.perc(e.atk, rel);
					},

					\durMul, 0.5, //multiply duration
					\dur, Pkey(\durMul) * (Pn(Plazy{ Pstutter(Pseq(a.repetitions,1), Pseq(a.durations,1)) },inf)),

					\octave, Pstutter(3, Pseq([3,4,5], inf)),
					\scale, Scale.minor(\just),
					\degree, Pn(Plazy{ Prout {
						a.notes.do{
							arg note,i;
							var repetitions = a.repetitions.wrapAt(i);
							repetitions.do {
								arg j;
								(note + a.motif.wrapAt(j)).yield};
						}
					}}, inf,
					),

					//Buchla LPG Parameters
					\lpgoffset, Pfunc({LFSaw.kr(0.1).range(0.0,0.1)}),
					\lpgfilterscale, Pfunc({LFNoise2.kr(0.1).range(0.4,0.95)}),
					\vcaness, Pfunc({LFNoise2.kr(1).unipolar}),
					\res, 1.1,

					//FM Parameters
					\ratio3, 0,
					\ratio2, 0,
					\ratio1, 0,

					\ratio6, 0.251,
					\ratio5, 0,
					\ratio4, 0,

					\mInd3, 1.462,
					\mInd2, 1.938,
					\mInd1, 2.873,

					\mInd6, 1.065,
					\mInd5, 1.793,
					\mInd4, 3.283,

					\amp3, 0.629,
					\amp2, 0.241,
					\amp1, 0.288,

					\amp6, 0.780,
					\amp5, 0.034,
					\amp4, 0.433,

					\fb, 0.9,

					\amp, 0.75,
					\pan, Pwhite(-0.75,0.75,inf),
					\out, 0,
				)
		), inf
	)
).play(t, quant:1);
)

~makeSeed.(70);

thanks @dkmayer. the updating of the seed works perfectly.
i will have a look if i can come with a solution for sequencing the different seeds maybe with another pattern. I also liked the idea of Pchain.

is it possible that ~makeSeed.(~seed) waits for the restart of Pfindur and is not giving a new set right away after it has been evaluated? otherwise the current set is interrupted in a non musical way. thanks