{
   "ancestor_list" : [],
   "description" : "A more simple example using the shared memory interface to get the current status of a bus, and also setting a bus from the GUI.\r\nThe circle turns red depending on the oscillator value, and the oscillator frequency and amplitude are controlled by the x, y position of the circle in the window.",
   "author" : "rukano",
   "name" : "Simple animated 2D user interface",
   "id" : "1-4Qf",
   "is_private" : null,
   "code" : "// needs shared memory interface (SC 3.5+)\r\n\r\nServer.default = s = Server.local;\r\ns.waitForBoot{\r\n\tif (s.hasShmInterface) {\r\n\t\tw = Window().front;\r\n\t\tu = UserView(w, w.view.bounds);\r\n\t\tf = { |x, y|\r\n\t\t\tvar size = 20 + (y/4);\r\n\t\t\tk = k.center_(Point(x, y));\r\n\t\t\tk = k.size_(Size(size, size));\r\n\t\t\tb.setSynchronous(x.linlin(0,u.bounds.width, 1/4, 16));\r\n\t\t\tc.setSynchronous(50*(y/4));\r\n\t\t};\r\n\t\tw.onClose = { Ndef(\\sound).end(1) };\r\n\t\tu.background = Color.blue(0.5);\r\n\t\tu.animate = true;\r\n\t\tk = Rect(100, 100, 50, 50);\r\n\t\tu.drawFunc = {\r\n\t\t\tvar osc = Ndef(\\osc).bus.getSynchronous * 0.5 + 0.5;\r\n\t\t\tPen.strokeColor = Color.blue;\r\n\t\t\tPen.addOval(k);\r\n\t\t\tPen.fillRadialGradient(\r\n\t\t\t\tk.center,\r\n\t\t\t\tk.center,\r\n\t\t\t\tk.width/8,\r\n\t\t\t\tk.width,\r\n\t\t\t\tColor(1,1,1,0),\r\n\t\t\t\tColor(1,0,0,osc)\r\n\t\t\t);\r\n\t\t};\r\n\t\t\r\n\t\tu.mouseMoveAction = { |u, x, y| f.(x, y) }; \r\n\t\tu.mouseDownAction = { |u, x, y| f.(x, y) }; \r\n\t\t\r\n\t\tb = Bus.control(s);\r\n\t\tc = Bus.control(s);\r\n\t\tb.setSynchronous(4);\r\n\t\tc.setSynchronous(500);\r\n\t\t\r\n\t\tNdef(\\osc, { SinOsc.kr(b.kr) });\r\n\t\tNdef(\\sound).fadeTime = 1;\r\n\t\tNdef(\\sound, { MoogFF.ar(LFSaw.ar(50+[0,1]), Ndef(\\osc).kr.linexp(-1,1,50,c.kr)) }).play;\r\n\t} {\r\n\t\t\"get SC 3.5 or higher ;)\".warn;\r\n\t};\r\n};",
   "labels" : [
      "synchronization",
      "control bus",
      "audiovisual",
      "animated user interface"
   ]
}
