This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/RandSeed.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
class:: RandSeed
summary:: Sets the synth's random generator seed.
related:: Classes/RandID
categories::  UGens>Generators>Stochastic, UGens>Random


Description::

When the trigger signal changes from nonpositive to positive, the synth's
random generator seed is reset to the given value. All synths that use
the same random number generator reproduce the same sequence of numbers
again.


See  link::Classes/RandID::  UGen for setting the randgen id and
link::Reference/randomSeed:: for the client side equivalent.


classmethods::

method::kr, ir

argument::trig

The trigger. Trigger can be any signal. A trigger happens when
the signal changes from non-positive to positive.


argument::seed
The random seed.

Examples::

code::

// start a noise patch

(
{
var noise, filterfreq;
noise = WhiteNoise.ar(0.05 ! 2) + Dust2.ar(70 ! 2);
filterfreq = LFNoise1.kr(3, 5500, 6000);
Resonz.ar(noise * 5, filterfreq, 0.5) + (noise * 0.5)
}.play;
)

// reset the seed at a variable rate
(
x = { arg seed=1956;
		RandSeed.kr(Impulse.kr(MouseX.kr(0.1, 100)), seed);
}.play;
)



x.set(\seed, 2001);
x.set(\seed, 1798);
x.set(\seed, 1902);


// above you can see that the sound of the LFNoise1 is not exactly reproduced (filter frequency)
// this is due to interference between the internal phase of the noise ugen and the
// seed setting rate.

// a solution is to start a new synth:

(
SynthDef("pseudorandom", { arg out, sustain=1, seed=1967, id=0;
	var noise, filterfreq;
	RandID.ir(id);
	RandSeed.ir(1, seed);


	noise = WhiteNoise.ar(0.05 ! 2) + Dust2.ar(70 ! 2);
	filterfreq = LFNoise1.kr(3, 5500, 6000);

	Out.ar(out,
		Resonz.ar(noise * 5, filterfreq, 0.5) + (noise * 0.5)
		*
		Line.kr(1, 0, sustain, doneAction:2)
	)

}).add;
)

// the exact same sound is reproduced
(
fork {
	loop {
		Synth("pseudorandom");
		1.1.wait; // wait a bit longer than sustain, so sounds don't overlap
	}
}
)

// changing the rand seed changes the sound:

(
fork {
	(1902..2005).do { |seed|
		seed.postln;
		3.do {
			Synth("pseudorandom", [\seed, seed]);
			1.1.wait;
		}
	}
}
)

// cd skipper
(
fork {
	(1902..2005).do { |seed|
		seed.postln;
		rrand(4,10).do {
			Synth("pseudorandom", [\seed, seed, \sustain, 0.05]);
			0.06.wait;
		}
	}
}
)

// if the sounds overlap, this does not work as expected anymore
// sounds vary.

(
fork {
	loop {
		Synth("pseudorandom");
		0.8.wait; // instead of 1.1
	}
}
)

// rand id can be used to restrict the resetting of the seed to each voice:

(
fork {
	var id=0;
	(1902..2005).do { |seed|
		seed.postln;
		3.do {
			Synth("pseudorandom", [\seed, seed, \id, id]);
			id = id + 1 % 16; // there is 16 different random generators
			0.8.wait;
		}
	}
}
)

::