(
SynthDef("drum1", { arg freq=80, amp2=1, myspeed=50, mynum2=5000;
	var trig, seq, osc;
	
	trig = Impulse.kr(myspeed);

	seq = Drand([
		Dseq([4,0,0,1,2,1,0,1]),
		Dseq([4,0,2,0,1,0,1,1]),
		Dseq([4,0,0,2,0,0,1,1]),
		Dseq([4,0,1,2,0,1,2,0]),
		Dseq([4,1,1,1,2,2,3,3]),
		Dseq([4,1,0,1,0,1,0,1])
	], inf);
	trig = Demand.kr(trig, 0, seq * 0.4) * trig;
	osc = {HPF.ar(WhiteNoise.ar, mynum2)}.dup * Decay.kr(trig, 0.5);

	Out.ar(0, osc*amp2);
	}).writeDefFile;
)

(
SynthDef("drum2", { arg freq=80, amp3=1, myspeed2=50, mynum3=3000;
	var trig, seq, osc;
	
	trig = Impulse.kr(myspeed2);

	seq = Drand([
		Dseq([4,0,0,1,2,1,0,1]),
		Dseq([4,0,2,0,1,0,1,1]),
		Dseq([4,0,0,2,0,0,1,1]),
		Dseq([4,0,1,2,0,1,2,0]),
		Dseq([4,1,1,1,2,2,3,3]),
		Dseq([4,1,0,1,0,1,0,1])
	], inf);
	trig = Demand.kr(trig, 0, seq * 0.4) * trig;
	osc = {LPF.ar(PinkNoise.ar, mynum3)}.dup * Decay.kr(trig, 0.5);

	Out.ar(0, osc*amp3);
	}).writeDefFile;
)

(
var w, b1, b2, b3, b4, sl1, sl2, sl3, sl4, sl5, sl6, str2, s;

s = Server.local;
w = SCWindow("Beat Noise Controller", Rect(100, 800, 400, 450));
w.front;

b1 = SCButton(w, Rect(5, 0, 150, 24));
b1.states = [
		["Start Server", Color.black, Color.green],
		["Stop Server", Color.white, Color.red],
			];
b1.action = { arg view;
		if (b1.value == 1, {
				s.boot;
		},{
				s.quit;
		});
};

b2 = SCButton(w, Rect(5, 30, 150, 24));
b2.states = [
		["Load Drum 2", Color.black, Color.green]
			];
b2.action = { arg view;
	s.sendSynthDef("drum2");
};

b3 = SCButton(w, Rect(155, 30, 150, 24));
b3.states = [
		["Load Drum 1", Color.black, Color.green]
			];
b3.action = { arg view;
	s.sendSynthDef("drum1");
	s.sendSynthDef("drum2");
};

b4 = SCButton(w, Rect(5, 60, 150, 24));
b4.states = [
		["Play", Color.black, Color.green],
		["Stop", Color.white, Color.red],
			];
b4.action = { arg view;
		if (b4.value == 1, {
				s.sendMsg("/s_new", "variablesine", 1000, 1, 0, "freq", 80, "freq2", 1);
				s.sendMsg("/s_new", "drum1", 1001, 0, 0, "freq", 80);
				s.sendMsg("/s_new", "drum2", 1002, 0, 0, "freq", 80);
				s.sendMsg("n_map", 1000, \freq2, 10);
		},{
				s.sendMsg("/n_free", 1000);
				s.sendMsg("/n_free", 1001);
				s.sendMsg("/n_free", 1002);
		});
};

sl1 = SCSlider(w, Rect(35, 100, 25, 300));
sl1.action = {
		var val;
		val = ((3000*sl1.value)+10);
		val.postln;
		s.sendMsg("/n_set", 1001, "mynum2", val);
};

sl2 = SCSlider(w, Rect(155, 100, 25, 300));
sl2.action = {
		var val;
		val = (20*sl2.value);
		val.postln;
		s.sendMsg("/n_set", 1001, "myspeed", val);
};

sl3 = SCSlider(w, Rect(215, 100, 25, 300));
sl3.action = {
		var val;
		val = (20*sl3.value);
		val.postln;
		s.sendMsg("/n_set", 1002, "myspeed2", val);
};

sl4 = SCSlider(w, Rect(275, 100, 25, 300));
sl4.action = {
		var val;
		val = (5*sl4.value);
		val.postln;
		s.sendMsg("/n_set", 1001, "amp2", val);
				
};

sl5 = SCSlider(w, Rect(335, 100, 25, 300));
sl5.action = {
		var val;
		val = (5*sl5.value);
		val.postln;
		s.sendMsg("/n_set", 1002, "amp3", val);
};

sl6 = SCSlider(w, Rect(095, 100, 25, 300));
sl6.action = {
		var val;
		val = ((6000*sl6.value)+20);
		val.postln;
		s.sendMsg("/n_set", 1002, "mynum3", val);
};

str2 = SCStaticText(w, Rect(30, 400, 200, 30));
str2.string = "Filter 1";
str2.font = Font("Futura-Medium", 10);

str2 = SCStaticText(w, Rect(90, 400, 200, 30));
str2.string = "Filter 2";
str2.font = Font("Futura-Medium", 10);

str2 = SCStaticText(w, Rect(150, 400, 200, 30));
str2.string = "Speed 1";
str2.font = Font("Futura-Medium", 10);

str2 = SCStaticText(w, Rect(210, 400, 200, 30));
str2.string = "Speed 2";
str2.font = Font("Futura-Medium", 10);

str2 = SCStaticText(w, Rect(270, 400, 200, 30));
str2.string = "Amp 1";
str2.font = Font("Futura-Medium", 10);

str2 = SCStaticText(w, Rect(330, 400, 200, 30));
str2.string = "Amp 2";
str2.font = Font("Futura-Medium", 10);

)