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

//silly music3
~out.ar(2)
~out.play
~boing= {|t_trig= 0, dur= 0.1, start= 100, stop= 200, amp= 0.1| SinOsc.ar(Lag.ar(Trig1.ar(t_trig, dur), dur)*(stop-start)+start, 0, amp)}
~out= ~boing
~boing.set(\dur, 1, \t_trig, 1)
~boing.set(\start, 150, \dur, 1, \t_trig, 1)
~boing.set(\start, 100, \dur, 1, \t_trig, 1)
~boing= {|t_trig= 0, dur= 0.1, start= 100, stop= 200, amp= 0.1| SinOsc.ar(Lag.ar(Trig1.ar(t_trig, dur), dur)*(stop-start)+start, 0, amp)*SinOsc.ar(~tempo.kr).abs}

Tdef(\boing).quant_(4).play(c)
(Tdef(\boing, {
	inf.do{|i|
		~boing.set(\start, [100, 150].choose, \dur, 0.5, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\boing, {
	inf.do{|i|
		~boing.set(\start, [100, 150].choose, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\boing, {
	var mel;
	mel= Pseq([0, 5, 4, 4, 4, 5], inf).asStream;
	inf.do{|i|
		~boing.set(\start, (mel.next+60).midicps.postln, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~boing.set(\start, 100, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\boing, {
	var mel, ml2;
	mel= Pseq([0, 5, 4, 4, 4, 5], inf).asStream;
	ml2= Pseq([300, 250, 300, 300, 400], inf).asStream;
	inf.do{|i|
		~boing.set(\stop, ml2.next, \start, (mel.next+60).midicps.postln, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~boing.set(\stop, ml2.next, \start, 100, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

~boing= {|t_trig= 0, freq2= 100, dur= 0.1, start= 100, stop= 200, amp= 0.1| SinOsc.ar(Lag.ar(Trig1.ar(t_trig, dur), dur)*(stop-start)+start, SinOsc.ar(SinOsc.ar(~tempo.kr/4, 0, 5, freq2).round(2.5), 0, pi, pi), amp)*SinOsc.ar(~tempo.kr).abs}

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 5, 4, 4, 4, 5], inf).asStream;
	ml2= Pseq([300, 250, 300, 300, 400], inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		~boing.set(\freq2, f2.next, \stop, ml2.next, \start, (mel.next+60).midicps, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~boing.set(\stop, ml2.next, \start, 100, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

~tsk= {|t_trig= 0, amp= 0.1| BPF.ar(WhiteNoise.ar(amp))*EnvGen.kr(Env.sine(0.5), t_trig)}
~out= ~boing+~tsk
~tsk.set(\t_trig, 1)
~tsk.set(\amp, 0.05, \t_trig, 1)
~tsk= {|t_trig= 0, amp= 0.1| BPF.ar(WhiteNoise.ar(amp), SinOsc.ar(~tempo.kr*4, 0, 50, 300))*EnvGen.kr(Env.sine(0.5), t_trig)}
~tsk.set(\t_trig, 1)
~tsk= {|t_trig= 0, amp= 0.1| BPF.ar(WhiteNoise.ar(amp), SinOsc.ar(~tempo.kr*20, 0, 200, 500))*EnvGen.kr(Env.sine(0.5), t_trig)}

Tdef(\tsk).quant_(4).play(c)
(Tdef(\tsk, {
	inf.do{|i|
		~tsk.set(\t_trig, 1);
		3.wait;
	}
}))

~tsk= {|t_trig= 0, amp= 0.1, dur= 0.5| BPF.ar(WhiteNoise.ar(amp), SinOsc.ar(~tempo.kr*20, 0, 200, 500))*EnvGen.kr(Env.sine(dur), t_trig)}

(Tdef(\tsk, {
	inf.do{|i|
		~tsk.set(\dur, 0.5, \t_trig, 1);
		3.wait;
		~tsk.set(\dur, 0.1, \t_trig, 1);
		3.wait;
	}
}))

~tsk= {|t_trig= 0, amp= 0.1, dur= 0.5, speed= 20| BPF.ar(WhiteNoise.ar(amp), SinOsc.ar(~tempo.kr*speed, 0, 300, 800))*EnvGen.kr(Env.sine(dur), t_trig)}

(Tdef(\tsk, {
	inf.do{|i|
		~tsk.set(\speed, 1000, \dur, 0.5, \t_trig, 1);
		3.wait;
		~tsk.set(\speed, 2, \dur, 0.15, \t_trig, 1);
		3.wait;
	}
}))

Tdef(\disrupt).quant_(4).play(c)
(Tdef(\disrupt, {
	0.25.wait;
	inf.do{|i|
		~boing.set(\freq2, 1000, \dur, 0.125, \t_trig, 1);
		1.wait;
	}
}))

Tdef(\disrupt).stop
(Tdef(\disrupt, {
	0.25.wait;
	inf.do{|i|
		~boing.set(\freq2, 1000, \dur, 0.125, \amp, 0.01, \t_trig, 1);
		1.wait;
	}
}))
Tdef(\disrupt).play(c)

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 5, 4, 4, 4, 5], inf).asStream;
	ml2= Pseq([300, 250, 300, 300, 400], inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		~boing.set(\amp, 0.1, \freq2, f2.next, \stop, ml2.next, \start, (mel.next+60).midicps, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~boing.set(\amp, 0.1, \stop, ml2.next, \start, 100, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\disrupt, {
	0.25.wait;
	inf.do{|i|
		~boing.set(\freq2, 1000, \dur, 0.125, \amp, 0.01, \t_trig, 1);
		2.rrand(5).wait;
	}
}))

Tdef(\disrupt2).quant_(4).play(c)
(Tdef(\disrupt2, {
	(1/3).wait;
	inf.do{|i|
		Tdef(\boing).pause;
		~boing.set(\amp, 0.2, \start, 50, \stop, 60, \freq2, 50, \dur, 0.5, \t_trig, 1);
		6.rrand(11).wait;
		Tdef(\boing).resume;
		16.rrand(21).wait;
	}
}))

~beep= {|t_trig= 0, freq= 500, amp= 0.1| Mix(SinOsc.ar(freq*#[1, 1.99, 2.98], 0, amp))*EnvGen.kr(Env.perc, t_trig)}
~out= ~boing+~tsk+~beep
~beep.set(\t_trig, 1)
~beep.set(\t_trig, 1)
~beep.set(\freq, 600, \t_trig, 1)

(Tdef(\disrupt2, {
	(1/3).wait;
	inf.do{|i|
		Tdef(\boing).pause;
		~boing.set(\amp, 0.2, \start, 50, \stop, 60, \freq2, 25, \dur, 0.5, \t_trig, 1);
		~beep.set(\amp, 0.1, \freq, 50, \t_trig, 1);
		6.rrand(11).wait;
		~beep.set(\amp, 0.1, \freq, 60, \t_trig, 1);
		Tdef(\boing).resume;
		16.rrand(21).wait;
	}
}))

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 5, 4, 4, 4, 5], inf).asStream;
	ml2= Pseq([300, 250, 300, 300, 400], inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		var f;
		f= f2.next;
		~boing.set(\amp, 0.1, \freq2, f, \stop, ml2.next, \start, (mel.next+60).midicps, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~beep.set(\amp, 0.01, \freq, f, \t_trig, 1);
		~boing.set(\amp, 0.1, \stop, ml2.next, \start, 100, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

//urk ugly music.  how to fix this up?

(Tdef(\tsk, {
	inf.do{|i|
		3.do{
			~tsk.set(\speed, 1000, \dur, 0.15, \t_trig, 1);
			0.25.wait;
		};
		~tsk.set(\speed, 2, \dur, 0.3, \t_trig, 1);
		3.25.wait;
	}
}))

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 6, 3, 3, 3, 6], inf).asStream;
	ml2= Pseq([300, 250, 300], inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		var f, s;
		s= (mel.next+68).midicps;
		f= f2.next;
		~boing.set(\amp, 0.1, \freq2, f, \stop, s+20, \start, s, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~beep.set(\amp, 0.02, \freq, f*2, \t_trig, 1);
		~boing.set(\amp, 0.1, \stop, ml2.next, \start, 68.midicps, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

~beep= {|t_trig= 0, freq= 500, amp= 0.1| var src; src= Mix(SinOsc.ar(freq*#[1, 1.99, 2.98], 0, amp))*EnvGen.kr(Env.perc, t_trig); src+BPF.ar(CombN.ar(src, 1, c.tempo.reciprocal, 3, 4), 1200)}

(Tdef(\tsk, {
	inf.do{|i|
		3.do{
			~tsk.set(\speed, 1000, \dur, 0.15, \t_trig, 1);
			0.25.wait;
		};
		if(0.9.coin, {
			~tsk.set(\speed, 2, \dur, 0.3, \t_trig, 1);
			3.25.wait;
		}, {
			9.do{
				~tsk.set(\speed, 10000.rand, \dur, 0.05, \t_trig, 1);
				0.125.wait;
			};
		});
	}
}))

(Tdef(\disrupt, {
	0.25.wait;
	inf.do{|i|
		~boing.set(\freq2, 4000, \dur, 0.125, \amp, 0.01, \t_trig, 1);
		4.wait;
	}
}))

//better but still not silly

(Tdef(\disrupt2, {
	(1/3).wait;
	inf.do{|i|
		~boing.set(\amp, 0.2, \start, 50, \stop, 60, \freq2, 25, \dur, 0.5, \t_trig, 1);
		~beep.set(\amp, 0.1, \freq, 50, \t_trig, 1);
		8.wait;
		~beep.set(\amp, 0.1, \freq, 60, \t_trig, 1);
		16.wait;
	}
}))

~bd= {|t_trig= 0, amp= 0.1| SinOsc.ar(EnvGen.kr(Env.perc(0, 0.1), t_trig, 60, 10), pi/2, amp)}
~out= ~boing+~tsk+~beep+~bd
~bd.set(\t_trig, 1)
~bd= {|t_trig= 0, amp= 0.1| SinOsc.ar(EnvGen.kr(Env.perc(0.01, 0.1), t_trig, 200, 30), pi/2, amp)}
~bd.set(\t_trig, 1)
~bd.set(\t_trig, 1)
~bd= {|t_trig= 0, amp= 0.1, scale= 200, offset= 30| SinOsc.ar(EnvGen.kr(Env.perc(0.01, 0.1), t_trig, scale, offset), pi/2, amp)}

Tdef(\bd).quant_(4).play(c)
(Tdef(\bd, {
	inf.do{|i|
		~bd.set(\amp, 0.2, \scale, [200, 300].choose, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\bd, {
	var offset, scale;
	offset= Pseq([Pn(30, 12), Pn(50, 4)], inf).asStream;
	scale= Pseq([Pn(200, 7), 400], inf).asStream;
	inf.do{|i|
		~bd.set(\amp, 0.2, \scale, scale.next, \offset, offset.next, \t_trig, 1);
		1.wait;
	}
}))

~sn= {|t_trig= 0, amp= 0.1, scale= 2000, offset= 300| BPF.ar(WhiteNoise.ar(EnvGen.kr(Env.perc(0.01, 0.1), t_trig, amp)), EnvGen.kr(Env.perc(0.01, 0.1), t_trig, scale, offset))}
~out= ~boing+~tsk+~beep+~bd+~sn
~sn.set(\t_trig, 1)
~sn= {|t_trig= 0, amp= 0.1, scale= 2000, offset= 600| BPF.ar(WhiteNoise.ar(EnvGen.kr(Env.perc(0.01, 0.2), t_trig, amp)), EnvGen.kr(Env.perc(0.01, 0.1), t_trig, scale, offset))}
~sn.set(\t_trig, 1)
~sn.set(\t_trig, 1)
~sn.set(\t_trig, 1)
Tdef(\sn).quant_(4).play(c)
(Tdef(\sn, {
	1.wait;
	inf.do{|i|
		~sn.set(\amp, 0.2, \scale, [2000, 3000].choose, \t_trig, 1);
		2.wait;
	}
}))

(Tdef(\sn, {
	var amp, dur;
	amp= Pseq([Pn(0.2, 7), 0.1, 0.1], inf).asStream;
	dur= Pseq([Pn(2, 7), 0.5, 1.5], inf).asStream;
	1.wait;
	inf.do{|i|
		~sn.set(\amp, amp.next, \scale, [2000, 3000].choose, \t_trig, 1);
		dur.next.wait;
	}
}))

(Tdef(\sn, {
	var amp, dur;
	amp= Pseq([Pseq([Pn(0.2, 7), 0.1, 0.1], 1), Pseq([Pn(0.2, 7), Prand([0.1, 0.1, 0], 4)], 1)], inf).asStream;
	dur= Pseq([Pseq([Pn(2, 7), 0.5, 1.5], 1), Pseq([Pn(2, 7), Pn(0.5, 4)], 1)], inf).asStream;
	1.wait;
	inf.do{|i|
		~sn.set(\amp, amp.next, \scale, [2000, 3000, 4000].choose, \t_trig, 1);
		dur.next.wait;
	}
}))

Tdef(\boing).stop

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 6, 3, 3, 3, 6], inf).asStream;
	ml2= Pseq([300, 250, 300], inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		var f, s;
		s= (mel.next+68+12).midicps;
		f= f2.next;
		~boing.set(\amp, 0.05, \freq2, f, \stop, s+20, \start, s, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~beep.set(\amp, 0.02, \freq, f*4, \t_trig, 1);
		~boing.set(\amp, 0.05, \stop, ml2.next*2, \start, 68.midicps*2, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))
Tdef(\boing).play(c)

(Tdef(\boing, {
	var mel, ml2, f2;
	mel= Pseq([0, 6, 3, 3, 3, 6], inf).asStream;
	ml2= Pseq([300, 250, 300]*0.01, inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	inf.do{|i|
		var f, s;
		s= (mel.next+68+12).midicps;
		f= f2.next;
		~boing.set(\amp, 0.05, \freq2, f, \stop, s+20, \start, s, \dur, 0.25, \t_trig, 1);
		0.5.wait;
		~beep.set(\amp, 0.02, \freq, f*4, \t_trig, 1);
		~boing.set(\amp, 0.05, \stop, ml2.next*2, \start, 68.midicps*2, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

(Tdef(\bd, {
	var offset, scale;
	offset= Pseq([Pn(30, 12), Pn(50, 4)], inf).asStream;
	scale= Pseq([Pn(200, 7), 400], inf).asStream;
	inf.do{|i|
		~bd.set(\amp, 0.2, \scale, scale.next, \offset, offset.next, \t_trig, 1);
		if(0.9.coin, {
			1.wait;
		}, {
			3.do{|j|
				0.25.wait;
				~bd.set(\amp, 0.1, \scale, 1000, \offset, 200*j+100, \t_trig, 1);
			};
			0.25.wait;
		});
	}
}))

~beep= {|t_trig= 0, freq= 500, amp= 0.1| var src; src= Mix(SinOsc.ar(freq*#[1, 1.99, 2.98], 0, amp))*EnvGen.kr(Env.perc, t_trig); src+BPF.ar(CombN.ar(src, 1, c.tempo.reciprocal, 3, 4), SinOsc.kr(~tempo.kr/4, 0, 300, 1200), SinOsc.kr(~tempo.kr/3, 0, 1, 3))}

c.tempo_(2.4)

~beep= {|t_trig= 0, freq= 500, amp= 0.1| var src; src= Mix(SinOsc.ar(freq*#[1, 1.99, 2.98], 0, amp))*EnvGen.kr(Env.perc(0.01, 0.75), t_trig); src+BPF.ar(CombN.ar(src, 1, c.tempo.reciprocal/2, 2, 2), SinOsc.kr(~tempo.kr/4, 0, 300, 1200), SinOsc.kr(~tempo.kr/3, 0, 2, 3))}

(Tdef(\tsk, {
	inf.do{|i|
		6.do{|j|
			~tsk.set(\speed, j*1000+100, \dur, j*0.01+0.01, \t_trig, 1);
			0.125.wait;
		};
		if(0.9.coin, {
			~tsk.set(\speed, 2, \dur, 0.3, \t_trig, 1);
			3.25.wait;
		}, {
			9.do{
				~tsk.set(\speed, 10000.rand, \dur, 0.05, \t_trig, 1);
				0.125.wait;
			};
		});
	}
}))

(Tdef(\boing, {
	var mel, ml2, f2, ff;
	mel= Pseq([0, 6, 3, 3, 3, 6], inf).asStream;
	ml2= Pseq([300, 250, 300]*0.01, inf).asStream;
	f2= Pseq({3.linrand*50+100}.dup(16), inf).asStream;
	ff= Pseq({[4, 3, 2].wchoose([0.6, 0.3, 0.1])}.dup(16), inf).asStream;
	inf.do{|i|
		var f, s;
		s= (mel.next+68+12).midicps;
		f= f2.next;
		~boing.set(\amp, 0.05, \freq2, f/2, \stop, s-20, \start, s, \dur, 0.125, \t_trig, 1);
		0.5.wait;
		~beep.set(\amp, 0.02, \freq, f*ff.next, \t_trig, 1);
		~boing.set(\amp, 0.05, \stop, ml2.next*2, \start, (68-12).midicps*2, \dur, 0.25, \t_trig, 1);
		1.wait;
	}
}))

Tdef(\disrupt).stop
Tdef(\disrupt2).stop
Tdef(\tsk).stop
~beep.release(20)

Tdef(\boing).stop
Tdef(\boing).play(c)
Tdef(\boing).stop
~boing.release(20)
Tdef(\boing).play(c)
Tdef(\boing).stop
Tdef(\boing).play(c)
Tdef(\boing).stop

~sn.release(20)
~bd.release(20)
Tdef(\bd).stop
Tdef(\sn).stop

p.clear
p.pop