Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Simple animated 2D user interface
name
code content
// needs shared memory interface (SC 3.5+) Server.default = s = Server.local; s.waitForBoot{ if (s.hasShmInterface) { w = Window().front; u = UserView(w, w.view.bounds); f = { |x, y| var size = 20 + (y/4); k = k.center_(Point(x, y)); k = k.size_(Size(size, size)); b.setSynchronous(x.linlin(0,u.bounds.width, 1/4, 16)); c.setSynchronous(50*(y/4)); }; w.onClose = { Ndef(\sound).end(1) }; u.background = Color.blue(0.5); u.animate = true; k = Rect(100, 100, 50, 50); u.drawFunc = { var osc = Ndef(\osc).bus.getSynchronous * 0.5 + 0.5; Pen.strokeColor = Color.blue; Pen.addOval(k); Pen.fillRadialGradient( k.center, k.center, k.width/8, k.width, Color(1,1,1,0), Color(1,0,0,osc) ); }; u.mouseMoveAction = { |u, x, y| f.(x, y) }; u.mouseDownAction = { |u, x, y| f.(x, y) }; b = Bus.control(s); c = Bus.control(s); b.setSynchronous(4); c.setSynchronous(500); Ndef(\osc, { SinOsc.kr(b.kr) }); Ndef(\sound).fadeTime = 1; Ndef(\sound, { MoogFF.ar(LFSaw.ar(50+[0,1]), Ndef(\osc).kr.linexp(-1,1,50,c.kr)) }).play; } { "get SC 3.5 or higher ;)".warn; }; };
code 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. The 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.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change