/* Three kinds of randomness s = Server.internal.boot; z = s.scope(1); FreqScope.new; First, WhiteNoise. Uniformly distributed random number generator. This will generate values between amp and -amp */ SynthDef(\whitenoise, {arg dur, amp; var src, env; env = Line.kr(1, 1, dur, doneAction: 2); src = WhiteNoise.ar(amp); Out.ar(0, src * env); }).load(s); /* // a sample of how it sounds s.sendBundle(0.1, [\s_new, \whitenoise, -1, 0, 0, \dur, 2, \amp, 0.5]); */ /* non-uniformly distributed noise. Each sample's value is held for one period of the freq (or 1 / freq). Results is a stairstep like wave form. Less energy is given to high frequencies. */ SynthDef(\lf0, {arg dur, freq, amp; var src, env; env = Line.kr(1, 1, dur, doneAction: 2); src = LFNoise0.ar(freq, amp); Out.ar(0, src * env); }).load(s); /* s.sendBundle(0.1, [\s_new, \lf0, -1, 0, 0, \freq, 1000, \dur, 2, \amp, 0.5]); */ /* non-uniformly distributed noise. Output values are interpolated between random values chosen at 1 / freq. Linear segments are produced. Less energy is given to high frequencies. */ SynthDef(\lf1, {arg dur, freq, amp; var src, env; env = Line.kr(1, 1, dur, doneAction: 2); src = LFNoise1.ar(freq, amp); Out.ar(0, src * env); }).load(s); /* s.sendBundle(0.1, [\s_new, \lf1, -1, 0, 0, \freq, 1000, \dur, 2, \amp, 0.5]); */ /* non-uniformly distributed noise. Output values are quadratically interpolated between random values chosen at 1 / freq. Curved segments are produced. Less energy is given to high frequencies. */ SynthDef(\lf2, {arg dur, freq, amp; var src, env; env = Line.kr(1, 1, dur, doneAction: 2); src = LFNoise2.ar(freq, amp); Out.ar(0, src * env); }).load(s); /* s.sendBundle(0.1, [\s_new, \lf2, -1, 0, 0, \freq, 1000, \dur, 2, \amp, 0.5]); */ /* random UGens in SuperCollider can also be seeded, here is an example where LFNoise2 is controlling the panning of a sound */ SynthDef(\lfpan, {arg dur, pulse, amp, seed = 1000; var src, pan, pos; RandSeed.kr(1, seed); pos = LFNoise2.ar(1); src = Decay2.ar(Impulse.ar(pulse), 0.01, pulse.reciprocal) * PinkNoise.ar(amp); pan = Pan2.ar(src, pos) * EnvGen.kr( Env([0, 1, 0], [0.1, 0.9], \sin), timeScale: dur, doneAction: 2); Out.ar(0, pan ++ pos); }).load(s); /* // remember to mute channel 3 of your mixer s.scope(3) s.sendBundle(0.1, [\s_new, \lfpan, -1, 0, 1, \dur, 2, \pulse, 4, \amp, 3]) s.sendBundle(0.1, [\s_new, \lfpan, -1, 0, 1, \dur, 2, \pulse, 4, \amp, 3, \seed, 30]) */