Tzopilotl
Docs
GitHub

Writing SynthDefs

8. Random Signals

Random sources take a channel count and a rate. At Rate.audio (the default) they produce a new value every sample per channel — noise. At Rate.init they produce values once per synth instance — randomized fixed parameters, different in every node you create. Each synth instance seeds its own RNG.

FunctionDescription
frand(lo, hi, chans = 1, rate = Rate.audio)Uniform floats in [lo, hi).
irand(lo, hi, chans = 1, rate = Rate.audio)Uniform integers in [lo, hi].
urand(chans = 1, rate = Rate.audio)Uniform unipolar floats in [0, 1).
birand(chans = 1, rate = Rate.audio)Uniform bipolar floats in [-1, 1) — this is white noise at audio rate (see white).
rand64(chans = 1, rate = Rate.audio)Raw random 64-bit integers.
exprand(a, b, chans = 1, rate = Rate.audio)(common_ugens) Exponentially distributed between a and b — the right distribution for frequencies.
-- Eight oscillators at random frequencies, fixed per instance,
-- with slowly moving random amplitudes:
let freqs    = exprand(100, 600, 8, Rate.init);
let ampFreqs = exprand(0.1, 0.5, 8, Rate.init);
let amps     = ampFreqs fsinosc(urand(8, Rate.init)) uni;
freqs fsinosc * amps |> sum(2) * 0.1 outlet

For noise colors and random event generators built on these (pink, dust, velvet, …) see §15.8.

↑ Back to top