«sonic focal depth» by danstowell

on 14 May'12 18:06 in

Ten layers of sound, all constantly running, yet only one is in "sharp focus" at any time. Move the mouse up and down to control the focal depth. by Dan Stowell 2012-05-14, after a chat w Simon Katan.

You'll need the PV_MagSmooth ugen which is in sc3-plugins.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
sonic focal depth
Ten layers of sound, all constantly running,
yet only one is in "sharp focus" at any time.
Move the mouse up and down to control the focal depth.
by Dan Stowell 2012-05-14, after a chat w Simon Katan.

You'll need the PV_MagSmooth ugen which is in sc3-plugins.
*/

s.boot

~nlayers = 10;
~basefreqs = ~nlayers.collect{|x|  (x * 7 + 60).midicps};
~fftbufs = ~nlayers.collect{ Buffer.alloc(s, 2048) };

(
x = {
	var layers, position, trig, ampenv, freqenv, layerpos, smoothfactor, ampfactor;
	position = MouseY.kr(0, 1);
	/* Create sounds - each layer must have spectral variation in it */
	layers = ~basefreqs.collect{ |basefreq|
		trig = Dust.ar(10);
		ampenv = Decay2.ar(trig, 0.0001, 0.2);
		freqenv = Decay.ar(trig, 0.1).linexp(0,1,1,1.5);
		SinOsc.ar(freqenv * basefreq, 0, ampenv);
	};
	/* Now apply focal effect - least smoothing (0) when the 
		mouse is at the same "position" as a layer */
	layers = layers.collect{|son, i|
		layerpos = i / (~nlayers - 1); // 0 to 1
		smoothfactor = 1 - (layerpos - position).abs.linexp(0,1, 1, 0.0005);
		ampfactor    =     (layerpos - position).abs.linlin(0,1, 1, 0.9);
		IFFT(PV_MagSmooth(FFT(~fftbufs[i], son), smoothfactor))
		 * ampfactor * AmpCompA.ir(~basefreqs[i], ~basefreqs[3])
	};
	layers.mean.dup
}.play;
)

x.free
raw 1330 chars (focus & ctrl+a+c to copy)
reception
comments
Simon Katan user 28 Jun'12 08:07

Cheers for this Dan,

I finally got round to investigating this. I'm using the same approach for the piece we were chatting about and it works great. Will show you at the next SC meetup