(
	var inst, fx;
	b = Bus.audio(s, 1);
	
	SynthDef("ht", { arg freq=75, amp=1, gate=0;
		var wave, eg, eg2, out;
		wave = SinOsc.ar(freq,0,SinOsc.kr(45));
		wave = LPF.ar(wave, 300);
		eg = EnvGen.kr(Env.perc(0.01,0.2,amp),gate);
		eg2 = EnvGen.kr(Env.perc(0,0.02,amp/2),gate);
		out = (wave * eg * amp)+(LPF.ar(WhiteNoise.ar(eg2),5000));
		Out.ar(b, out);
	}).store;
	
	SynthDef("mt", { arg freq=50, amp=1, gate=0;
		var wave, eg, eg2, out;
		wave = SinOsc.ar(freq,0,SinOsc.kr(45));
		wave = LPF.ar(wave, 200);
		eg = EnvGen.kr(Env.perc(0.01,0.2,amp),gate);
		eg2 = EnvGen.kr(Env.perc(0,0.02,amp/2),gate);
		out = (wave * eg * amp)+(LPF.ar(WhiteNoise.ar(eg2),5000));
		Out.ar(b, out);
	}).store;
	
	SynthDef("lt", { arg freq=25, amp=1, gate=0;
		var wave, eg, eg2, out;
		wave = SinOsc.ar(freq,0,SinOsc.kr(45));
		wave = LPF.ar(wave, 200);
		eg = EnvGen.kr(Env.perc(0.01,0.2,amp),gate);
		eg2 = EnvGen.kr(Env.perc(0,0.02,amp/2),gate);
		out = (wave * eg * amp)+(LPF.ar(WhiteNoise.ar(eg2),5000));
		Out.ar(b, out);
	}).store;
	
	SynthDef("cb", { arg amp=1, gate=0;
		var out, freq1, freq2, eg;
		freq1 = Pulse.ar(587, 0.3, 0.2);
		freq2 = Pulse.ar(845, 0.5, 0.1);
		out = Mix.new([freq1, freq2, PinkNoise.ar(0.1)]);
		out = EnvGen.kr(Env.perc(0.001, 1, 1, -8),gate) * out * amp;
		out = BPF.ar(out, 2000);
		Out.ar([0,1], out);
	}).store;
	
	SynthDef("bd", { arg freq=70, amp=1, gate=0;
		var wave, eg1, eg2, out;
		wave = SinOsc.ar(freq, SinOsc.kr(45));
		wave = LPF.ar(wave, 300);
		eg1 = EnvGen.kr(Env.perc(0,0.225,amp,'linear'), gate);
		eg2 = EnvGen.kr(Env.perc(0,0.02,amp/2), gate);
		out = (wave * eg1)+(LPF.ar(WhiteNoise.ar(eg2),5000));
		Out.ar(b, out);
	}).store;
	
	SynthDef("sd", { arg amp=1, pan=0, gate=0;
		var eg1, eg2, snare, drum, out;
		eg1 = EnvGen.kr(Env.perc(0.01,0.3,amp*1.5),gate);
		eg2 = EnvGen.kr(Env.perc(0.01,0.2,amp/2),gate);
		snare = Resonz.ar(WhiteNoise.ar,1400,0.5,eg1);
		drum = SinOsc.ar(250,0,SinOsc.kr(70)*eg2);
		out = snare + drum;
		Out.ar(b, out);
	}).store;
	
	SynthDef("ch", { arg amp=1, gate=0;
		var eg, out;
		eg = EnvGen.kr(Env.perc(0,0.1,amp),gate);
		out = Resonz.ar(WhiteNoise.ar,7000,0.5,eg);
		Out.ar(b, out);
	}).store;
	
	SynthDef("hh", { arg amp=1, gate=0;
		var eg, out;
		eg = EnvGen.kr(Env.perc(0,0.5,amp),gate);
		out = Resonz.ar(WhiteNoise.ar,7000,0.5,eg);
		Out.ar(b, out);
	}).store;
	
	SynthDef("synth", {arg freq, amp=1, gate=0, pitch=1, delay=0.01, mix=0;
		var out, eg, oct1, oct2;
		out = Pulse.ar(freq, 0.5, gate);
		out = PitchShift.ar(out, 0.2, pitch, 0, delay);
		oct1 = PitchShift.ar(out, 0.2, pitch*2, 0, delay, mix);
		oct2 = PitchShift.ar(out, 0.2, pitch/2, 0, delay, mix);
		out = Mix.new([out,oct1,oct2]);
		Out.ar(b, out);
	}).store;
	
	SynthDef("output", { arg delay=2, preGain=1, postGain=1, feedback=1, lpf=20000;
		var sig, local;
		sig = In.ar(b, 1)*preGain;
		local = LocalIn.ar(1)*feedback;
		local = (DelayN.ar(local, 8, delay, 1, sig)*postGain).softclip;
		LocalOut.ar(local);
		Out.ar([0,1], local);
	}).store;
	
	inst = Group.new(s);
	fx = Group.new(inst, \addAfter);
	a = Synth("bd", target: inst, addAction: \addToTail);
	b = Synth("sd", target: inst, addAction: \addToTail);
	c = Synth("ch", target: inst, addAction: \addToTail);
	d = Synth("hh", target: inst, addAction: \addToTail);
	h = Synth("ht", target: inst, addAction: \addToTail);
	i = Synth("mt", target: inst, addAction: \addToTail);
	j = Synth("lt", target: inst, addAction: \addToTail);
	k = Synth("cb", target: inst, addAction: \addToTail);
	e = Synth("synth", target: inst, addAction: \addToTail);
	f = Synth("output", [\delay, 2], fx, \addToTail);
	g = Array.fill(25, { arg i; i+48});
	
	NoteOnResponder( { |src,chan,note,vel| a.set(\amp,vel/64, \gate,1); }, nil, 9, 36, nil);
	NoteOffResponder( { |src,chan,note,vel| a.set(\gate,0) }, nil, 9, 36, nil);
	
	NoteOnResponder( { |src,chan,note,vel| b.set(\amp,vel/64, \gate,1); }, nil, 9, 38, nil);
	NoteOffResponder( { |src,chan,note,vel| b.set(\gate,0) }, nil, 9, 38, nil);
	
	NoteOnResponder( { |src,chan,note,vel| c.set(\amp,vel/64, \gate,1); }, nil, 9, 46, nil);
	NoteOffResponder( { |src,chan,note,vel| c.set(\gate,0) }, nil, 9, 46, nil);
	
	NoteOnResponder( { |src,chan,note,vel| d.set(\amp,vel/64, \gate,1); }, nil, 9, 42, nil);
	NoteOffResponder( { |src,chan,note,vel| d.set(\gate,0) }, nil, 9, 42, nil);
	
	NoteOnResponder( { |src,chan,note,vel| h.set(\amp,vel/64, \gate,1); }, nil, 9, 50, nil);
	NoteOffResponder( { |src,chan,note,vel| h.set(\gate,0) }, nil, 9, 36, nil);
	
	NoteOnResponder( { |src,chan,note,vel| i.set(\amp,vel/64, \gate,1); }, nil, 9, 45, nil);
	NoteOffResponder( { |src,chan,note,vel| i.set(\gate,0) }, nil, 9, 38, nil);
	
	NoteOnResponder( { |src,chan,note,vel| j.set(\amp,vel/64, \gate,1); }, nil, 9, 51, nil);
	NoteOffResponder( { |src,chan,note,vel| j.set(\gate,0) }, nil, 9, 46, nil);
	
	NoteOnResponder( { |src,chan,note,vel| k.set(\amp,vel/64, \gate,1); }, nil, 9, 49, nil);
	NoteOffResponder( { |src,chan,note,vel| k.set(\gate,0) }, nil, 9, 42, nil);
	
	NoteOnResponder({|src,chan,note,vel| e.set(\freq, note.midicps, \gate,1);}, nil, 0, g, nil);
	NoteOffResponder({|src,chan,note,vel| e.set(\gate,0) }, nil, 0, g, nil);
	
	CCResponder( { |src,chan,num,val| f.set(\delay,val); }, nil, 0, 71, nil);
	CCResponder( { |src,chan,num,val| f.set(\preGain,1+val); }, nil, 0, 74, nil);
	CCResponder( { |src,chan,num,val| f.set(\postGain,1+val); }, nil, 0, 84, nil);
	CCResponder( { |src,chan,num,val| f.set(\feedback,val); }, nil, 0, 7, nil);
	
	CCResponder( { |src,chan,num,val| e.set(\delay,val*0.0015625,\mix,1/128); }, nil, 0, 1, nil);
	BendResponder( { |src,chan,val| e.set(\pitch,val*2/16000); });
)

(
MIDIResponder.removeAll;
NoteOnResponder.removeAll;
NoteOffResponder.removeAll;
CCResponder.removeAll;
)