p= ProxySpace.push(s.boot)
p.makeTempoClock(1.7)
c= p.clock
~out.ar(2)
~out.play
p.fadeTime_(5)

(
~depressed= {|f0, f1, f2|
	var saws;
	saws= [f0, f1, f2].collect{|x, i| Saw.ar(Lag.kr(x, 3)+LFNoise1.kr(0.1, 2, 2), LFNoise2.kr(0.1, 0.1, 0.3))};
	RLPF.ar(Mix(saws));
})

~out= ~depressed
~depressed.set(\f0, 100)
~depressed.set(\f1, 200)

(
~depressed= {|f0, f1, f2, rf= 300, rq= 1|
	var saws;
	saws= [f0, f1, f2].collect{|x, i| Saw.ar(Lag.kr(x, 3)+LFNoise1.kr(0.1, 2, 2), LFNoise2.kr(0.1, 0.1, 0.3))};
	RLPF.ar(Mix(saws), Lag.kr(rf, 3), Lag.kr(rq, 3));
})

~depressed.rebuild
~depressed.rebuild
~depressed.set(\rf, 300, \rq, 0.3)
~depressed.rebuild

Tdef(\tired).play(c)
(
Tdef(\tired, {
	inf.do{|i|
		~depressed.set(\rf, (4-(i%6)*20+200).postln);
		~depressed.set(\rq, i%8/8+0.2);
		2.wait;
	}
}))

~depressed.set(\f2, 100)
~depressed.set(\f2, 0)
~depressed.set(\f2, 150)
~depressed.set(\f2, 0)
~depressed.set(\f2, 150)

Tdef(\dusty).play(c)
(
Tdef(\dusty, {
	inf.do{|i|
		if(i%20==0, {
			~depressed.set(\f2, 1.rrand(5));
		}, {
			~depressed.set(\f2, 150+2.rand2);
		});
		1.wait;
	}
}))

~pling= {|t_trig, freq= 900, pan= 0| Pan2.ar(Resonz.ar(Trig.ar(t_trig), freq, 0.1), pan)}
~out= ~depressed+~pling
~pling.set(\t_trig, 1)
~pling.set(\t_trig, 1)

Tdef(\sad).play(c)
(
Tdef(\sad, {
	inf.do{|i|
		if(0.1.coin, {
			~pling.set(\freq, [9, 8, 7, 6].choose*100);
			~pling.set(\pan, 0.3.rand2);
			~pling.set(\t_trig, 1)
		});
		[1, 0.5].choose.wait;
	}
}))

Tdef(\sadl).play(c)
(
Tdef(\sadl, {
	inf.do{|i|
		if(0.1.coin, {
			~pling.set(\freq, ([9, 8, 7, 6].choose*[40, 10].foldAt(i)));
			~pling.set(\pan, 0.6.rrand(1.0)*[1, -1].choose);
			~pling.set(\t_trig, 1)
		});
		[0.5, 0.25, 0.125].choose.wait;
	}
}))

~depressed.set(\f1, 210)
~depressed.set(\f1, 200)

(
Tdef(\tired, {
	inf.do{|i|
		~depressed.set(\rf, (4-(i%6)*20+200));
		~depressed.set(\rq, i%8/8+0.2);
		~depressed.set(\f1, [200, 210].wrapAt(i));
		2.wait;
	}
}))

(
Tdef(\tired, {
	inf.do{|i|
		~depressed.set(\rf, (4-(i%6)*20+200));
		~depressed.set(\rq, i%8/8+0.2);
		~depressed.set(\f1, [200, 200, 210].wrapAt(i));
		~depressed.set(\f0, [100+1.5.rand2, [1, 2].choose].wrapAt(i.div(30)));
		2.wait;
	}
}))

~sines= {|freq= 400, amp= 0.1| SinOsc.ar([1.01, 1]*freq, 0, amp)}
~out= ~depressed+~pling+~sines
~sines= {|freq= 400, amp= 0.1| SinOsc.ar([1.01, 1]*freq, 0, amp+LFNoise2.kr(0.1, 0.05, Lag.kr(amp, 3)))}
~sines.set(\amp, 0.05)
~sines= {|freq= 400, amp= 0.05| SinOsc.ar([1.01, Lag.kr(LFNoise0.kr(0.6, 0.1, 1.5).round(1), 0.1)]*freq, 0, amp+LFNoise2.kr(0.1, 0.05, Lag.kr(amp, 3)*[1, 0.5]))}

(
Tdef(\tired, {
	inf.do{|i|
		~depressed.set(\rf, (4-(i%6)*20+300));
		~depressed.set(\rq, i%8/8+0.1);
		~depressed.set(\f1, [100, 200, 210].wrapAt(i.div(3)));
		~depressed.set(\f0, [100+1.5.rand2, 300].wrapAt(i.div(30)));
		~depressed.set(\f2, (i%5*100+200).round(66.6667));
		3.wait;
	}
}))

(
Tdef(\sadl, {
	inf.do{|i|
		if(0.9.coin, {
			~pling.set(\freq, (600.dup(5)++500.dup(3)).wrapAt(i));
			~pling.set(\pan, [0.9, -0.9]@(i%2));
			~pling.set(\t_trig, 1)
		});
		[0.5, 0.5, 0.25].wrapAt(i).wait;
	}
}))
(
Tdef(\sad, {
	inf.do{|i|
		if(0.9.coin, {
			~pling.set(\freq, [9, 8, 7, 6].wrapAt(i)*200);
			~pling.set(\pan, 0.3.rand2);
			~pling.set(\t_trig, 1)
		});
		[1, 0.5, 0.125].foldAt(i).wait;
	}
}))

~sines.end(30)
~depressed.set(\f1, 0)
Tdef(\tired, {inf.do{|i|
	~depressed.set(\f2, (i%5*100+200).round(66.6667));
	3.wait;
	}}
)
~depressed.set(\f1, 0)
~depressed.set(\f0, 0)

~depressed.set(\f2, 2)
Tdef(\tired).stop
~depressed.set(\f2, 2)
Tdef(\dusty).stop
~depressed.set(\f2, 2)
~depressed.set(\f2, 12)
~depressed.set(\f2, 1)
~depressed.set(\f2, 0)
~depressed.end(40)
Tdef(\sadl).stop
Tdef(\sad).stop
p.end
p.pop