# Stochastic Synthesis Examples

Dear all,

Is there a topic dedicated to this technique with practical implementations in SuperCollider? I know there is a large bulk with plugins and methods to create this but are there any examples that actually show how the techniques behind and most importantly they “sound good”. For example, there is the Chaotic generators topic in help file so I am looking a “how to” special into the stochastic technique. For one thing, there is this (https://composerprogrammer.com/research/stochasticsynthesis.pdf) and Sergio Luque’s (Stochastic Composition and Synthesis, 16/17/18.12.2011, Barcelona | SuperCollider) work which is a good start but I am just curious if there is more apropos to the classes in SuperCollider and their practical applications around that show how to use them efficiently, that is, besides each one’s help file.

Cheers

K.

hey,

i recently have extracted some `DemandEnvGen` examples from the synthesis part of this github repo maybe they are of interest to you:

``````(
{|sdm=1, mod=0.005, from=9, to=12, min=0.1, max=0.3, amp=1|
var sd = SampleDur.ir * sdm, hpf=40, mf=1.0;
HPF.ar(
DemandEnvGen.ar(
Dseq([min, min.neg, [max.neg, max]], inf),
sd * Dseq([Lag.kr(from), Lag.kr(to), Dbrown(from, to, to, from.neg,from)], inf)
).fold2(SinOsc.ar(mod)) * mf * amp,
hpf)
}.play;
)

(
{|sdm=1, repeats=32, from=8, to=30, min=0.1, max=0.9, amp=1.0|
var sd = SampleDur.ir * sdm, mf=0.2;

DemandEnvGen.ar(
Dseq([
Dseq([0, 0.5], repeats),
Dseq([-0.2, 0.8], repeats/2),
Dseq([-1.0, 1.0], Dwhite(repeats/32, repeats)),
Dseq([-0.8, 0.1], repeats/16)
], inf),
Dseq([
Dwhite(from, to, [repeats, repeats*0.5]),
Dwhite(from/1.5, to/1.5, [repeats, repeats*2]),
Dbrown(from/10, to/10, from/20, [repeats, repeats*0.25])
], inf) * sd
) * mf * amp;
}.play;
)

(
{|step=2, start=1, from=2, to=5, sdm=0.2, min=0.1, max=0.9, amp=1.0, brownStep=0.01|
var iter = 2;
var sd = SampleDur.ir * [sdm,sdm*1.1], mf=0.08;
var levels = ({ Dseries(rrand(min.neg,max.neg), rrand(min,max), from*rrand(from,to)) } ! iter) ++
({ Dbrown(rrand(min.neg,max.neg), rrand(min,max), brownStep, to*2) } ! iter);
var times = { Dseries(rrand(start,start*2), rrand(step,step*2), rrand(from*5,to*4)) } ! (iter*2);

DemandEnvGen.ar(
Dseq(levels, inf),
Dseq(times, inf) * sd
) * mf * amp
}.play;
)

(
{|sdm=1, repeats=4, from=5, to=18, mod=60, amp=1.0|
var length = 30;
var sd = SampleDur.ir * sdm, mf=0.3;

DemandEnvGen.ar(
Dseq([Dseries(-1.0, [0.04,0.09], 30)], inf),
Dseq([
Dwhite(from, to, repeats),
Dwhite(from/1.5, to*3, repeats)
], inf) * sd
).clip(SinOsc.ar(mod)) * mf * amp;
}.play;
)

(
{|sdm=0.15,modFreq=10, modFrom=5, modTo=25, amp=1.0|
var sd = SampleDur.ir * sdm, mf =0.4;
var size=5;
var from=1;
var to=25;

HPF.ar(DemandEnvGen.ar(
Dseq([1, [-1, 0.5]], inf),
Dseq(Array.rand(size,from,to), inf) * sd
).atan(SinOsc.ar(LFNoise0.ar(modFreq).range(modFrom, modTo))),40) * mf * amp;
}.play;
)

(
{|sdm=0.15,modFreq=10, modFrom=5, modTo=25, fmfreq=100, fmhi=4000, amp=1.0, mf = 0.25|
var size=5;
var from= 20;
var to=25;
var sd = SampleDur.ir * sdm;
var first = [1, [-1, 1.0]];
var second = Array.rand(size,from,to);
var seq = Dseq(second, inf);
var snd = DemandEnvGen.ar(Dseq(first, inf), seq * sd
).atan(SinOsc.ar(LFNoise0.ar(modFreq).range(modFrom, modTo))) * 0.5;

var trig = Impulse.kr(10);
var freq = Demand.kr(trig, 0, seq);
var buena = Stepper.kr(trig, 0, 0, 10, 1);

snd = snd + PMOsc.ar(LFCub.kr([freq, freq/2], 0, fmfreq * 0.2, fmfreq), fmhi, 0.5) * mf;
snd = snd + (DemandEnvGen.ar(Dwhite(-0.9,0.9,1),seq * sd * 10 * 0.1));
HPF.ar(snd, 40, amp)
}.play;
)

(
{|filtSpeed=10, filtCenter=200, sdm=1, modFreq=0.01, filtBw=3, amp=1.0, lpf=2500|
var size=3;
var from=1;
var to=25;
var a = 9;
var b = 5;
var min=0.1;
var max=0.3;
var sd = SampleDur.ir * sdm;
var snd = DemandEnvGen.ar(
Dseq([min, min.neg, [max.neg, max]], inf),
Dwhite(sd * a, sd * b),
).wrap2(SinOsc.ar([modFreq, modFreq * 1.1])) * 0.2;
snd = SoftClipAmp8.ar(snd,10) * amp;
HPF.ar(BBandStop.ar(snd, Lag.ar(LFNoise1.ar( [filtSpeed,filtSpeed*2] ).range(filtCenter * 0.2, filtCenter * 2), 0.05), filtBw));
}.play;
)
``````
2 Likes

Thanks for this, tried to find some help about the library but only code, is there some information about interacting/controlling attributes of this.