{
   "labels" : [
      "synchronization",
      "control bus",
      "audiovisual",
      "animated user interface"
   ],
   "is_private" : null,
   "id" : "1-4Qe",
   "code" : "// If it doesn't work, please read!\r\n// * Needs actual SC version 3.5+ (shared memory interface)\r\n// * Needs Qt GUI\r\n\r\nvar makeGui = {\r\n\tvar getVal = { |key| Ndef(key).bus.getSynchronous };\r\n\tvar w, v;\r\n\tGUI.qt;\r\n\tw = Window(\"sync\").front;\r\n\tw.onClose = {\r\n\t\t#[aa,bb,cc,dd,ee].do{ |k| Ndef(k).end(3) };\r\n\t};\r\n\tu = UserView(w, w.view.bounds);\r\n\tu.background = Color.white;\r\n\tu.animate = true;\r\n\tu.clearOnRefresh = false;\r\n\tu.drawFunc = {\r\n\t\tvar width = u.bounds.width;\r\n//\t\tPen.fontColor\r\n\t\tPen.stringAtPoint(\"Click on a zone to pause or resume the oscillator\", Point(0,0));\r\n\t\tPen.fillColor = Color(1, 1, 1, 0.1);\r\n\t\tPen.fillRect(u.bounds);\r\n\t\t#[a,b,c,d,e].do{ |k, i|\r\n\t\t\tPen.strokeColor = Color(i/4, sin(i*pi)*0.5+0.5, k.ascii[0]-97/5);\r\n\t\t\tPen.strokeOval(Rect(getVal.(k).linlin(-1,1,0,width-100),25+(i*75),50,50));\r\n\t\t};\r\n\t};\r\n\t\r\n\tu.mouseDownAction = { |u, x, y|\r\n\t\tvar k = #[a,b,c,d,e][floor(y/(u.bounds.height/5))];\r\n\t\tif( Ndef(k).paused ) { Ndef(k).resume } { Ndef(k).pause };\r\n\t};\r\n};\r\n\r\n//////////////////////////////////\r\nServer.default = s = Server.local;\r\ns.waitForBoot{\r\n\tif( s.hasShmInterface ) {\r\n\t\t// LFOs\r\n\t\tNdef(\\a, { SinOsc.kr(1) });\r\n\t\tNdef(\\b, { SinOsc.kr(1.05) });\r\n\t\tNdef(\\c, { LFNoise0.kr(4) });\r\n\t\tNdef(\\d, { LFSaw.kr(1/8) });\r\n\t\tNdef(\\e, { LFPulse.kr(4) });\r\n\r\n\t\t// Sounds\r\n\t\t#[aa,bb,cc,dd,ee].do{ |n| Ndef(n).fadeTime = 4 };\r\n\t\tNdef(\\aa, { SinOscFB.ar([Ndef(\\a).kr, DelayN.kr(Ndef(\\a).kr,1/2,1/2)]*10+50, Ndef(\\b).kr*0.5+0.5) * 0.1 }).play;\r\n\t\tNdef(\\bb, { MoogFF.ar(LFSaw.ar(50+[0,0.5]), Ndef(\\e).kr * (Ndef(\\c).kr*250) + 150, 3) * 0.5 }).play;\r\n\t\tNdef(\\cc, { GVerb.ar(Resonz.ar(PinkNoise.ar!2, Ndef(\\d).kr * 3200 + 3300, 0.1) * Ndef(\\d).kr * 0.1 + 0.1, 200, 8) }).play;\r\n\t\tNdef(\\dd, { CombN.ar(Decay2.kr(HPZ1.kr(Ndef(\\e).kr), 0.01, Ndef(\\d).kr.linexp(-1,1,0.1,1.5)) * SinOsc.ar(Ndef(\\d).kr.linexp(-1,1,100,800).round(100).lag)!2 * 0.1, 1/2, 1/2, 4) }).play;\r\n\t\tNdef(\\ee, {\r\n\t\t\tvar f = 50*Ndef(\\c).kr.linexp(-1,1,2,8).round.lag(0.1);\r\n\t\t\tSplay.ar(BPF.ar(LFSaw.ar(f*{LFNoise2.kr(1/8).range(0.99,1.01)}!8), f*Ndef(\\c).kr.linlin(-1,1,1,8).lag(1), 0.3, 0.1))\r\n\t\t\t* 0.3\r\n\t\t}).play;\r\n\t\t\r\n\t\t// make gui\r\n\t\tmakeGui.value;\r\n\t} {\r\n\t\t\"get the latest SC version ;)\".warn;\r\n\t};\r\n};",
   "name" : "Synchronous control bus visualizer using the shared memory interface",
   "author" : "rukano",
   "ancestor_list" : [],
   "description" : "Messing around with Control buses and later Control Ndefs and using getSynchronous to use the exact value of the UGen in the draw function.\r\nExtra: you can click on the zone of the moving circle to pause and resume the running synth on that bus :)"
}
