p= ProxySpace.push(s.boot)
p.makeTempoClock(3)
c= p.clock

//fm
(SynthDef(\fm1, {|out= 0, freq= 400, amp= 0.1, modfreq= 440, modamp= 1, lag= 2, dur= 0.1|
	var e, z, m;
	e= EnvGen.kr(Env.sine(dur), doneAction:2);
	m= SinOsc.ar(modfreq*e, 0, modamp, 100, modfreq);
	z= SinOsc.ar(m, 0, amp);
	Out.ar(out, z*e);
}).send(s)
)

Tdef(\first).play(c)
Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand]); [0.4, 0.3].choose.wait}
})

(SynthDef(\fm1, {|out= 0, freq= 400, amp= 0.1, modfreq= 440, moddepth= 100, modamp= 1, lag= 2, dur= 0.1|
	var e, z, m;
	e= EnvGen.kr(Env.sine(dur), doneAction:2);
	m= SinOsc.ar(modfreq*e, 0, modamp, moddepth, freq);
	z= SinOsc.ar(m, 0, amp);
	Out.ar(out, Pan2.ar(z*e));
}).send(s)
)

d= Pseq([Pn(0.4, 10), Pn(0.3, 1)], inf).asStream

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand]); d.next.wait}
})

Tdef(\second).play(c)
Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.2, \moddepth, 200]); 0.4.wait}
})
Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.2, \moddepth, 200, \modamp, 0.4.rrand(1.8)]); 0.4.wait}
})

Tdef(\third).play(c)
Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.05.rand, \dur, 0.3, \moddepth, 404]); 0.4.wait}
})

Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \dur, 0.3, \moddepth, [404, 488].foldAt(i)]); 0.4.wait}
})
Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \dur, 0.3, \moddepth, [404, 488].foldAt(i.div(5))]); 0.4.wait}
})

(SynthDef(\fm2, {|out= 0, freq= 400, amp= 0.1, modfreq= 440, moddepth= 100, modamp= 1, lag= 2, dur= 0.1|
	var e, z, m;
	e= EnvGen.kr(Env.perc(dur), doneAction:2);
	m= LPF.ar(Saw.ar(modfreq*e, modamp, moddepth, freq), LFNoise1.kr(0.4, 2000, 3000));
	z= SinOsc.ar(m, 0, amp);
	Out.ar(out, Pan2.ar(z*e));
}).send(s)
)

Tdef(\next1).play(c)
Tdef(\next1, {
	inf.do{|i| Synth(\fm2, [\amp, 0.1.rand, \dur, 1, \moddepth, 100]); 2.wait}
})

Tdef(\next1, {
	inf.do{|i| Synth(\fm2, [\amp, 0.1.rand, \dur, 1, \moddepth, 80]); 2.wait}
})

Tdef(\next1, {
	inf.do{|i| Synth(\fm2, [\amp, 0.1.rand, \dur, 1, \moddepth, [100, 80].foldAt(i.div(20))]); 2.wait}
})

Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \dur, 0.3, \moddepth, [404, 488, 414, 488].foldAt(i.div(6))]); 0.4.wait}
})

Tdef(\next2).play(c)
Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, 0.01.rand, \dur, 0.05, \moddepth, 1000.rrand(2000).round(100)]); 0.1.wait}
})

Tdef(\next2).stop
Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, 0.01.rand, \dur, 0.05, \moddepth, 1000.rrand(2000).round(400)]); 0.5.wait}
})
Tdef(\next2).play(c)
Tdef(\next2).stop
Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.01, 0, 0].choose, \dur, 0.05, \moddepth, i%10*700+1000]); 0.5.wait}
})
Tdef(\next2).play(c)
Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [0.02, 0.1].foldAt(i), \moddepth, i%10*400+1000]); [0.5, 0.1].wrapAt(i%4).wait}
})
Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [0.02, 0.05].foldAt(i), \modamp, 100, \moddepth, (i%10+94).midicps]); [0.5, 2].wrapAt(i%4).wait}
})

Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \modamp, 50, \dur, 0.3, \moddepth, [404, 488, 414, 488].foldAt(i.div(6))]); 0.4.wait}
})

Tdef(\third, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \modamp, [40, 1].foldAt(i.div(4)), \dur, 0.3, \moddepth, [404, 488, 414, 488].foldAt(i.div(6))]); 0.4.wait}
})

Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [1.02, 1.05].foldAt(i), \modamp, 100, \moddepth, (i%8+94).midicps]); [0.5, 4].wrapAt(i%4).wait}
})

Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.15, \moddepth, 200, \modamp, 1.rrand(18)]); 0.4.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.2.rand, \modamp, [1, 10, 20].wrapAt(i)]); d.next.wait}
})

Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [1.02, 1.05].foldAt(i), \modamp, 100, \moddepth, (9-(i%8)+94).round(3).midicps]); [0.5, 4].wrapAt(i%4).wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.2.rand, \modamp, [10, 20, 30].wrapAt(i)]); d.next.wait}
})

Tdef(\third).stop

Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.15, \moddepth, [400, 200].foldAt(i.div(20)), \modamp, 1.rrand(18)]); 0.4.wait}
})

