Color to Sound Panning
Convert position to stereo panning
Controlling stereo panning.Animation
(ns lv.demo)
(use 'lv.core)
(layout "grid" [ras0 mov1]
[ras2 ras3])
(movie "../../../timelapse/series/20210401-hirsch-1/hirsch-1.mkv")
(texpr
; use nanoKONTROL2 als input
; ks0 0.81102
; ks1 0.32283
(t0 (- 1 (* 2 ks0)))
(t1 (- 1 (* 2 ks1)))
)
(hsv :ras0 []
(v (+ (pow (- 1 (abs (+ x (snoise y (* 0.011 f))))) 8)
(pow (- 1 (abs (+ x (snoise y (* 0.023 f))))) 2)))
)
(hsv :mov1 [c0]
(sy 1.42)
(s 0.2)
(h (+ c0.h 0.5))
(v (- 1 (- c0.v r)))
)
(hsv :ras2 [ras0 ras2]
(v (mix (max ras2.v 0) (sqr ras0.v) kp7))
)
(hsv :ras3 [mov1 ras2]
(s (max 0 (- 0.7 r)))
(h mov1.h 0.5)
(v (* (sqr mov1.v) ras2.v))
)
(render 3)
(inspect [ras3]
"color2sound/analyse_dualhead_color.cl"
(channels 2)
(x0 (* 1.7 (snoise (* 0.0051 f) 0.1 0.2)))
(y0 t0)
(r0 ks7)
(x1 (* 1.7 (snoise (* 0.0053 f) 0.5 0.6)))
(y1 t1)
(r1 ks7)
)
The graphic animation is sampled at 2 moving areas. The x-position values of these areas are used to move the sound between both speakers.
SuperCollider
s.waitForBoot({
SynthDef(\AudioMix,
{ | out = 0,
cutlpf = 440,
v_value=0.1,
pan = 0 |
var snd1 = MoogLadder.ar(
Mix(LFSaw.ar([60, 90, 120, 185], 0, 0.33)),
LinExp.kr(v_value, 0, 0.2, 180, 1500),
0.75);
var rev1 = JPverb.ar(
snd1,
\t60.kr(1, 0.05),
\damp.kr(1, 0.05),
\size.kr(1, 0.05),
\earlydiff.kr(0.707, 0.05),
\mdepth.kr(5, 0.05),
\mfreq.kr(2, 0.05),
\lowx.kr(1, 0.05),
\midx.kr(1, 0.05),
\highx.kr(1, 0.05),
\lowband.kr(250, 0.05),
\highband.kr(1000, 0.05)
);
var lpf1 = LPF.ar(Mix([snd1*1.0, rev1*3.0]), cutlpf);
Out.ar(out, [lpf1*LinLin.kr(pan, -1, 1, 1, 0),
lpf1*LinLin.kr(pan, -1, 1, 0, 1)]);
}, \kr!4).add;
0.5.wait;
~toppos = Synth.new(\AudioMix,
[ \out, 0,
\cutlpf, 600]);
~botpos = Synth.new(\AudioMix,
[ \out, 0,
\cutlpf, 480]);
h.free;
h = OSCFunc({ |msg, time, addr, recvPort|
// from area x0
~toppos.set(\pan, msg[2]);
~toppos.set(\v_value, msg[7]);
// from area x1
~botpos.set(\pan, msg[8]);
~botpos.set(\v_value, msg[13]);
}, '/f_hsb4c');
q.free;
q = OSCFunc({ |msg, time, addr, recvPort|
// stop
[time, msg].postln;
s.quit;
0.exit;
}, '/f_collider/quit');
});
OpenCL color sampler
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
const sampler_t SAMPLER = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;
__kernel void image_analysis(__read_only image2d_t image1,
__global int * inparams,
__global int * result)
{
int px = get_global_id(0);
int py = get_global_id(1);
int dist0 = inparams[2];
if( (px >= inparams[0]-dist0)
&& (px <= inparams[0]+dist0)
&& (py >= inparams[1]-dist0)
&& (py <= inparams[1]+dist0)) {
int2 pos = (int2)(px, py);
float4 color = read_imagef(image1, SAMPLER, pos);
atomic_add(&result[0], 32768*fmax(0.0f, color.x));
atomic_add(&result[1], 32768*fmax(0.0f, color.y));
atomic_add(&result[2], 32768*fmax(0.0f, color.z));
atom_inc(&result[3]);
}
int dist1 = inparams[5];
if( (px >= inparams[3]-dist1)
&& (px <= inparams[3]+dist1)
&& (py >= inparams[4]-dist1)
&& (py <= inparams[4]+dist1)) {
int2 pos = (int2)(px, py);
float4 color = read_imagef(image1, SAMPLER, pos);
atomic_add(&result[4], 32768*fmax(0.0f, color.x));
atomic_add(&result[5], 32768*fmax(0.0f, color.y));
atomic_add(&result[6], 32768*fmax(0.0f, color.z));
atom_inc(&result[7]);
}
}