Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / examples / pieces / aftergoeyvaerts.scd
blobbf454524939d4903251ff2e5cf3191aeaf1c78a1
1 //after goeyvaerts
2 //(C) Nick Collins 2007
5 //first send the SynthDefs; make sure the Server is on
7 SynthDef(\goeysynth, {
8 arg freq=440,amp=0.1, sustain=0.1, pan=0.0; 
9 var source, env;
11 source= LPF.ar(Mix(LFPar.ar(freq*[0.999,1.001],0,amp)).distort,EnvGen.kr(Env([10000,2000,4000,1000],[0.005,Rand(0.009,0.05),0.005])));
13 env= EnvGen.kr(Env([0,1,0.4,0.7,0],[Rand(0.001,0.005),0.005,0.005,sustain]), doneAction:2);
15 Out.ar(0,Pan2.ar(source*env,pan))
17 }).send(s);
19 //preferred version if you have the FreeVerb UGen, commented out by default
20 //SynthDef(\goeyfx, {
21 //ReplaceOut.ar(0,FreeVerb.ar(In.ar(0,2),0.33,1.5))
22 //}).send(s);
24 //adapted from JmC reverb
25 SynthDef(\goeyfx, {
26 var a,c,z,y,in;
27 c = 2; // number of comb delays
28 a = 3; // number of allpass delays
30 in=In.ar(0,2);
31 // reverb predelay time :
32 z = DelayN.ar(in, 0.048,0.048);
34 //for delaytime if want modulation-     //LFNoise1.kr(0.1.rand, 0.04, 0.05)
35 y=Mix.arFill(c,{CombL.ar(z,0.1,rrand(0.01, 0.1),5)});
36         
37 // chain of 4 allpass delays on each of two channels (8 total) :
38 a.do({ y = AllpassN.ar(y, 0.051, [rrand(0.01, 0.05),rrand(0.01, 0.05)], 1) });
39         
40 // add original sound to reverb and play it :
41 Out.ar(0,(0.2*y));
43 }).send(s);
49 Synth(\goeysynth,[\freq,440]); //test
53 //now run the piece
55 var n, octaves, basenote, selections, probs;
56 var ioirow, ioimult, noterow, amprow, susrow, panrow;
57 var fxsynth;
59 n=12; //notes per octave
61 fxsynth= Synth(\goeyfx);
63 noterow=(0..(n-1)).scramble; //[4,0,5,14,13,15,21,19,20,11,6,10]%12; 
64 amprow= Pseq((1,3..36).neg.dbamp.scramble,inf).asStream;
65 susrow= Pseq((((1..37)/37).exp/exp(1)).scramble,inf).asStream;
66 panrow= Pseq((((0..31)/31)*2-1).scramble,inf).asStream;
68 ioimult=0.1;
70 ioirow= n**(((1..n).scramble)/n); //exponential spacing 1 to n
71 ioirow= Pseq(ioirow,inf).asStream;
73 basenote=36;
74 octaves=4;
75 selections= Array.fill(n,{0});
76 probs=Array.fill(n,{1.0});
80 inf.do
81 {       
82         var notenow;
83         
84         if(ioimult.coin,{ioimult=[0.01,0.025,0.05,0.1,0.2].choose;});
85         
86         if(0.03.coin,{selections= Array.fill(n,{0});});
87         if(0.02.coin,{octaves= rrand(2,5);});
88         if(0.01.coin,{basenote=rrand(35,47);});
89         
90         //recovery rate
91         probs.do{|val,i| if(val<0.9999,{probs[i]=probs[i]+0.1})};
92                 
93         s.makeBundle(s.latency, {       
94                 [1,2,3,4,5].wchoose([0.5,0.35,0.1,0.025,0.025]).do{     
95                         notenow= noterow.wchoose(probs.normalizeSum);
97                         probs[notenow]=0.1;
98                         
99                         selections[notenow]=selections[notenow]+1;
100         
101                         Synth.before(fxsynth, \goeysynth,[\freq, ((((selections[notenow]%octaves)*12)+ basenote) + ((notenow/n)*12)).midicps,\amp,(amprow.next)*0.2, \sustain, susrow.next, \pan, panrow.next]);
102                         
103                 };
104                 
105         });
106         
107         ((ioirow.next)*ioimult).wait;
110 }.fork;
115 //future possibilities:
116 //add different rhythmic sections, and also, use fold or wrap on array data
117 //up to four notes at once in selection; optional slight spread? really need independent voices too