«Mono2eN - Ndef, slightly altered» by LFSaw

on 26 Mar'13 18:01 in code forkspatialperformance tool

The ndef version of the mono2eN system, slightly adapted - a multichannel autospatilisation musical performance tool.

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// patch for benjolin spatialisation, original 2012 by Callum Goddard
// adapted and altered by Till Bovermann

(
q = q ? ();

q.inChannel   = 0;
q.numOutChans = 4;


s.waitForBoot{
	NdefMixer(s);
	Ndef(\for8).fadeTime = 10;
	Spec.add(\rotSpeed, [-10, 10]);
	Spec.add(\posLag, [0, 5, \exp]);
	Spec.add(\posLag, [0.001, 5, \exp]);
	Spec.add(\shifter, [0.25, 4]);
	Spec.add(\drive, [0, 10, 4]);


(
Ndef(\for8, {|drive = 1, rotSpeed = 1, posLag = 0.1, shifter = 1|
	var in, pos, width, sig, sig2, sig2pan, out, chain, centroid;
	var freq, hasFreq, freq2, hasFreq2;

	var numInternalChannels = 4;

	in = SoundIn.ar(q.inChannel);  // input
				
	width = \width.kr(4);
	
	

	// calculate spectral centroid (center of mass)
	// do some magic to scale it properly
	centroid = ((
		SpecCentroid.kr(
			FFT(LocalBuf(2048, 1), in)
		) * 0.0005
	) - 0.3 ) * 10;
	
	// new position determined by centroid, linearly lagged
	pos = VarLag.ar(K2A.ar(centroid), posLag, 0) * rotSpeed;

	sig = PanAz.ar(
	     numInternalChannels,
	     in,
	     pos,
	     0.5,
	     width
	);
	
	
	// Freezr
	#freq, hasFreq = Pitch.kr(
		in, 
		ampThreshold: 0.09, 
		median: 7
	);
	freq = freq * hasFreq * 0.01;


	chain = FFT({LocalBuf(2048, 1)}.dup(q.numOutChans), sig);
	chain = PV_MagFreeze(
		chain, 
		SinOsc.ar(
			(freq*100).lag2(\laggin.kr(0.1), 0)
		)
	);
	
	sig2 = IFFT(chain);
	sig2pan = SplayAz.ar(
		numInternalChannels,
		sig2,
		center: LFSaw.ar(0.125)
	);
	
	sig = PitchShift.ar(sig, 0.05, shifter, 0);
	
	(SplayAz.ar(
		q.numOutChans, 
		Mix([sig, sig2pan]).scramble
	) * drive).tanh;
})
);

//Ndef('for8').set('shifter', 1.0, 'posLag', 0.82647347718014, 'fadeTime', 10, 'width', 2.0, 'laggin', 0.76778019328278, 'drive', 1.0, 'rotSpeed', 0.1);

Ndef('for8').set('shifter', 1.0, 'posLag', 0.27577667345515, 'fadeTime', 10, 'width', 2.0, 'laggin', 1.078391331802, 'drive', 4.4666739998668, 'rotSpeed', -0.1);


//Ndef('for8').set('shifter', 1.0, 'posLag', 0.021611250555475, 'fadeTime', 10, 'width', 4.0, 'laggin', 0.17982121468705, 'drive', 6.9880842593118, 'rotSpeed', 0.4);

Ndef('for8').play(
	vol: 0.6914284026465

);

}
)
Ndef(\tester, {SoundIn.ar(0)})
NdefMixer(s)
raw 2258 chars (focus & ctrl+a+c to copy)
reception
comments