supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / FFT / Unpack1FFT.html
blob5825051f0f30a780b087ffba28cd2c2d4fde6fe3
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.35">
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: 9.0px Monaco; min-height: 12.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
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; color: #000000; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0029b1; min-height: 14.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0021e7}
19 span.s1 {font: 15.0px Helvetica}
20 span.s2 {color: #002bf0}
21 span.s3 {color: #000000}
22 span.s4 {color: #0000bf}
23 span.s5 {color: #606060}
24 span.s6 {font: 12.0px Helvetica; color: #0021e7}
25 span.Apple-tab-span {white-space:pre}
26 </style>
27 </head>
28 <body>
29 <p class="p1"><span class="s1"><b>Unpack1FFT<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>Unpack a single value (magnitude or phase) from an FFT chain</b></p>
30 <p class="p2"><br></p>
31 <p class="p1"><b>Unpack1FFT(chain, bufsize, binindex, whichmeasure=0)</b></p>
32 <p class="p2"><br></p>
33 <p class="p1">Takes an <a href="FFT.html"><span class="s2">FFT</span></a> chain and extracts a single scalar value as a demand-rate stream. To call it you need a "demander" which fires whenever the FFT chain fires - this is normally achieved using <a href="PackFFT.html"><span class="s2">PackFFT</span></a> but can also be done using <a href="../Synth control/Demand Rate/Demand.html"><span class="s2">Demand</span></a>. <b>chain</b> is an FFT chain, <b>bufsize</b> is the size of the expected input FFT frames, <b>binindex</b> is the integer index of the bin you want to query, and <b>whichmeasure</b> is 0 for magnitude and 1 for phase. None of these arguments can be modulated.</p>
34 <p class="p2"><br></p>
35 <p class="p1"><b><i>Note:</i></b> The main purpose of this UGen is as a component in <a href="pvcollect.html"><span class="s2">pvcollect</span></a>, <a href="pvcalc.html"><span class="s2">pvcalc</span></a>, and <a href="pvcalc2.html"><span class="s2">pvcalc2</span></a> processes. You're welcome to use it on its own - the example below shows basic usage. But most people won't typically need to use it directly.</p>
36 <p class="p3"><br></p>
37 <p class="p4">(</p>
38 <p class="p4">s.boot.doWhenBooted{</p>
39 <p class="p5"><span class="s3"><span class="Apple-tab-span"> </span>c = </span><span class="s4">Buffer</span><span class="s3">.read(s,</span>"sounds/a11wlk01.wav"<span class="s3">);</span></p>
40 <p class="p4">}</p>
41 <p class="p4">)</p>
42 <p class="p6"><br></p>
43 <p class="p7">// Let's extract the DC component - i.e. the magnitude at index zero.</p>
44 <p class="p4">(</p>
45 <p class="p4">x = {</p>
46 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">var</span> fftsize = 1024;</p>
47 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">var</span> sig, chain, unp;</p>
48 <p class="p4"><span class="Apple-tab-span"> </span>sig = <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>(fftsize), sig);</p>
50 <p class="p6"><span class="Apple-tab-span"> </span></p>
51 <p class="p4"><span class="Apple-tab-span"> </span>unp = <span class="s4">Unpack1FFT</span>(chain, b.numFrames, 0, 0);</p>
52 <p class="p6"><span class="Apple-tab-span"> </span></p>
53 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span>// Demand some data from the unpacker</p>
54 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">Demand</span>.kr(chain&gt;=0, 0, unp).poll(chain&gt;=0, <span class="s5">"unpacked value"</span>);</p>
55 <p class="p6"><br></p>
56 <p class="p4"><span class="Apple-tab-span"> </span>(sig*0.1).dup;</p>
57 <p class="p4">}.play(s);</p>
58 <p class="p4">)</p>
59 <p class="p4">x.free;</p>
60 <p class="p8"><br></p>
61 <p class="p2"><br></p>
62 <p class="p9"><span class="s3">See also: <a href="UnpackFFT.html"><span class="s6">UnpackFFT</span></a>, <a href="PackFFT.html"><span class="s6">PackFFT</span></a>, <a href="pvcollect.html"><span class="s6">pvcollect</span></a>, <a href="pvcalc.html"><span class="s6">pvcalc</span></a>, <a href="pvcalc2.html"><span class="s6">pvcalc2</span></a></span></p>
63 </body>
64 </html>