supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / FFT / pvcalc.html
blob59e5d40d6232d00d170b073ae9f276ad162727d3
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
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: 15.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}
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: #a81914}
17 span.s1 {color: #1630ea}
18 span.s2 {color: #000000}
19 span.s3 {color: #1024b0}
20 span.s4 {color: #0910ba}
21 span.s5 {color: #a81914}
22 span.Apple-tab-span {white-space:pre}
23 </style>
24 </head>
25 <body>
26 <p class="p1"><b>pvcalc<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Process the bins of an FFT chain</b></p>
27 <p class="p2"><br></p>
28 <p class="p3"><b><span class="Apple-tab-span"> </span>chain = chain.pvcalc(numframes, func, frombin, tobin, zeroothers)</b></p>
29 <p class="p2"><br></p>
30 <p class="p3">pvcalc applies function <b>func</b> to the frequency-domain data of an FFT chain. <b>func</b> should be a function that takes two arrays as inputs (magnitude, and phase) and returns a resulting pair of arrays [magnitude, phase].</p>
31 <p class="p2"><br></p>
32 <p class="p3"><b>frombin</b>, <b>tobin</b>, and <b>zeroothers</b> are optional arguments which limit the processing to a specified integer range of FFT bins. If <b>zeroothers</b> is set to 1 then bins outside of the range being processed are silenced.</p>
33 <p class="p2"><br></p>
34 <p class="p3">See <a href="pvcollect.html"><span class="s1">pvcollect</span></a> for discussion of efficiency considerations. See also <a href="pvcalc2.html"><span class="s1">pvcalc2</span></a>, <a href="UnpackFFT.html"><span class="s1">UnpackFFT</span></a>.</p>
35 <p class="p2"><br></p>
36 <p class="p2"><br></p>
37 <p class="p3"><b>Examples</b></p>
38 <p class="p2"><br></p>
39 <p class="p4">(</p>
40 <p class="p4">s.boot.doWhenBooted{</p>
41 <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span>c = </span><span class="s3">Buffer</span><span class="s2">.read(s,</span>"sounds/a11wlk01.wav"<span class="s2">);</span></p>
42 <p class="p4">}</p>
43 <p class="p4">)</p>
44 <p class="p6"><br></p>
45 <p class="p4">(</p>
46 <p class="p4">x = {</p>
47 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">var</span> in, chain, v;</p>
48 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s4">PlayBuf</span>.ar(1, c, <span class="s4">BufRateScale</span>.kr(c), loop: 1);</p>
49 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s4">FFT</span>(<span class="s4">LocalBuf</span>(1024), in);</p>
50 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
51 <p class="p4"><span class="Apple-tab-span"> </span>chain = chain.pvcalc(1024, {<span class="s4">|mags, phases|</span></p>
52 <p class="p7">//////// Try uncommenting each of these lines in turn and re-running the synth:</p>
53 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[mags * {1.5.rand}.dup(mags.size), phases + {pi.rand}.dup(phases.size)]; <span class="s5">// Arbitrary filter, arbitrary phase shift</span></p>
54 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//[mags.reverse, phases.reverse]; // Upside-down!</p>
55 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//[mags.differentiate, phases.differentiate]; // Differentiate along frequency axis</p>
56 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//[mags[30..] ++ mags[..30], phases[30..] ++ phases[..30]]; // ".rotate" doesn't work directly, but this is equivalent</p>
57 <p class="p4"><span class="Apple-tab-span"> </span>}, frombin: 0, tobin: 250, zeroothers: 0);</p>
58 <p class="p6"><span class="Apple-tab-span"> </span></p>
59 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">Out</span>.ar(0, 0.5 * <span class="s4">IFFT</span>(chain).dup);</p>
60 <p class="p4">}.play(s);</p>
61 <p class="p4">)</p>
62 <p class="p4">x.free;</p>
63 </body>
64 </html>