2 summary:: Real-time convolver with linear interpolation
3 related:: Classes/Convolution, Classes/Convolution2, Classes/Convolution3, Classes/StereoConvolution2L
4 categories:: UGens>FFT, UGens>Convolution
7 Strict convolution with fixed kernel which can be updated using a trigger signal. There is a linear crossfade between the buffers upon change.
9 See emphasis:: Steven W Smith, The Scientist and Engineer's Guide to Digital Signal Processing: chapter 18:: -
10 http://www.dspguide.com/ch18.htm
21 buffer index for the fixed kernel, may be modulated in combination with the trigger
24 update the kernel on a change from <=0 to >0
27 size of FFT frame, must be a power of two. Convolution uses twice this number internally, maximum value you can give this argument is 2^16=65536. Note that it gets progressively more expensive to run for higher powers! 512, 1024, 2048, 4096 standard.
30 The number of periods over which a crossfade is made. The default is 1. This must be an integer.
36 (// allocate three buffers
37 b = Buffer.alloc(s, 2048);
38 c = Buffer.alloc(s, 2048);
39 d = Buffer.alloc(s, 2048);
47 50.do({ |it| c.set(20*it+10, 1.0.rand); });
48 3.do({ |it| b.set(400*it+100, 1); });
49 20.do({ |it| d.set(40*it+20, 1); });
54 SynthDef(\conv_test, { arg kernel, t_trig=0;
59 // must have power of two framesize
60 Out.ar(0, Convolution2L.ar(input, kernel, t_trig, 2048, 1, 0.5));
64 x = Synth(\conv_test, [\kernel, b]);
66 // changing the buffer number:
68 x.set(\t_trig, 1); // after this trigger, the change will take effect.
70 x.set(\t_trig, 1); // after this trigger, the change will take effect.
73 40.do({ |it| d.set(20*it+10, 1); });// changing the buffers' contents
74 x.set(\t_trig, 1); // after this trigger, the change will take effect.
77 x.set(\t_trig, 1); // after this trigger, the change will take effect.
85 SynthDef( \conv_test2, { arg kernel, t_trig=0;
90 // must have power of two framesize
91 Out.ar(0, Convolution2L.ar(input, kernel, t_trig, 2048, 5, 0.5));
95 x = Synth(\conv_test2, [\kernel, b]);
97 // changing the buffer number:
99 x.set(\t_trig, 1); // after this trigger, the change will take effect.
101 x.set(\t_trig, 1); // after this trigger, the change will take effect.
104 40.do({ |it| d.set(20*it+10, 1); });// changing the buffers' contents
105 x.set(\t_trig, 1); // after this trigger, the change will take effect.
108 x.set(\t_trig, 1); // after this trigger, the change will take effect.
116 b = Buffer.read(s, Help.dir +/+ "sounds/a11wlk01.wav");
121 input= SoundIn.ar(0);
123 // must have power of two framesize
124 Convolution2L.ar(input, b, 0, 512, 1, 0.5);
134 // must have power of two framesize- FFT size will be sorted by Convolution2 to be double this
135 // maximum is currently a=8192 for FFT of size 16384
138 g = Buffer.alloc(s, a, 1);
143 100.do({arg i; g.set(a.rand, (i+1).reciprocal)});
147 // random impulse response
150 var input, inputAmp, threshhold, gate;
152 input = SoundIn.ar(0);
153 inputAmp = Amplitude.kr(input);
154 threshhold = 0.02; // noise gating threshold
155 gate = Lag.kr(inputAmp > threshhold, 0.01);
157 Convolution2L.ar(input*gate, g, 0, a, 1, 0.5);
166 b = Buffer.alloc(s, 512, 1);
167 b.sine1(1.0/[1, 2, 3, 4, 5, 6], true, true, true);
175 // must have power of two framesize
176 Convolution2L.ar(input, b, 0, 512, 1, 0.5);