Reset RandSeed with a control

Works this way:


(
Ndef(\foo, { 
	RandSeed.kr(Impulse.kr(\seedResetFreq.kr(2)), 1234);
	SinOsc.ar(LFNoise0.ar(220).range(0.5,1).lag(0.01) * 440)!2 * 0.2
}).play;
)

but does not this way:

(
Ndef(\foo, { 
	RandSeed.kr(\t.tr(1), 1234);
	SinOsc.ar(LFNoise0.ar(220).range(0.5,1).lag(0.01) * 440)!2 * 0.2
}).play;
)

(
r = Tdef (\a, { 
	inf.do{
		Ndef(\foo).set(\t, 1.0);
		0.001.wait.postln;
	}  
}).play;
)


a bug maybe?

Can you describe in what way it doesn’t work? The following works here, minus a bit of weird behaviour at the beginning where they initialise (potentially a bug, but I don’t think it is the one you are talking about).

(
Ndef(\foo, { 
	RandSeed.kr(Impulse.kr(\seedResetFreq.kr(0.25)), 1234);
	Demand.kr(Impulse.kr(1), 0, Drand((0..10000), inf)).poll(2);
	Silent.ar
}).play;

Ndef(\foo).set(\seedResetFreq, 4.reciprocal)

)

// above produces the same 4 numbers in a sequence as the following (after intialisation)

(
Ndef(\foo2, { 
	RandSeed.kr(\t.tr(1), 1234);
	Demand.kr(Impulse.kr(1), 0, Drand((0..10000), inf)).poll(2);
	Silent.ar
}).play;

Tdef (\a, { 
	inf.do{
		Ndef(\foo2).set(\t, 1.0);
		4.wait;
	}  
}).play;
)

mm, this one works on my side as well.
but LFNoise resetting one does not.

That’s a reset frequency of 1000 triggers/second, or a period of 1 ms.

A trigger must have at least 2 samples: 1 0 1 0 1 0 is the fastest possible stream of retriggers.

So the shortest period for retriggering at kr (assuming normal block size and 48 kHz) is 2 blocks x 64 samples/block (“blocks” cancel out) x 1 sec / 48000 samples (“samples” cancel out) = 2.6666 ms, or 375 triggers/sec.

So you were asking it to retrigger more than 2.5 times faster than it’s possible to retrigger.

Since RandSeed is kr only, it will never be able to reach 1000 resets per second (not even at 96 kHz).

hjh

Thanks James, that explains it
though what’s interesting is for .kr trigger it works even with smaller intervals (though probably it just skips part)

(
Ndef(\foo, { 
	RandSeed.kr(\t.kr(1), 1234);
	SinOsc.ar(LFNoise0.ar(220).range(0.5,1).lag(0.01) * 440)!2 * 0.2
}).play;
)


r = Tdef (\a, {
	var minStep = 64/44100;
	inf.do{
		Ndef(\foo).set(\t, 1.0);
		(minStep*0.5).wait;
		Ndef(\foo).set(\t, 0.0);
		(minStep * 0.2).wait;
	}  
}).play;
)

my mistake originally was that I was not putting a .wait after Ndef(\foo).set(\t, 0.0);