Animate from SuperCollider.
Use SuperCollider for Animation
Using low frequency oscillators (LFO) and Open Sound Control (OSC).Low Frequency Oscillator
Here SuperCollider is used as low frequency oscillator (LFO) to control the graphic animation. Approximately every frame the SClang program sends OSC messages to aNa. This updates the variables u1, u2 and u3 in aNa.
The OSC messages can of course be sent from another program. Also the SuperCollider server is not active, because only the SClang interpreter is needed.
// 57220 is the default port number for analog NOT analog server
n = NetAddr("127.0.0.1", 57220);
~fps = (1.0 / 25.0); // frames per second
// lfo for u0: unused in the Cojure part
Tdef(\par_u0, {
var x1 = Plazy({ Pseries(0, 0.005, inf) }).loop.asStream;
var x2 = Plazy({ Pbrown(-3.14159, 3.14159, 0.05) }).loop.asStream;
loop({
n.sendMsg("/ana_u0",
(sin(x1.next) + sin(x2.next)) * 0.25);
~fps.wait;
})
});
Tdef(\par_u0).play;
// lfo for u1: send to ras1
Tdef(\par_u1, {
var x1 = Plazy({ Pseries(0, 0.0125, inf) }).loop.asStream;
var x2 = Plazy({ Pbrown(-3.14159, 3.14159, 0.05) }).loop.asStream;
loop({
n.sendMsg("/ana_u1", sin(x1.next) + sin(x2.next));
~fps.wait;
})
});
Tdef(\par_u1).play;
// lfo for u2: send to ras2
Tdef(\par_u2, {
var x1 = Plazy({ Pseries(0, 0.025, inf) }).loop.asStream;
var x2 = Plazy({ Pwhite(-0.14, 0.14, inf) }).loop.asStream;
loop({
n.sendMsg("/ana_u2", sin(x1.next) + x2.next);
~fps.wait;
})
});
Tdef(\par_u2).play;
// lfo for u3: brownian motion: send to ras3
Tdef(\par_u3, {
var x1 = Plazy({ Pbrown(0, 1.0, 0.01) }).loop.asStream;
loop({
n.sendMsg("/ana_u3", x1.next);
~fps.wait;
})
});
Tdef(\par_u3).play;
/*
n.sendMsg("/ana_render", "(render [3])");
n.sendMsg("/ana_render", "(render [])");
*/
/*
Tdef(\par_u0).play;
Tdef(\par_u1).play;
Tdef(\par_u2).play;
Tdef(\par_u3).play;
*/
/*
Tdef(\par_u0).stop;
Tdef(\par_u1).stop;
Tdef(\par_u2).stop;
Tdef(\par_u3).stop;
*/
(layout "grid" [img0 ras1] [ras2 ras3])
; assume there are 4 PNG images in the media folder.
(image "flower-sampler/*.png")
(render)
; convert to gray-scale and invert
(hsv :img0 [c0 c1 c2 c3]
(v (- 1 c3.v))
)
; a simple gradient using lfo \par_u1
(hsv :ras1 []
(v (* (- 1 y u1)))
)
; concentric discs using lfo \par_u2
(hsv :ras2 []
(v (/ (floor (* 7 (- 1 r u2))) 7))
)
; blending upstream images with \par_u3
(hsv :ras3 [img0 ras1 ras2]
(rot (* 0.002 (pos? (- u3 0.01) f 0)))
(v (* img0.v (mix ras1.v ras2.v (- 1 a u3))))
)