MIDIClient.init;
MIDIClient.sources.do;

MIDIIn.connect(0);

MIDIIn.connectAll;

(
~sampleDir = PathName("~/snd/samples/808/").fullPath;

~samples = (
	42: Buffer.read(s, ~sampleDir +/+ "ch.wav"),
	46: Buffer.read(s, ~sampleDir +/+ "oh.wav"),
	49: Buffer.read(s, ~sampleDir +/+ "cy.wav"),
	56: Buffer.read(s, ~sampleDir +/+ "cb.wav"),
	39: Buffer.read(s, ~sampleDir +/+ "cp.wav"),
	37: Buffer.read(s, ~sampleDir +/+ "rs.wav"),
	50: Buffer.read(s, ~sampleDir +/+ "ht.wav"),
	47: Buffer.read(s, ~sampleDir +/+ "mt.wav"),
	43: Buffer.read(s, ~sampleDir +/+ "lt.wav"),
	38: Buffer.read(s, ~sampleDir +/+ "sd.wav"),
	36: Buffer.read(s, ~sampleDir +/+ "bd.wav"),
	70: Buffer.read(s, ~sampleDir +/+ "ma.wav"),
	75: Buffer.read(s, ~sampleDir +/+ "cl.wav"),
	62: Buffer.read(s, ~sampleDir +/+ "hc.wav"),
	63: Buffer.read(s, ~sampleDir +/+ "mc.wav"),
	64: Buffer.read(s, ~sampleDir +/+ "lc.wav")
);
);

~playSample = { |note|
	var buf = ~sample[note];
	if (buf.notNil) {
		Synth(\samplePlayer, [\buf, buf]);
	};
};

MIDIdef.noteOn(\tr08Trigger, { |vel, note, chan, src|
	~playSample.(note);
});


MIDIdef.cc[\cc_debug, { |val, num, chan, src|
	[num, val].postln;
});