//Eduardo H. Obieta
//www.laad.com.mx
s.boot;
f=Server("fluxus", NetAddr("127.0.0.1", 4444));
(
(SynthDef(\synth0,{|wmul=0.5, wsfreq=0.1, wsmul=2000, wsadd=2600, lmul=0.035, pan=0|
			var son, son1, son2, paneo, freq1, mul1;
			son=HPF.ar(WhiteNoise.ar(wmul,0),SinOsc.kr(wsfreq,0,wsmul,wsadd),lmul,0);
			son=son+Dust.ar(15);
			paneo=Pan2.ar(son,pan);
			Out.ar(0,paneo);
			}).send(s)
			);
(SynthDef(\synth1, {|freq=120, mul=0.5, pan=0|
			var env, paneo, son1, dem;
			son1=SinOsc.ar(freq,0,mul)+SinOsc.ar(freq*2,0,0.1);
			paneo=Pan2.ar(son1,pan);
			env=EnvGen.kr(Env.perc(0.005, 0.2, 1, -4),doneAction:2);
			Out.ar(0,paneo);
			}).send(s)
			);
(SynthDef(\synth2, {|freq=40, dur=0.2, mul=0.55, amp=1|
			var sig, env;
			sig=SinOsc.ar(freq,pi/2,mul)+Saw.ar(freq,0.121)!2;
			env=EnvGen.kr(Env.perc(0.05,dur,1,-8),doneAction:2);
			Out.ar(0,sig*env*1*amp);
			}).send(s)
			);
(SynthDef(\synth3, {|freq=80, dur=0.4, amp=1, factor=1.2, ampB=0.3, durB=0.05|
			var sig, env;
			sig=Pan2.ar(Mix(SinOsc.ar(XLine.kr(freq*factor,freq,dur)*[1,1.1,1.25],pi/2,amp/3)),0);
			sig=sig+EnvGen.ar(Env([1,0],[0.05]));
			sig=sig+(BrownNoise.ar(ampB)*EnvGen.kr(Env.perc(0.01,durB)));
			env=EnvGen.kr(Env.perc(0.01,dur),doneAction:2);
			Out.ar(0,sig*env)
			}).send(s)
			);
(SynthDef(\synth4, {|freq=12000, mul=0.5, pan=0, rel=0.2|
			var sig, env;
			sig=HPF.ar(WhiteNoise.ar,freq,mul,0);
			sig=Pan2.ar(sig,pan);
			env=EnvGen.kr(Env.perc(0.01,rel,0.7,-8),doneAction:2);
			Out.ar(0,sig*env);
			}).send(s);
			);
(SynthDef(\synth5, {|freq=120, mul=0.5, pan=0|
			var env, paneo, son1;
			son1=Saw.ar(freq*0.25, mul, 0)*SinOsc.ar(60.midicps);
			paneo=Pan2.ar(son1,pan);
			env=EnvGen.kr(Env.perc(0.01, 1, 0.75, -10),doneAction:2);
			Out.ar(0,paneo*env);
			}).send(s)
			);
)
//TDEF
(
(j=Pseq([Pseq([60,64,67,69],8),Pseq([63,68,72,75],8)],inf).asStream;
k=Pseq([0.2,0.2,0.4,0.2,0.4,0.2,0.2,0.2],inf).asStream;
a=Tdef(\fluxus, {
	inf.do {
		k.next.wait;
		Synth(\synth1,[\freq, j.next]);
		f.sendMsg("/uno", j.next);
			}}));
(l=Pseq([60,65,69,72,60,65,69,75,60,65,69,72],inf).asStream;
m=Prand([0.4,0.2],inf).asStream;
b=Tdef(\fluxus2, {
	inf.do {
		m.next.wait;
		Synth(\synth2, [\freq, l.next]);
		f.sendMsg("/dos", l.next);
			}}));
(n=Pseq([15,30,45,60],inf).asStream;
o=Pseq([0.1,0.2,0.1,0.4,0.2,0.2,0.2,0.1,0.2,0.4],inf).asStream;
c=Tdef(\fluxus3, {
	inf.do {
		o.next.wait;
		Synth(\synth3,[\freq, 1.5*n.next]);
		f.sendMsg("/tre", n.next);
			}}));
(p=Pseq([12000,14000,17000],inf).asStream;
q=Pseq([0.1,0.1,0.1,0.1,0.05,0.05,0.1,0.1,0.05],inf).asStream;
d=Tdef(\fluxus4, {
	inf.do {
		q.next.wait;
		Synth(\synth4,[\freq, p.next]);
		f.sendMsg("/cua", p.next);
			}}));
(
u=Pseq([0.1,0.1,0.2,0.2,0.1,0.1,0.2,0.1,0.5],inf).asStream;
e=Tdef(\fluxus5, {
	inf.do {
		u.next.wait;
		t=([84,89,93,96,101,103,105]).choose;
		Synth(\synth5,[\freq, t.midicps]);
		f.sendMsg("/cin", t.next);
			}}));

)

z=Synth(\synth0).play;
a.play
b.play
c.play
d.play
e.play
	
a.stop
b.stop
c.stop
d.stop
e.stop
z.free

s.quit;