1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"1038.29">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
16 span
.s1
{font: 18.0px Helvetica
}
17 span
.s2
{color: #003dea}
18 span
.s3
{text-decoration: underline
}
19 span
.s4
{text-decoration: underline
; color: #0040d6}
20 span
.s5
{color: #000000}
21 span
.s6
{color: #001bb9}
22 span
.s7
{color: #0000bf}
23 span
.s8
{color: #007300}
24 span
.s9
{color: #2c7014}
25 span
.Apple-tab-span
{white-space:pre
}
29 <p class=
"p1"><span class=
"s1"><b>StereoConvolution2L
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>stereo real-time convolver with linear interpolation
</b></p>
31 <p class=
"p1"><b>StereoConvolution2L.ar(in, kernelL, kernelR, trigger, framesize, crossfade, mul, add)
</b></p>
32 <p class=
"p2"><br></p>
33 <p class=
"p1">Strict convolution with fixed kernel which can be updated using a trigger signal. There is a linear crossfade between the buffers upon change.
</p>
34 <p class=
"p1">Like
<a href=
"Convolution2L.html"><span class=
"s2">Convolution2L
</span></a>, but convolves with two buffers and outputs a stereo signal. This saves one FFT transformation per period, as compared to using two copies of
<b>Convolution2L
</b>.
</p>
35 <p class=
"p1">Useful applications could include stereo reverberation or HRTF convolution.
</p>
36 <p class=
"p3"><br></p>
37 <p class=
"p1">See Steven W Smith, The Scientist and Engineer's Guide to Digital Signal Processing:
<span class=
"Apple-converted-space"> </span></p>
38 <p class=
"p1">chapter
18:
<span class=
"Apple-converted-space"> </span><span class=
"s3"> http:// www.dspguide.com/ch18.htm
</span><span class=
"Apple-converted-space"> </span></p>
39 <p class=
"p3"><br></p>
40 <p class=
"p1"><b>in
</b> - processing target
</p>
41 <p class=
"p1"><b>kernelL
</b> - buffer index for the fixed kernel of the left channel, may be modulated in combination with the trigger
</p>
42 <p class=
"p1"><b>kernelR
</b>- buffer index for the fixed kernel of the right channel, may be modulated in combination with the trigger
</p>
43 <p class=
"p1"><b>trigger
</b> - update the kernel on a change from
<=
0 to
>0</p>
44 <p class=
"p1"><b>framesize
</b>- 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.
</p>
45 <p class=
"p1"><b>crossfade
</b> - The number of periods over which a crossfade is made. The default is
1. This must be an integer.
</p>
46 <p class=
"p3"><br></p>
47 <p class=
"p1">See also
<a href=
"Convolution2.html"><span class=
"s4">Convolution2
</span></a> and
<a href=
"Convolution2L.html"><span class=
"s2">Convolution2L
</span></a>.
</p>
48 <p class=
"p2"><br></p>
49 <p class=
"p2"><br></p>
50 <p class=
"p2"><br></p>
51 <p class=
"p4"><span class=
"s5">(
</span>//allocate three buffers
</p>
52 <p class=
"p5">b =
<span class=
"s6">Buffer
</span>.alloc(s,
2048);
</p>
53 <p class=
"p5">c =
<span class=
"s6">Buffer
</span>.alloc(s,
2048);
</p>
54 <p class=
"p5">d =
<span class=
"s6">Buffer
</span>.alloc(s,
2048);
</p>
55 <p class=
"p2"><br></p>
56 <p class=
"p5">b.zero;
</p>
57 <p class=
"p5">c.zero;
</p>
58 <p class=
"p5">d.zero;
</p>
60 <p class=
"p2"><br></p>
62 <p class=
"p5">50.do({
<span class=
"s6">|it|
</span> c.set(
20*it+
10,
1.0.rand); });
</p>
63 <p class=
"p5">3.do({
<span class=
"s6">|it|
</span> b.set(
400*it+
100,
1); });
</p>
64 <p class=
"p5">20.do({
<span class=
"s6">|it|
</span> d.set(
40*it+
20,
1); });
</p>
66 <p class=
"p2"><br></p>
67 <p class=
"p2"><br></p>
69 <p class=
"p5"><span class=
"s7">SynthDef
</span>(
<span class=
"s8">\conv_test
</span>, {
<span class=
"s7">arg
</span> kernel1, kernel2, t_trig=
0;
</p>
70 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> input;
</p>
71 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span>input=
<span class=
"s7">Impulse
</span>.ar(
1);
</p>
73 <p class=
"p2"><br></p>
74 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>//must have power of two framesize
</p>
75 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s7">Out
</span>.ar(
0,
<span class=
"s7">StereoConvolution2L
</span>.ar(input,kernel1, kernel2,t_trig,
2048,
1,
0.5));
</p>
76 <p class=
"p5">}).add
</p>
77 <p class=
"p2"><br></p>
79 <p class=
"p2"><br></p>
80 <p class=
"p2"><br></p>
81 <p class=
"p5">x =
<span class=
"s6">Synth
</span>(
<span class=
"s8">\conv_test
</span>, [
<span class=
"s9">\kernel1
</span>,b,
<span class=
"s9">\kernel2
</span>,c]);
</p>
82 <p class=
"p2"><br></p>
83 <p class=
"p4">// changing the buffer number:
</p>
84 <p class=
"p5">x.set(
<span class=
"s9">\kernel1
</span>,d);
</p>
85 <p class=
"p4"><span class=
"s5">x.set(
</span><span class=
"s9">\t_trig
</span><span class=
"s5">,
1);
</span>// after this trigger, the change will take effect.
</p>
86 <p class=
"p5">x.set(
<span class=
"s9">\kernel2
</span>,d);
</p>
87 <p class=
"p4"><span class=
"s5">x.set(
</span><span class=
"s9">\t_trig
</span><span class=
"s5">,
1);
</span>// after this trigger, the change will take effect.
</p>
88 <p class=
"p2"><br></p>
89 <p class=
"p5">d.zero;
</p>
90 <p class=
"p4"><span class=
"s5">40.do({
</span><span class=
"s6">|it|
</span><span class=
"s5"> d.set(
20*it+
10,
1); });
</span>// changing the buffers' contents
</p>
91 <p class=
"p4"><span class=
"s5">x.set(
</span><span class=
"s9">\t_trig
</span><span class=
"s5">,
1);
</span>// after this trigger, the change will take effect.
</p>
92 <p class=
"p2"><br></p>
93 <p class=
"p5">x.set(
<span class=
"s9">\kernel1
</span>,b);
</p>
94 <p class=
"p4"><span class=
"s5">x.set(
</span><span class=
"s9">\t_trig
</span><span class=
"s5">,
1);
</span>// after this trigger, the change will take effect.
</p>
95 <p class=
"p2"><br></p>
96 <p class=
"p5">x.free;
</p>