{
   "labels" : [
      "filters"
   ],
   "code" : "(\r\ns.waitForBoot{\r\n\tvar synth, srcs, snds, path, win, bnds, view, vIn, scope, h, w, v, iW, oW, btns, f, snd, flt, fltSel, fltTxts;\r\n\t\r\n\tfltSel = Bus.control(s,1);\r\n\t\r\n\tsynth = {\r\n\t\targ which, frq, mul;\r\n\t\tvar in, src, rq;\r\n\t\tin = Saw.ar(200,0.3!2);\r\n\t\tsrcs = [\r\n\t\t\tDecay.ar(\r\n\t\t\t\tImpulse.ar(LFGauss.kr(5, 0.5).range(2, 7)),\r\n\t\t\t\t0.1,\r\n\t\t\t\tin*MouseButton.kr(0, 1, 0.001)\r\n\t\t\t),\r\n\t\t\tWhiteNoise.ar(0.08!2),\r\n\t\t\tPinkNoise.ar(0.08!2),\r\n\t\t\tBrownNoise.ar(0.08!2),\r\n\t\t\tGrayNoise.ar(0.08!2),\r\n\t\t\tClipNoise.ar(0.08!2),\r\n\t\t\tImpulse.ar(10!2),\r\n\t\t\tDust.ar(10!2),\r\n\t\t\tDust2.ar(10!2),\r\n\t\t\tCrackle.ar(1.5, 0.08!2)\r\n\t\t];\r\n\t\tsrc = Select.ar(which, srcs);\r\n\t\t\r\n\t\trq = MouseY.kr(0.01, 10, 1);\r\n\t\t\r\n\t\tsnds = [\r\n\t\t\tsrc,\r\n\t\t\tLPF.ar(src, frq),\r\n\t\t\tLPF.ar(LPF.ar(src, frq), frq),\r\n\t\t\tHPF.ar(src, frq),\r\n\t\t\tBRF.ar(src, frq, rq),\r\n\t\t\tBPF.ar(src, frq, rq),\r\n\t\t\tResonz.ar(src, frq, rq),\r\n\t\t\tResonz.ar(\r\n\t\t\t\tResonz.ar(src, frq, rq),\r\n\t\t\t\tfrq,\r\n\t\t\t\trq\r\n\t\t\t),\r\n\t\t\tBBandPass.ar(src, frq, rq),\r\n\t\t\tRLPF.ar(src, frq, rq),\r\n\t\t\tRHPF.ar(src, frq, rq)\r\n\t\t];\r\n\t\t\r\n\t\tflt = Out.kr(fltSel, MouseX.kr(0, snds.size));\r\n\t\t\r\n\t\tSelect.ar(In.kr(fltSel), snds) * mul\r\n\t};\r\n\t\r\n\tsnd = synth.play(args:[frq:1000, mul:0, which:0]);\r\n\t\r\n\tbnds = Window.screenBounds;\r\n\th = bnds.height;\r\n\tw = bnds.width;\r\n\twin = Window(\"control\", Rect(0, 0, w, h)).fullScreen;\r\n\twin.onClose_{ snd.free };\r\n\tiW = w/srcs.size;\r\n\toW = w/snds.size;\r\n\t\r\n\tStaticText(win, Rect(10, 10, 500, 30))\r\n\t.align_(\\topLeft)\r\n\t.font_(Font(\"Arial\", 24))\r\n\t.string_(\"Input Signal (Source) Seleciton:\");\r\n\t\r\n\tbtns = srcs.size.collect {\r\n\t\t|i|\r\n\t\tvar x, inputs, outputs;\r\n\t\tinputs = [\r\n\t\t\t\"decay\",\r\n\t\t\t\"whiteNoise\",\r\n\t\t\t\"pinkNoise\",\r\n\t\t\t\"brownNoise\",\r\n\t\t\t\"grayNoise\",\r\n\t\t\t\"clipNoise\",\r\n\t\t\t\"impulse\",\r\n\t\t\t\"dust\",\r\n\t\t\t\"dust2\",\r\n\t\t\t\"crackle\"\r\n\t\t][i];\r\n\t\tButton(win, Rect(iW * i, 50, iW, 30))\r\n\t\t.states_([\r\n\t\t\t[inputs, Color.grey, Color.white],\r\n\t\t\t[inputs, Color.white, Color.grey]\r\n\t\t])\r\n\t\t.action_{ arg butt;\r\n\t\t\tif(butt.value == 1) {\r\n\t\t\t\tsnd.set(\\which, i);\r\n\t\t\t\tbtns.size.do{|n|\r\n\t\t\t\t\t[n, i];\r\n\t\t\t\t\tif (n != i) { btns[n].value = 0 }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t.value_(if(i==0) { 1 })\r\n\t};\r\n\t\r\n\tStaticText(win, Rect(10, 95, 2000, 60))\r\n\t.align_(\\topLeft)\r\n\t.font_(Font(\"Arial\", 24))\r\n\t.string_(\"Input Signal (Source) Seleciton: Select the output signal (filtered sound) by pressing the mouse button and dragging the mouse pointer across the columns. The vertical position of the 5th through 11th columns is related to the Q-factor.\");\r\n\t\r\n\tview = UserView(win, Rect(0, 160, w, h-430));\r\n\t\r\n\tvIn = true;\r\n\t\r\n\tview\r\n\t.mouseDownAction_{ |view, x, y, modifiers, buttonNumber, clickCount|\r\n\t\tif(buttonNumber==0 && (clickCount==1)) { snd.set(\\mul, 1) }\r\n\t}\r\n\t.mouseUpAction_{ |view, x, y, modifiers, buttonNumber, clickCount|\r\n\t\tif(buttonNumber==0) { snd.set(\\mul, 0) }\r\n\t}\r\n\t.mouseLeaveAction_{ |view, x, y|\r\n\t\tsnd.set(\\mul, 0)\r\n\t}\r\n\t.mouseMoveAction_{ | view, x, y |\r\n\t\tif (view.bounds.containsPoint(x@(y + 160))) {\r\n\t\t\tvIn = true;\r\n\t\t\tsnd.set(\\mul, 1)\r\n\t\t} {\r\n\t\t\tif (vIn) {\r\n\t\t\t\tvIn = false;\r\n\t\t\t\tview.mouseLeaveAction.()\r\n\t\t} }\r\n\t}\r\n\t.animate_(true);\r\n\t\r\n\tfltTxts = snds.size.collect{\r\n\t\t|i|\r\n\t\tvar outputs;\r\n\t\toutputs = [\r\n\t\t\t\"S\\nR\\nC\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nL\\nP\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nL\\nP\\nF\\n↓\\nL\\nP\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nH\\nP\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nB\\nR\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nB\\nP\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\\n↓\\nR\\nE\\nS\\nO\\nN\\nZ\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nB\\nB\\nA\\nN\\nD\\nP\\nA\\nS\\nS\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nR\\nL\\nP\\nF\",\r\n\t\t\t\"S\\nR\\nC\\n↓\\nR\\nH\\nP\\nF\"\r\n\t\t][i];\r\n\t\tStaticText(view, Rect(oW * (i + 0.1), 10, 200, 500))\r\n\t\t.align_(\\topLeft)\r\n\t\t.font_(Font(\"Arial\", 24))\r\n\t\t.string_(outputs)\r\n\t};\r\n\t\r\n\tview.drawFunc = {\r\n\t\tsnds.do {\r\n\t\t\t|which, i|\r\n\t\t\tPen.strokeColor = Color.black;\r\n\t\t\tPen.moveTo(0@0);\r\n\t\t\tPen.lineTo(0@h);\r\n\t\t\tPen.translate(oW, 0);\r\n\t\t\tPen.stroke;\r\n\t\t\t\r\n\t\t\tfltTxts[i].stringColor_(\r\n\t\t\t\tif(fltSel.getSynchronous.asInteger==i) {\r\n\t\t\t\t\tColor.black\r\n\t\t\t\t}{\r\n\t\t\t\t\tColor.gray\r\n\t\t\t\t}\r\n\t\t\t)\r\n\t\t}\r\n\t};\r\n\t\r\n\tServerMeterView.new(s, win, 10@(h-235), 0, 2);\r\n\t\r\n\tscope = UserView(win, Rect(90, h-257, 247, 247));\r\n\tStethoscope(s, view:scope);\r\n\t\r\n\tFreqScopeView(win, Rect(350, h-255, w-360, 245))\r\n\t.active_(true)\r\n\t.freqMode_(1);\r\n\t\r\n\twin.front\r\n}\r\n)",
   "id" : "1-5ao",
   "is_private" : null,
   "name" : "Filter Explorer  @  1000 Hz of the Cutoff Frequency (Centre Frequency)",
   "author" : "prko",
   "ancestor_list" : [],
   "description" : "Special Thanks to Russell Johnston who gave an excellent solution to MouseLeaveAction issue via the sc-users list!\r\nThanks to Fredrik Olofsson who mentioned to the related issue as well."
}
