p= ProxySpace.push(s.boot)

//--pads
~one.ar(2)
~one= {|cutoff= 400, rq= 0.3, freq= 100, amp= 0.1| Pan2.ar(RLPF.ar(Mix(Pulse.ar(freq*[1, 2, 3]+LFNoise2.kr(Rand(0.1, 0.2), 2), 0.5, amp)), cutoff, rq), SinOsc.kr(0.1, 0, 0.2))}
~one.fadeTime_(5)
~one.play
~one.set(\freq, 80)
~one.set(\freq, 100)
~one= {|cutoff= 400, rq= 0.3, freq= 100, amp= 0.1| Pan2.ar(RLPF.ar(Mix(Pulse.ar(freq*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3), 2), 0.5, amp)), cutoff, rq), SinOsc.kr(0.1, 0, 0.2))}
~one.set(\freq, 80)
~one.set(\freq, 50)
~one= {|cutoff= 400, rq= 0.3, freq= 100, amp= 0.1, lag= 1| Pan2.ar(RLPF.ar(Mix(Pulse.ar(Lag.kr(freq, lag)*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3), [0, 1, 2]), LFNoise2.kr({0.2.rand}.dup(3), 0.2, 0.5), amp)), Lag.kr(cutoff, lag), Lag.kr(rq, lag)), SinOsc.kr(0.1, 0, 0.2))}
~one.set(\lag, 3)
~one.set(\rq, 1)
~one.set(\rq, 0.2)
~one.set(\rq, 2)
~one.set(\rq, 0.1)
~one.set(\cutoff, 200)
~one.set(\cutoff, 300)

~two.ar(2)
~two= {|cutoff= 800, rq= 0.3, freq= 200, amp= 0.1, lag= 1| Pan2.ar(RLPF.ar(Mix(Saw.ar(Lag.kr(freq, lag)*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3), [0, 1, 2]), amp)), Lag.kr(cutoff, lag), Lag.kr(rq, lag)), SinOsc.kr(0.1, 0, 0.2))}
~two.fadeTime_(8)
~two.play
~two.set(\lag, 3)
~two.set(\freq, 180)
~two.set(\freq, 200)
~two.set(\rq, 0.2)
~two.set(\rq, 0.1)
~two.set(\rq, 0.9)
~two.set(\freq, 150)
~two.set(\freq, 160)
~two.set(\freq, 100)

~the.ar(2)
~the= {|cutoff= 1600, rq= 0.3, freq= 400, amp= 0.1, lag= 1| Pan2.ar(RLPF.ar(Mix(LFTri.ar(Lag.kr(freq, lag)*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3), [0, 1, 2]), 0, amp)), Lag.kr(cutoff, lag), Lag.kr(rq, lag)), SinOsc.kr(0.1, 0, 0.2))}
~the.fadeTime_(8)
~the.play
~the.set(\amp, 0.05)
~the.set(\lag, 3)
~the.set(\rq, 0.6)
~the.set(\rq, 0.9)
~the.set(\cutoff, 2600)
~the.set(\cutoff, 1600)
~the.set(\freq, 380)
~the.set(\freq, 350)
~the.set(\freq, 360)
~the.set(\freq, 300)

~one.set(\lag, 10)
~one.set(\freq, 45)
~one.set(\freq, 50)
~one.set(\freq, 45)
~two.set(\lag, 10)
~two.set(\freq, 100*0.9)
~the.set(\lag, 10)
~the.set(\freq, 300*0.9)
~one.set(\freq, 50)
~two.set(\freq, 100*0.9*0.9)
~the.set(\freq, 300*0.9*0.9)

~one.set(\freq, 50*0.9*0.9)
~one.set(\freq, 50*0.9*0.9*0.9)
~the.set(\rq, 0.3)
~two.set(\rq, 0.3)

~one.set(\freq, 50*0.9*0.9)

Tdef(\f, {
	inf.do{|i|
		[
			{~one.set(\freq, 50*[1, 0.9, 1.5].choose)},
			{~two.set(\freq, 100*[1, 0.9, 1.5].choose)},
			{~the.set(\freq, 200*[1, 0.9, 1.5].choose)}
		].choose.value;
		10.wait;
	}
}).play
Tdef(\f).stop

(Tdef(\f, {
	inf.do{|i|
		[~one, ~two, ~the].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.01.rrand(1.0)),
			\freq, \freq.asSpec.map(1.0.rand).round(100)
		);
		10.wait;
	}
}).play)

(Tdef(\f, {
	inf.do{|i|
		[~two, ~the].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.01.rrand(1.0)),
			\freq, \freq.asSpec.map(0.7.rand).round(100).min(100)
		);
		10.wait;
	}
}).play)

//keep firm base
~one.set(\freq, 45, \rq, 0.3, \cutoff, 300)

(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(0.7.rand).round(50).min(100);
		[~two, ~the].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.01.rrand(1.0)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(0.7.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

~for.ar(2)
~for= {|cutoff= 3200, rq= 0.3, freq= 1600, amp= 0.1, lag= 1| Pan2.ar(RLPF.ar(Mix(BPF.ar(WhiteNoise.ar(amp*0.6), Lag.kr(freq, lag)*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3)), 0.2)), Lag.kr(cutoff, lag), Lag.kr(rq, lag)), SinOsc.kr(0.1, 0, 0.2))}
~for.fadeTime_(8)
~for.play
~for.set(\lag, 10)

