s.boot

p=ProxySpace.push(s)
p.pop

(
SynthDef(\pop, {|gate=1, dur=0.1, lineEnd=40, lineDur=10, freqMod, freqPort, wrap=0.5, amp=1|
			 var sig, env;
			 sig=SinOsc.ar(SinOsc.kr(Line.kr(0,lineEnd,lineDur),0,freqMod,freqPort)).wrap2(wrap)!2;
			 env=EnvGen.kr(Env.perc(0.01,dur),gate, doneAction:2);
			 Out.ar(0,sig*env*0.754325*amp);
			 }).send(s)
)
~tempo=0.5
~tempo=0.25
~tempo=0.1
~tempo=0.01
~tempo=0.05

Synth(\pop, [\freqMod, 1200, \freqPort, rrand(1000,5000)])

~arrayfreqPort=Pseq([80,80,80,40,20,20].scramble,100000).asStream;
~arrayRitmo=[0,2,4,6,10,12,15,14];
~mod1=16.rand;
~arrayWrap1=Pseq([0.1,0.2,0.5,0.8].scramble,100000).asStream;

~arrayfreqPort2=Pseq([60,60,20,70,90,170].scramble,100000).asStream;
~arrayRitmo2=[0,2,4,6,10,12,15,14];
~mod2=16.rand;
~arrayWrap2=Pseq([0.1,0.15,0.2,0.25].scramble,100000).asStream;

~bajo=Pseq([0,0,3,2,0,0,0,0].midiratio*100,100000).asStream
~bajo=Pseq(([0,0,3,2,0,0,0,0] +2).midiratio*100,100000).asStream
~bajo=Pseq(([0,0,3,2,0,0,-2,0] -4).midiratio*100,100000).asStream
~bajo=Pseq([0,0,3,7,10,12,10,12].midiratio*100,100000).asStream
~bajo=Pseq([0,0,3,4,10,12,7,12].midiratio*100,100000).asStream
~arrayRitmoBajo=[0,4,8,12]
~mod3=16

~arrayRitmoPlatillo=(0..7)*2
~mod4=16

~esesmg=OSCresponder(nil,"/ti", {arg a,b,c; 
					//c[1].postln;
					 if(~arrayRitmo.find([c[1]%~mod1])!=nil,{Synth(\pop, [\freqMod, 20, \freqPort, ~arrayfreqPort.next, \wrap,~arrayWrap1.next])});
				  	if(~arrayRitmo2.find([c[1]%~mod2])!=nil,{Synth(\pop, [\freqMod, 20, \freqPort, ~arrayfreqPort2.next, \wrap, ~arrayWrap2.next])});
				 	 if(~arrayRitmoBajo.find([c[1]%~mod3])!=nil,{Synth(\bajo, [\freq, ~bajo.next])});
				 	 //if(~arrayRitmoPlatillo.find([c[1]%~mod4])!=nil,{10.do{|i| Synth(\pop, [\freqMod, (i+1)*1000, \freqPort, rrand(1000,5000), \amp, 0.5])}});
	}).add
	
~esesmg.remove

(
Tdef(\pip, {
			inf.do{|i|
				  if(~arrayRitmo.find([i%~mod1])!=nil,{Synth(\pop, [\freqMod, 20, \freqPort, ~arrayfreqPort.next, \wrap,~arrayWrap1.next])});
				  if(~arrayRitmo2.find([i%~mod2])!=nil,{Synth(\pop, [\freqMod, 20, \freqPort, ~arrayfreqPort2.next, \wrap, ~arrayWrap2.next])});
				  if(~arrayRitmoBajo.find([i%~mod3])!=nil,{Synth(\bajo, [\freq, ~bajo.next])});
				  //if(~arrayRitmoPlatillo.find([i%~mod4])!=nil,{10.do{|i| Synth(\pop, [\freqMod, (i+1)*1000, \freqPort, rrand(1000,5000), \amp, 0.5])}});
				  ~tempo.wait;
				  }
		})
)

Tdef(\pip).play
Tdef(\pip).stop

10.do{|i| Synth(\pop, [\freqMod, (i+1)*1000, \freqPort, rrand(1000,5000)])}

(
SynthDef(\bajo, {|gate=1, dur=0.54325, lineEnd=40, lineDur=10, freqMod, freqPort, wrap=0.5, freq=100, amp=1|
			 var sig, env;
			 sig=SinOsc.ar(freq,0,amp)+Saw.ar(freq);
			 env=EnvGen.kr(Env.perc(0.01,dur),gate, doneAction:2);
			 Out.ar(0,sig*env*1);
			 }).send(s)
)

Synth(\bajo)