2 //(C) Nick Collins 2007
5 //first send the SynthDefs; make sure the Server is on
7 var numChannels=2;//4 //replace 2 by 4 if you want to try a quadrophonic setup
9 SynthDef(\impulsetrain1, {arg freq=440, amp=0.1,attack=0.01, sustain=0.1, decay=0.01,pan=0.0, bandwidth=100;
10 var source, filter, env;
12 env= EnvGen.ar(Env([0,1,1,0],[attack, sustain, decay]), doneAction:2);
14 source= Impulse.ar(freq);
16 filter= BPF.ar(source*env*amp*10,freq,bandwidth/freq);
18 Out.ar(0,PanAz.ar(numChannels,filter,pan))
22 SynthDef(\sinarpegg1, {arg freq=440, amp=0.1,attack=0.01, sustain=0.1, decay=0.01,pan=0.0;
23 var source, filter, env;
25 source= SinOsc.ar(EnvGen.kr(Env([1,2,3,4,5,6]*freq,(0.2*attack).dup(5))));
27 filter= CombN.ar(source*EnvGen.kr(Env([1,1,0],[attack,0.01])),0.025,0.025,5);
29 env= EnvGen.kr(Env([0,0,1,1,0],[attack, 0.01,sustain, decay]), doneAction:2);
31 Out.ar(0,PanAz.ar(numChannels,filter*env*0.5*amp,pan))
35 SynthDef(\pitchednoise, {arg freq=440, amp=0.1,attack=0.01, sustain=0.1, decay=0.01,pan=0.0, bandwidth=100;
36 var source, filter, env;
38 env= EnvGen.ar(Env([0,1,1,0],[attack, sustain, decay]), doneAction:2);
40 source= WhiteNoise.ar;
42 filter= BPF.ar(source*env*2*amp,freq,bandwidth/freq);
44 Out.ar(0,PanAz.ar(numChannels,filter,pan))
48 //preferred version if you have the FreeVerb UGen, commented out by default
49 //SynthDef(\stockyfx, {arg shift=0.0, rate=1.0;
55 ////simulate slow down
56 //shifted= PitchShift.ar(input, 0.01,rate);
58 //ReplaceOut.ar(0,FreeVerb.ar(((shift*shifted)+((1.0-shift)*input)),0.33,1.5))
63 SynthDef(\stockyfx, {arg shift=0.0, rate=1.0;
67 c = 2; // number of comb delays
68 a = 3; // number of allpass delays
73 shifted= PitchShift.ar(input, 0.01,rate);
75 input= (shift*shifted)+((1.0-shift)*input);
77 // reverb predelay time :
78 z = DelayN.ar(input, 0.048,0.048);
80 //for delaytime if want modulation- //LFNoise1.kr(0.1.rand, 0.04, 0.05)
81 y=Mix.arFill(c,{CombL.ar(z,0.1,rrand(0.01, 0.1),5)});
83 // chain of 4 allpass delays on each of two channels (8 total) :
84 a.do({ y = AllpassN.ar(y, 0.051, [rrand(0.01, 0.05),rrand(0.01, 0.05)], 1) });
86 ReplaceOut.ar(0,(0.33*y) + input);
95 Synth(\pitchednoise,[\freq, 100, \bandwidth, 200])
96 Synth(\impulsetrain1,[\freq, 440])
97 Synth(\sinarpegg1,[\freq, 440])
105 var series,seriesseries,series2,seriesseries2, tmp;
106 var ioiseries, durseries, dynamicseries, bandwidthseries, instrseries;
107 var attackseries, sustainseries, decayseries, freqseries, panseries, temposeries;
112 var sourceseries, moments;
114 fxsynth= Synth(\stockyfx);
116 sourceseries= Array.fill(rrand(1,12),{[(0..5).scramble,(0..11).scramble]});
118 moments= Array.fill(exprand(13,137).asInteger,{[sourceseries.choose[0], sourceseries.choose[1], exprand(12,143).asInteger]});
124 ("Struktur"+(i+1)).postln;
131 seriesseries= Array.fill(5,{tmp= (tmp-1).max(0)});
135 seriesseries2= Array.fill(12,{tmp= (tmp-1).max(0)});
137 //series of six except for pitches
138 ioiseries= Pseq(0.025+(6**((seriesseries2.copy.flatten.at((0..143)).rotate(144.rand)+1)/12)-1),inf).asStream;
139 dynamicseries= Pseq(((seriesseries2.copy.flatten.at((0..142)).rotate(144.rand))*2).neg.dbamp,inf).asStream;
140 bandwidthseries= Pseq((seriesseries2.copy.flatten.at((0..127)).rotate(144.rand)+1)*25,inf).asStream;
141 instrseries= Pseq([\pitchednoise,\impulsetrain1,\sinarpegg1].dup(6).flatten.scramble,inf).asStream;
142 attackseries= Pseq((seriesseries.copy.flatten.at((0..26)).rotate(36.rand)+1)*0.01,inf).asStream;
143 sustainseries=Pseq((seriesseries2.copy.flatten.at((0..125)).rotate(144.rand)+1)*0.1,inf).asStream;
144 decayseries=Pseq((seriesseries.copy.flatten.at((0..24)).rotate(36.rand)+1)*0.1,inf).asStream;
145 freqseries=Pseq(24**((0..216).scramble/216),inf).asStream;
146 panseries=Pseq((seriesseries.copy.flatten.at((0..23)).rotate(36.rand)+1)*(2/5)-1.0,inf).asStream;
147 numatonce=Pseq((seriesseries.copy.flatten.at((0..28)).rotate(36.rand)+1),inf).asStream;
148 temposeries=Pseq(((30,35..120)/60).scramble,inf).asStream;
150 fxsynth.set(\shift,[0.0,1.0,rrand(0.25,0.75)].choose,\rate,[1,0.5,0.25,0.125,4].choose);
151 basefreq=[27.5,55,110,220,330,660].choose;
156 t.tempo_(temposeries.next)});
159 basefreq=[27.5,55,110,220,330,660].choose
162 s.makeBundle(s.latency, {
165 instrtype=instrseries.next;
168 Synth.before(fxsynth,instrtype ,[\freq, basefreq*freqseries.next, \amp, (dynamicseries.next)*0.25, \pan, panseries.next, \attack, attackseries.next, \decay, decayseries.next, \sustain, sustainseries.next, \bandwidth, bandwidthseries.next ]);
182 //future: add ringmod and glissandi, plus distortion for old magnetic tape? differentiate moments more...