// title: Synchronous control bus visualizer using the shared memory interface // author: rukano // 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. // Extra: you can click on the zone of the moving circle to pause and resume the running synth on that bus :) // code: // If it doesn't work, please read! // * Needs actual SC version 3.5+ (shared memory interface) // * Needs Qt GUI var makeGui = { var getVal = { |key| Ndef(key).bus.getSynchronous }; var w, v; GUI.qt; w = Window("sync").front; w.onClose = { #[aa,bb,cc,dd,ee].do{ |k| Ndef(k).end(3) }; }; u = UserView(w, w.view.bounds); u.background = Color.white; u.animate = true; u.clearOnRefresh = false; u.drawFunc = { var width = u.bounds.width; // Pen.fontColor Pen.stringAtPoint("Click on a zone to pause or resume the oscillator", Point(0,0)); Pen.fillColor = Color(1, 1, 1, 0.1); Pen.fillRect(u.bounds); #[a,b,c,d,e].do{ |k, i| Pen.strokeColor = Color(i/4, sin(i*pi)*0.5+0.5, k.ascii[0]-97/5); Pen.strokeOval(Rect(getVal.(k).linlin(-1,1,0,width-100),25+(i*75),50,50)); }; }; u.mouseDownAction = { |u, x, y| var k = #[a,b,c,d,e][floor(y/(u.bounds.height/5))]; if( Ndef(k).paused ) { Ndef(k).resume } { Ndef(k).pause }; }; }; ////////////////////////////////// Server.default = s = Server.local; s.waitForBoot{ if( s.hasShmInterface ) { // LFOs Ndef(\a, { SinOsc.kr(1) }); Ndef(\b, { SinOsc.kr(1.05) }); Ndef(\c, { LFNoise0.kr(4) }); Ndef(\d, { LFSaw.kr(1/8) }); Ndef(\e, { LFPulse.kr(4) }); // Sounds #[aa,bb,cc,dd,ee].do{ |n| Ndef(n).fadeTime = 4 }; Ndef(\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; Ndef(\bb, { MoogFF.ar(LFSaw.ar(50+[0,0.5]), Ndef(\e).kr * (Ndef(\c).kr*250) + 150, 3) * 0.5 }).play; Ndef(\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; Ndef(\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; Ndef(\ee, { var f = 50*Ndef(\c).kr.linexp(-1,1,2,8).round.lag(0.1); Splay.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)) * 0.3 }).play; // make gui makeGui.value; } { "get the latest SC version ;)".warn; }; };