(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(0.9.rand).round(50).min(100);
		[~two, ~the, ~for].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.01.rrand(1.0)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(0.9.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

~fiv.ar(2)
~fiv= {|cutoff= 6400, rq= 0.3, freq= 3200, amp= 0.1, lag= 1| Pan2.ar(RLPF.ar(Mix(LFPar.ar(Lag.kr(freq, lag)*[1, 2, 3]+LFNoise2.kr({0.2.rand}.dup(3), [0, 1, 2]), 0, amp)), Lag.kr(cutoff, lag), Lag.kr(rq, lag)), SinOsc.kr(0.1, 0, 0.2))}
~fiv.fadeTime_(8)
~fiv.set(\lag, 10)
~fiv.play
~fiv.set(\amp, 0.005)

(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(0.9.rand).round(50).min(100);
		[~two, ~the, ~for, ~fiv].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.01.rrand(1.0)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(0.9.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

~fiv.set(\amp, 0.1)
~for.set(\amp, 0.1)
~the.set(\amp, 0.1)
~two.set(\amp, 0.1)

//why only low freqs?  try to fix
(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(1.0.rand).round(50).min(100).postln;
		[~two, ~the, ~for, ~fiv].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.1.rrand(1.5)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(1.0.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

//uh, max not min...
(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(0.5.rand).round(50).max(100).postln;
		[~two, ~the, ~for, ~fiv].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.1.rrand(1.5)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(1.0.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

//sounded nicer with only 100hz tho
(Tdef(\f, {
	inf.do{|i|
		var freq;
		freq= \freq.asSpec.map(0.8.linrand).round(50).max(100).postln;
		[~two, ~the, ~for, ~fiv].choose.perform(\set, 
			\rq, \rq.asSpec.map(0.1.rrand(1.5)),
			\freq, freq,
			\cutoff, \freq.asSpec.map(1.0.rand).min(freq*1.5)
		);
		10.wait;
	}
}).play)

(Tdef(\o, {
	var a, b, c, d, f;
	a= b= c= d= 0;
	f= {|x| (x*[0.99, 1.01].choose).clip(0.01, 0.1)};
	inf.do{|i|
		a= f.value(a);
		b= f.value(b);
		c= f.value(c);
		d= f.value(d);
		[\amps, a, b, c, d].postln;
		1.wait;
	}
}).play)

(Tdef(\o, {
	var a, b, c, d, f;
	a= b= c= d= 0;
	f= {|x| (x*[0.99, 1.01].choose).clip(0.01, 0.1)};
	inf.do{|i|
		a= f.value(a);
		b= f.value(b);
		c= f.value(c);
		d= f.value(d);
		~two.set(\amp, a);
		~the.set(\amp, b);
		~for.set(\amp, c);
		~fiv.set(\amp, d);
		1.wait;
	}
}).play)

(Tdef(\o, {
	var a, b, c, d, f;
	a= b= c= d= 0;
	f= {|x| [0.01, 0.1].choose};	//turn onoff at random
	inf.do{|i|
		a= f.value(a);
		b= f.value(b);
		c= f.value(c);
		d= f.value(d);
		~two.set(\amp, a);
		~the.set(\amp, b);
		~for.set(\amp, c);
		~fiv.set(\amp, d);
		1.wait;
	}
}).play)

//works.  rewrite above
(Tdef(\o, {
	var f;
	f= {[0.01, 0.1].choose};	//turn onoff at random
	inf.do{|i|
		[~two, ~the, ~for, ~fiv].do{|x| x.perform(\set, \amp, f.value)};
		1.wait;
	}
}).play)

//effect
~efx.ar(2)
~efx= {|time= 1, damp= 0.5, amp= 0.5|
	var src;
	src= PitchShift.ar([~two.ar, ~the.ar, ~for.ar, ~fiv.ar].mean, 0.2, 1.01);
	CombN.ar(src, 1, 1, time, damp, amp);
}
~efx.fadeTime_(8)
~efx.play
~efx.set(\time, 0.5)
~efx.set(\time, 1)
~efx.set(\damp, 2)
~efx.set(\damp, 3)
~efx.set(\amp, 0.3)

~efx= {|time= 1, damp= 0.5, amp= 0.5, pitch= 1.01, del= 1|
	var src;
	src= PitchShift.ar([~two.ar, ~the.ar, ~for.ar, ~fiv.ar].mean, 0.2, pitch);
	CombL.ar(src, 1, del.min(1), time, damp, amp);
}
~efx.set(\pitch, 0.99)
~efx.set(\pitch, 0.9)
~efx.set(\pitch, 0.5)

~efx.set(\damp, 4)
~efx.set(\damp, 0.2)
~efx.set(\time, 0.5)
~efx.set(\del, 0.5)
~efx.set(\time, 1)
~efx.set(\del, 0.25)
~efx.set(\del, 0.125)
~efx.set(\damp, 0.5)
~efx.set(\damp, 0.7)
~efx.set(\del, 0.125/2)
~efx.set(\amp, 0.5)
~efx.set(\pitch, 0.75)
~efx.set(\pitch, 0.95)
~efx.set(\time, 0.9)
~efx.set(\time, 2)
~efx.set(\damp, 1)
~efx.set(\amp, 0.4)
~efx.set(\pitch, 2)
~efx.set(\amp, 0.3)
~efx.set(\damp, 2)
~efx.set(\amp, 0.1)
~efx.set(\pitch, 2.01)
~efx.set(\del, 0.125/4)
//really like it here

//slow stop
~efx.set(\del, 0.25)
~efx.set(\del, 0.5)

~two.release(20)
~the.release(20)
~for.release(20)
~fiv.release(20)
~one.release(20)

Tdef(\f).stop
Tdef(\o).stop
~efx.release
p.clear
p.pop