(SynthDef(\fm2, {|out= 0, freq= 400, amp= 0.1, modfreq= 440, moddepth= 100, modamp= 1, lag= 2, dur= 0.1|
	var e, z, m;
	e= EnvGen.kr(Env.perc(dur), doneAction:2);
	m= LPF.ar(Saw.ar(modfreq*e, modamp, Lag.ar(Line.ar(moddepth/2, moddepth, lag), lag), freq), LFNoise1.kr(0.4, 2000, 3000));
	z= SinOsc.ar(m, 0, amp);
	Out.ar(out, Pan2.ar(z*e));
}).send(s)
)
(SynthDef(\fm1, {|out= 0, freq= 400, amp= 0.1, modfreq= 440, moddepth= 100, modamp= 1, lag= 2, dur= 0.1|
	var e, z, m;
	e= EnvGen.kr(Env.sine(dur), doneAction:2);
	m= SinOsc.ar(modfreq*e, 0, modamp, Lag.kr(XLine.kr(moddepth/2, moddepth, lag), lag), freq);
	z= SinOsc.ar(m, 0, amp);
	Out.ar(out, Pan2.ar(z*e));
}).send(s)
)

Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.15, \moddepth, [400, 200].foldAt(i.div(20)), \modamp, 1.rrand(18), \lag, [1, 2, 3].choose*0.1]); 0.4.wait}
})

Tdef(\second, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \dur, 0.15, \moddepth, [400, 200].foldAt(i.div(20)), \modamp, i%40, \lag, i%33*0.2]); 0.4.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.2.rand, \modamp, [10, 20, 130].wrapAt(i), \lag, 0.3]); d.next.wait}
})

Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [2.02, 2.05].foldAt(i), \modamp, [100, 200].foldAt(i), \moddepth, (9-(i%8)+94).round(3).midicps, \lag, 0.2]); [0.5, 4].wrapAt(i%4).wait}
})

Tdef(\next1, {
	inf.do{|i| Synth(\fm2, [\amp, 0.1.rand, \dur, 1, \moddepth, [180, 1].foldAt(i.div(20)), \lag, 0.02]); 2.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.15.rand, \modamp, [1, 2, 230].wrapAt(i), \lag, 0.1]); d.next.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.15.rand, \modamp, [1, 2, 330].wrapAt(i), \lag, 0.1]); d.next.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.12.rand, \modamp, [1, 2, 530].wrapAt(i), \lag, 0.05]); d.next.wait}
})

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \modamp, [1, 2, 1530].wrapAt(i), \lag, 0.01]); d.next.wait}
})

SynthDef(\efx, {Out.ar(0, In.ar(10, 2)*SinOsc.ar(400))}).send(s)
e= Synth(\efx)
Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \modamp, [1, 2, 1530].wrapAt(i), \lag, 0.01, \out, [10, 0].choose]); d.next.wait}
})
SynthDef(\efx, {Out.ar(0, CombN.ar(In.ar(10, 2), 0.2, 0.2)*SinOsc.ar(LFNoise0.kr(4, 100, 400).round(100)))}).send(s)
e.free
e= Synth(\efx)

//trying to pitchtrack output for ringmods freq
SynthDef(\efx, {Out.ar(0, CombN.ar(In.ar(10, 2), 0.2, 0.2)*SinOsc.ar(Pitch.kr(InFeedback.ar(0))[0]))}).send(s)
e.free
e= Synth(\efx)

SynthDef(\efx, {Out.ar(0, CombN.ar(In.ar(10, 2), 0.2, 0.2)*SinOsc.ar(Pitch.kr(Lag.ar(HPF.ar(InFeedback.ar(0), 1000), 0.5))[0]))}).send(s)
e.free
e= Synth(\efx)

Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1.rand, \modamp, [1, 2, 1000].wrapAt(i), \lag, 0.1, \out, [10, 10, 0].choose]); d.next.wait}
})

Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [2.02, 2.05].foldAt(i), \modamp, [100, 200].foldAt(i), \moddepth, [60, 90].choose.midicps, \lag, 1.2]); [0.5, 4].wrapAt(i%4).wait}
})

Tdef(\bd).play(c)
Tdef(\bd, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modamp, 80]); [1, 1, 2].wrapAt(i).wait}
})

Tdef(\hh).play(c)
Tdef(\hh, {
	var durs;
	durs= 1.dup(7)++0.25.dup(4);
	0.5.wait;
	inf.do{|i| Synth(\fm1, [\amp, 0.001, \modamp, 8000, \lag, 0.1]); durs.wrapAt(i).wait}
})

Tdef(\pad).play(c)
Tdef(\pad, {
	1.wait;
	inf.do{|i| Synth(\fm2, [\amp, 0.006, \modfreq, [800, 800, 400].foldAt(i), \modamp, 2000, \lag, [40, 1].foldAt(i), \dur, 4]); 4.wait}
})

