«A Multichannel Convolution Reverb» by prko

on 24 Apr'18 04:05 in reverbmultichannelconvolution
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
(
~numIRs = 4;
~fftsize = 2048;
s.waitForBoot {
	var irs, irbuffs, bufsizes, nextmod, numSamples;
	nextmod = 100;
	numSamples = 40000 ;
	
	/* an array of multiple IRs */
	irs = ~numIRs.collect{ arg nth;
		// nth is here not used, but can be useful to scale decay time.
		[0] ++ 0.dup(100) ++ Array.fill(
			numSamples, { arg i;
				(i%nextmod==0).if
				{
					nextmod= rrand(80, 120);
					(i.asFloat/numSamples).squared * 0.3
				} {
					0
				}
			}
		)
	};
	{ irs.plot }.defer; // to show irs.
	
	/* an array of buffers. */
	irbuffs = ~numIRs.collect{ arg i; Buffer.loadCollection(s, irs[i]) };
	irbuffs.postln; // to show irbuffs info.
	s.sync;
	
	bufsizes= irbuffs.collect{ |nth|PartConv.calcBufSize(~fftsize, nth) };
	~irSpctrms = bufsizes.collect{ arg size, i;
		Buffer
		.alloc(s, size, 1)
		.preparePartConv(irbuffs[i], ~fftsize)
	};
	s.sync; 
	
	~numIRs.do{|i| irbuffs[i].free}
}
)

(
fork{
	~target= Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
	s.sync;
	{
		var in, krnl;
		in= PlayBuf.ar(1, ~target, loop:1);
		
		/* an array of multiple instances of PartConv */
		krnl= ~numIRs.collect{ arg i;
			PartConv.ar(in, ~fftsize, ~irSpctrms[i].bufnum, 0.2)};
		// By iterating, each PartConv processes a mono-channel buffer in the array ~irSpctrms.
		
		Out.ar(0, krnl);
	}.play
}
)
raw 1368 chars (focus & ctrl+a+c to copy)
reception
comments