{
   "name" : "Custom event type for wiring up effects",
   "author" : "david_morgan",
   "description" : "",
   "ancestor_list" : [],
   "labels" : [
      "event type"
   ],
   "id" : "1-51t",
   "is_private" : null,
   "code" : "(\r\n// add custom event\r\nEvent.addEventType(\\nbind, {arg server;\r\n\r\n\tvar id = (currentEnvironment[\\ndef] ? currentEnvironment[\\instrument]).asSymbol;\r\n\tvar type = \\note;\r\n\r\n\tif (Ndef(id).isPlaying.not) {\r\n\t\tNdef(id).play;\r\n\t};\r\n\r\n\t~type = type;\r\n\t~group = Ndef(id).group;\r\n\t~out = Ndef(id).bus;\r\n\r\n    currentEnvironment.play;\r\n});\r\n\r\n// synth\r\nSynthDef(\\synth1, {arg freq = 440, out = 0;\r\n\t\r\n\tvar env = Env.perc.kr(doneAction:2);\r\n\tvar sig = SinOscFB.ar(freq * [1, 1.01], 0.7);\r\n\tsig = sig * env;\r\n\tOffsetOut.ar(out, Splay.ar(sig));\r\n\t\r\n}).add;\r\n\r\n// set up first set of fx\r\nNdef(\\fx1).play;\r\nNdef(\\fx1)[0] = \\filter -> {arg in;\r\n\tin.abs;\r\n};\r\n\r\n// set up additional fx\r\nNdef(\\fx2).play;\r\nNdef(\\fx2)[0] = \\filter -> {arg in;\r\n\tin + AllpassC.ar(in, 0.2, 0.2, [3, 5]);\r\n};\r\n\r\n)\r\n\r\n// play a pattern\r\nPbind(\\instrument, \\synth1, \r\n\t// specify custom event type\r\n\t\\type, \\nbind, \r\n\t// switch between fx\r\n\t\\ndef, Pseq([\\fx1, \\fx2], inf),\r\n\t\\degree, Pwhite(0, 5, inf)\r\n).play;"
}