Tdef(\hh, {
	var durs;
	durs= 1.dup(7)++0.25.dup(4);
	0.5.wait;
	inf.do{|i| Synth(\fm1, [\amp, 0.001, \modamp, [8000, 10000].wchoose([0.9, 0.1]), \lag, 0.1]); durs.wrapAt(i).wait}
})

Tdef(\first).stop

Tdef(\bd, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modamp, [80, 100].wchoose([0.9, 0.1])]); [1, 1, 2].wrapAt(i).wait}
})

Tdef(\hh, {
	var durs;
	durs= 1.dup(7)++0.25.dup(4);
	0.5.wait;
	inf.do{|i| Synth(\fm1, [\amp, 0.001, \modamp, [8000, 10000].wchoose([0.9, 0.1]), \lag, 0.1, \out, [0, 10].wchoose([0.7, 0.3])]); durs.wrapAt(i).wait}
})

Tdef(\next2, {
	inf.do{|i| Synth(\fm2, [\amp, [0.005, 0, 0].wrapAt(i), \dur, [0.02, 2.05].foldAt(i), \modamp, [10, 200].foldAt(i), \moddepth, [60, 90].choose.midicps, \lag, 1.2]); [0.5, 4].wrapAt(i%4).wait}
})

Tdef(\next2).stop

Tdef(\pad, {
	1.wait;
	inf.do{|i| Synth(\fm2, [\amp, 0.006, \modfreq, [800, 800, 400].foldAt(i), \modamp, 2000, \lag, [40, 1].foldAt(i), \dur, 2, \out, 10]); 4.wait}
})
Tdef(\second).isPlaying
Tdef(\second).stop
Tdef(\next1).isPlaying
Tdef(\next1).stop

Tdef(\pad, {
	1.wait;
	inf.do{|i| Synth(\fm2, [\amp, 0.01, \modfreq, [800, 1000, 400].foldAt(i), \modamp, [2000, 2500].wchoose([0.9, 0.1]), \lag, [40, 1].foldAt(i), \dur, 2, \out, 10]); 4.wait}
})

Tdef(\bd, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modamp, [80, 100].wchoose([0.9, 0.1])]); [1].wrapAt(i).wait}
})

Tdef(\bd, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modamp, [80, 100].wchoose([0.9, 0.1])]); [1, 1, 2].wrapAt(i).wait}
})

Tdef(\bd, {
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modamp, [80, 100, 170].wchoose([0.8, 0.1, 0.1])]); [1].wrapAt(i).wait}
})

Tdef(\first).play(c)
Tdef(\first).stop
Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.03.rand, \modamp, [1, 2, 10000].wrapAt(i), \lag, 0.5, \dur, 0.1, \out, [10, 10, 0].choose]); d.next.wait}
})

Tdef(\first).play(c)
Tdef(\first, {
	inf.do{|i| Synth(\fm1, [\amp, 0.01, \modamp, [1, 200, 10000].wrapAt(i), \lag, 0.5, \dur, 0.1, \out, [10, 10, 0].choose]); 0.5.wait}
})

Tdef(\bd, {
	var durs;
	durs= Pseq([Pn(1, 7), Pn(1/3, 3), Pn(1, 7), Pn(1/3, 3), Pn(1, 15), Pn(0.5/3, 6)], inf).asStream;
	inf.do{|i| Synth(\fm1, [\amp, 0.1, \modfreq, [400, 600].wrapAt(i.div(20)), \modamp, [80, 100, 270].wchoose([0.8, 0.1, 0.1])]); durs.next.wait}
})

Tdef(\pad, {
	1.wait;
	inf.do{|i| Synth(\fm2, [\amp, 0.02, \modfreq, [800, 1000, 400].foldAt(i), \modamp, 2*[2000, 2500].wchoose([0.9, 0.1]), \lag, [40, 1].foldAt(i), \dur, 2, \out, 10]); 4.wait}
})

Tdef(\hh, {
	var durs;
	durs= 1.dup(7)++0.25.dup(4);
	0.5.wait;
	inf.do{|i| Synth(\fm1, [\amp, 0.001, \modamp, [8000, 10000, 800].wchoose([0.8, 0.1, 0.1]), \lag, [0.1, 0.2].choose, \out, 12]); durs.wrapAt(i).wait}
})

SynthDef(\efx2, {
	var in;
	in= In.ar(12, 2);
	Out.ar(0, CombN.ar(in, 0.125, 0.125, 2, 1, in)*SinOsc.ar(Pitch.kr(Lag.ar(HPF.ar(InFeedback.ar(0), 1000), 0.5))[0]))}).send(s)
f= Synth(\efx2)

Tdef(\pad, {
	1.wait;
	inf.do{|i| Synth(\fm2, [\amp, 0.02, \modfreq, [800, 1000, 400].foldAt(i), \modamp, 2*[2000, 2500].wchoose([0.9, 0.1]), \lag, [40, 1].foldAt(i), \dur, 2, \out, 10]); 15.wait}
})

Tdef(\pad).stop
Tdef(\first).stop
Tdef(\bd).stop
Tdef(\hh).stop
e.free
f.free

p.clear
p.pop