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=
"949.43">
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: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000bf}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
17 span
.s1
{font: 18.0px Helvetica
}
18 span
.s2
{color: #000000}
19 span
.s3
{color: #0000bf}
20 span
.s4
{color: #0000bf}
21 span
.s5
{color: #0000bf}
22 span
.s6
{text-decoration: underline
}
23 span
.s7
{color: #0000bf}
24 span
.s8
{color: #007300}
25 span
.s9
{color: #bf0000}
26 span
.Apple-tab-span
{white-space:pre
}
30 <p class=
"p1"><span class=
"s1"><b>PV_Copy
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>copy an FFT buffer
</b></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3"><span class=
"s2"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><b>Object
</b></a></span><span class=
"s3"><b> :
</b><a href=
"../../Core/Kernel/AbstractFunction.html"><span class=
"s4"><b>AbstractFunction
</b></span></a><b> :
</b><a href=
"../UGen.html"><span class=
"s4"><b>UGen
</b></span></a><b> :
</b><a href=
"../PV_ChainUGen.html"><span class=
"s4"><b>PV_ChainUGen
</b></span></a><b> :
</b><a href=
"PV_MagMul.html"><span class=
"s5"><b>PV_MagMul
</b></span></a></span></p>
33 <p class=
"p2"><br></p>
34 <p class=
"p2"><br></p>
35 <p class=
"p1"><b>PV_Copy(bufferA,
<span class=
"Apple-converted-space"> </span>bufferB)
</b></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p1">Copies the spectral frame in bufferA to bufferB at that point in the chain of PV UGens. This allows for parallel processing of spectral data without the need for multiple FFT UGens, and to copy out data at that point in the chain for other purposes. bufferA and bufferB must be the same size.
</p>
38 <p class=
"p1"><b>bufferA
</b> - source buffer.
</p>
39 <p class=
"p1"><b>bufferB
</b> - destination buffer.
</p>
40 <p class=
"p2"><br></p>
41 <p class=
"p3"><span class=
"s2">See also
<a href=
"FFT Overview.html"><span class=
"s6">FFT Overview
</span></a>.
</span></p>
42 <p class=
"p2"><br></p>
44 <p class=
"p4">s.waitForBoot {
</p>
45 <p class=
"p5"><span class=
"s2"><span class=
"Apple-tab-span"> </span>d =
</span><span class=
"s7">Buffer
</span><span class=
"s2">.read(s,
</span>"sounds/a11wlk01.wav"<span class=
"s2">);
</span></p>
48 <p class=
"p6"><br></p>
49 <p class=
"p6"><br></p>
50 <p class=
"p7">//// crossfade between original and magmul-ed whitenoise
</p>
52 <p class=
"p4">x = {
<span class=
"s7">var
</span> in, in2, chain, chainB, chainC;
</p>
53 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in =
<span class=
"s7">PlayBuf
</span>.ar(
1, d,
<span class=
"s7">BufRateScale
</span>.kr(d), loop:
1) *
2;
</p>
54 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in2 =
<span class=
"s7">WhiteNoise
</span>.ar;
</p>
55 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">FFT
</span>(
<span class=
"s7">LocalBuf
</span>(
2048), in);
</p>
56 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">FFT
</span>(
<span class=
"s7">LocalBuf
</span>(
2048), in2);
</p>
57 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainC =
<span class=
"s7">PV_Copy
</span>(chain,
<span class=
"s7">LocalBuf
</span>(
2048));
</p>
58 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">PV_MagMul
</span>(chainB, chainC);
</p>
59 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">XFade2
</span>.ar(
<span class=
"s7">IFFT
</span>(chain),
<span class=
"s7">IFFT
</span>(chainB) *
0.1,
<span class=
"s7">SinOsc
</span>.kr(
0.1,
1.5pi));
</p>
60 <p class=
"p4">}.play(s);
</p>
62 <p class=
"p4">x.free;
</p>
63 <p class=
"p6"><br></p>
64 <p class=
"p6"><br></p>
65 <p class=
"p6"><br></p>
66 <p class=
"p6"><br></p>
67 <p class=
"p7">//// as previous but with Blip for 'vocoder' cross synthesis effect
</p>
69 <p class=
"p4">x = {
<span class=
"s7">var
</span> in, in2, chain, chainB, chainC;
</p>
70 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in =
<span class=
"s7">PlayBuf
</span>.ar(
1, d,
<span class=
"s7">BufRateScale
</span>.kr(d), loop:
1) *
2;
</p>
71 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in2 =
<span class=
"s7">Blip
</span>.ar(
100,
50);
</p>
72 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">FFT
</span>(
<span class=
"s7">LocalBuf
</span>(
2048), in);
</p>
73 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">FFT
</span>(
<span class=
"s7">LocalBuf
</span>(
2048), in2);
</p>
74 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainC =
<span class=
"s7">PV_Copy
</span>(chain,
<span class=
"s7">LocalBuf
</span>(
2048));
</p>
75 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">PV_MagMul
</span>(chainB, chainC);
</p>
76 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">XFade2
</span>.ar(
<span class=
"s7">IFFT
</span>(chain),
<span class=
"s7">IFFT
</span>(chainB) *
0.1,
<span class=
"s7">SinOsc
</span>.ar(
0.1));
</p>
77 <p class=
"p4">}.play(s);
</p>
79 <p class=
"p4">x.free;
</p>
80 <p class=
"p6"><br></p>
81 <p class=
"p6"><br></p>
82 <p class=
"p7">//// Spectral 'pan'
</p>
84 <p class=
"p4">x = {
<span class=
"s7">var
</span> in, chain, chainB, pan;
</p>
85 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in =
<span class=
"s7">PlayBuf
</span>.ar(
1, d,
<span class=
"s7">BufRateScale
</span>.kr(d), loop:
1);
</p>
86 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">FFT
</span>(
<span class=
"s7">LocalBuf
</span>(
2048), in);
</p>
87 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">PV_Copy
</span>(chain,
<span class=
"s7">LocalBuf
</span>(
2048));
</p>
88 <p class=
"p4"><span class=
"Apple-tab-span"> </span>pan =
<span class=
"s7">MouseX
</span>.kr(
0.001,
1.001,
<span class=
"s8">'exponential'
</span>) -
0.001;
</p>
89 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">PV_BrickWall
</span>(chain, pan);
<span class=
"Apple-converted-space"> </span></p>
90 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">PV_BrickWall
</span>(chainB, -
1 + pan);
<span class=
"Apple-converted-space"> </span></p>
91 <p class=
"p4"><span class=
"Apple-tab-span"> </span>0.5 *
<span class=
"s7">IFFT
</span>([chain, chainB]);
</p>
92 <p class=
"p4">}.play(s);
</p>
94 <p class=
"p4">x.free;
</p>
95 <p class=
"p6"><br></p>
96 <p class=
"p6"><br></p>
98 <p class=
"p4">s.waitForBoot {
</p>
99 <p class=
"p4"><span class=
"Apple-tab-span"> </span>b =
<span class=
"s7">Buffer
</span>.alloc(s,
2048,
1);
</p>
100 <p class=
"p4"><span class=
"Apple-tab-span"> </span>c =
<span class=
"s7">Buffer
</span>.alloc(s,
2048,
1);
</p>
101 <p class=
"p5"><span class=
"s2"><span class=
"Apple-tab-span"> </span>d =
</span><span class=
"s7">Buffer
</span><span class=
"s2">.read(s,
</span>"sounds/a11wlk01.wav"<span class=
"s2">);
</span></p>
102 <p class=
"p4"><span class=
"Apple-tab-span"> </span>e =
<span class=
"s7">Buffer
</span>.alloc(s,
2048,
1);
</p>
103 <p class=
"p4"><span class=
"Apple-tab-span"> </span>f =
<span class=
"s7">Buffer
</span>.alloc(s,
2048,
1);
</p>
106 <p class=
"p6"><br></p>
107 <p class=
"p6"><br></p>
108 <p class=
"p7">//// proof of concept
</p>
110 <p class=
"p4">x = {
<span class=
"s7">var
</span> inA, chainA, inB, chainB, chain;
</p>
111 <p class=
"p4"><span class=
"Apple-tab-span"> </span>inA =
<span class=
"s7">LFClipNoise
</span>.ar(
100);
</p>
112 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainA =
<span class=
"s7">FFT
</span>(b, inA);
</p>
113 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s7">PV_Copy
</span>(chainA, c);
<span class=
"Apple-converted-space"> </span></p>
114 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s7">IFFT
</span><span class=
"s2">(chainA) -
</span><span class=
"s7">IFFT
</span><span class=
"s2">(chainB);
</span>// cancels to zero so silent!
</p>
115 <p class=
"p4">}.play(s);
</p>
117 <p class=
"p4">x.free;
</p>
118 <p class=
"p7">// IFFTed frames contain the same windowed output data
</p>
119 <p class=
"p4">b.plot(
<span class=
"s8">\b
</span>,
<span class=
"s7">Rect
</span>(
200,
430,
700,
300)); c.plot(
<span class=
"s8">\c
</span>,
<span class=
"s7">Rect
</span>(
200,
100,
700,
300));
</p>
120 <p class=
"p6"><br></p>
121 <p class=
"p6"><br></p>
122 <p class=
"p6"><br></p>
123 <p class=
"p7">//// Multiple Magnitude plots
</p>
125 <p class=
"p4">x = {
<span class=
"s7">var
</span> in, chain, chainB, chainC;
</p>
126 <p class=
"p4"><span class=
"Apple-tab-span"> </span>in =
<span class=
"s7">WhiteNoise
</span>.ar;
</p>
127 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">FFT
</span>(b, in);
</p>
128 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s7">PV_Copy
</span><span class=
"s2">(chain,
</span><span class=
"s7">LocalBuf
</span><span class=
"s2">(
2048));
</span>// initial spectrum
</p>
129 <p class=
"p4"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s7">PV_RectComb
</span>(chain,
20,
0,
0.2);
</p>
130 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">PV_Copy
</span>(chain,
<span class=
"s7">LocalBuf
</span>(
2048));
<span class=
"s9">// after comb
</span></p>
131 <p class=
"p4"><span class=
"Apple-tab-span"> </span>2.do({chain =
<span class=
"s7">PV_MagSquared
</span>(chain)});
<span class=
"Apple-converted-space"> </span></p>
132 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s7">PV_Copy
</span><span class=
"s2">(chain,
</span><span class=
"s7">LocalBuf
</span><span class=
"s2">(
2048));
</span>// after magsquared
</p>
133 <p class=
"p4"><span class=
"Apple-tab-span"> </span>0.00001 *
<span class=
"s7">Pan2
</span>.ar(
<span class=
"s7">IFFT
</span>(chain));
</p>
134 <p class=
"p4">}.play(s);
</p>
136 <p class=
"p4">x.free;
</p>
137 <p class=
"p6"><br></p>
139 <p class=
"p4">c.getToFloatArray(action: {
<span class=
"s7">arg
</span> array;
</p>
140 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> z, x;
</p>
141 <p class=
"p4"><span class=
"Apple-tab-span"> </span>z = array.clump(
2).flop;
</p>
142 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// Initially data is in complex form
</p>
143 <p class=
"p4"><span class=
"Apple-tab-span"> </span>z = [
<span class=
"s7">Signal
</span>.newFrom(z[
0]),
<span class=
"s7">Signal
</span>.newFrom(z[
1])];
</p>
144 <p class=
"p4"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s7">Complex
</span>(z[
0], z[
1]);
</p>
145 <p class=
"p4"><span class=
"Apple-tab-span"> </span>{x.magnitude.plot(
<span class=
"s8">'Initial'
</span>,
<span class=
"s7">Rect
</span>(
200,
560,
700,
200))}.defer
</p>
146 <p class=
"p4">});
</p>
147 <p class=
"p4">e.getToFloatArray(action: {
<span class=
"s7">arg
</span> array;
</p>
148 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> z, x;
</p>
149 <p class=
"p4"><span class=
"Apple-tab-span"> </span>z = array.clump(
2).flop;
</p>
150 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// RectComb doesn't convert, so it's still complex
</p>
151 <p class=
"p4"><span class=
"Apple-tab-span"> </span>z = [
<span class=
"s7">Signal
</span>.newFrom(z[
0]),
<span class=
"s7">Signal
</span>.newFrom(z[
1])];
</p>
152 <p class=
"p4"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s7">Complex
</span>(z[
0], z[
1]);
</p>
153 <p class=
"p4"><span class=
"Apple-tab-span"> </span>{x.magnitude.plot(
<span class=
"s8">'After RectComb'
</span>,
<span class=
"s7">Rect
</span>(
200,
330,
700,
200))}.defer
</p>
154 <p class=
"p4">});
</p>
155 <p class=
"p4">f.getToFloatArray(action: {
<span class=
"s7">arg
</span> array;
</p>
156 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> z, x;
</p>
157 <p class=
"p4"><span class=
"Apple-tab-span"> </span>z = array.clump(
2).flop;
</p>
158 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// MagSquared converts to Polar
</p>
159 <p class=
"p4"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s7">Signal
</span>.newFrom(z[
0]);
<span class=
"s9">// magnitude first
</span></p>
160 <p class=
"p4"><span class=
"Apple-tab-span"> </span>{x.plot(
<span class=
"s8">'After MagSquared'
</span>,
<span class=
"s7">Rect
</span>(
200,
100,
700,
200))}.defer
</p>
163 <p class=
"p6"><br></p>
164 <p class=
"p4">[b, c, d, e, f].do(
<span class=
"s7">_
</span>.free);
<span class=
"s9">// free the buffers
</span></p>