How to implement RandSeed.kr?

Question about how to implement RandSeed.kr

{
	var trigger, partials = 12;
	trigger = Dust.kr(3/7);
	Pan2.ar(		
		Mix.ar(
			{
				SinOsc.ar(exprand(50.0, 4000)) *
				EnvGen.kr(
					Env.perc(0, rrand(0.2, 3.0)),
					trigger,
					1.0.rand
				)
			}.dup(partials)
		)/partials,
		1.0.rand2
	)
}.play
)

Goal:
Enter a line of code that would use a random seed and produce the same bell collection twice in a row.

Solution of myself, which doesn’t work and I don’t see why exactly. It doesn’t produce sound


( // Let it run for a while, the strikes are random
{
	var trigger, partials = 12;
	trigger = RandSeed.kr(Dust.kr(3/7), seed:56789);
	Pan2.ar(		
		Mix.ar(
			{
				SinOsc.ar(exprand(50.0, 4000)) *
				EnvGen.kr(
					Env.perc(0, rrand(0.2, 3.0)),
					trigger,
					1.0.rand
				)
			}.dup(partials)
		)/partials,
		1.0.rand2
	)
}.play
)

RandSeed sets the seed for the whole synth. of you want to set the seed for the synth just once then:

RandSeed.ir(1,56789);

on a line all by itself will do that - just add that line to your working version

to be able to make different versions you can add a seed argument to your function…

note: the “trigger” field in RandSeed determines when the seed gets set… RandSeed can’t trigger anything.

Take another look at the RandSeed help file. You’ll see that all of the examples put RandSeed into an expression by itself. None of them try to use RandSeed’s result.

In the first example, RandSeed.kr is triggered, but it doesn’t use RandSeed.kr as a trigger.

That is, you’ve created a graph that goes Dust → RandSeed → EnvGen. But the correct graph is:

    /--> RandSeed
Dust
    \--> EnvGen

… where the trigger (Dust) feeds separately into the two other units.

var trigger = Dust.kr(3/7);
RandSeed.kr(trigger, ...);

...
	EnvGen.kr(
		...,
		trigger
	)

The actual output value of RandSeed is not documented, but I checked the source code – it’s always 0. So that explains why you didn’t get any sound.

hjh