{
   "code" : "MIDIIn.connectAll;\r\n// MIDIClient.init;\r\n\r\n\r\n(\r\n// A SynthDef with ADSR envelope\r\nSynthDef(\"quick2\", {arg freq = 440, amp = 0.1, gate = 1;\r\n\tvar snd, env;\r\n\tenv = Env.adsr(0.01, 0.1, 0.3, 2, amp).kr(2, gate);\r\n\tsnd = Saw.ar(freq: [freq, freq*1.5], mul: env);\r\n\tOut.ar(0, snd)\r\n}).add;\r\n)\r\n\r\n// Play it with a MIDI keyboard\r\n(\r\nvar noteArray = Array.newClear(128); // array has one slot per possible MIDI note\r\n\r\nMIDIdef.noteOn(\\myKeyDown, {arg vel, note;\r\n\tnoteArray[note] = Synth(\"quick2\", [\\freq, note.midicps, \\amp, vel.linlin(0, 127, 0, 1)]);\r\n\t[\"NOTE ON\", note].postln;\r\n});\r\n\r\nMIDIdef.noteOff(\\myKeyUp, {arg vel, note;\r\n\tnoteArray[note].set(\\gate, 0);\r\n\t[\"NOTE OFF\", note].postln;\r\n});\r\n)\r\n// PS. Make sure SC MIDI connections are made (MIDIIn.connectAll)",
   "is_private" : null,
   "id" : "1-5aI",
   "labels" : [
      "midi",
      "keyboard",
      "saw"
   ],
   "ancestor_list" : [],
   "description" : "Basic example - how to use a MIDI keyboard with a simple synth",
   "author" : "Bruno Ruviaro",
   "name" : "Using a MIDI keyboard - simple example"
}
