supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / FFT / FFTTrigger.html
blob1ce7647ca929d39379d82ab86f2917b45746aa62
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="824.44">
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; color: #000000}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
14 span.s1 {font: 15.0px Helvetica}
15 span.s2 {color: #0000bf}
16 span.s3 {color: #000000}
17 span.Apple-tab-span {white-space:pre}
18 </style>
19 </head>
20 <body>
21 <p class="p1"><span class="s1"><b>FFTTrigger<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>Outputs the necessary signal for FFT chains, without doing an FFT on a signal</b></p>
22 <p class="p2"><br></p>
23 <p class="p1"><b>FFTrigger(buffer, hop, polar)</b></p>
24 <p class="p2"><br></p>
25 <p class="p1"><span class="Apple-tab-span"> </span>buffer - a buffer to condition for FFT use</p>
26 <p class="p1"><span class="Apple-tab-span"> </span>hop - the hop size for timing triggers (defaults to 0.5)</p>
27 <p class="p1"><span class="Apple-tab-span"> </span>polar - a flag. If 0.0, the buffer will be prepared for complex data, if &gt; 0.0, polar data is set up.</p>
28 <p class="p2"><span class="Apple-tab-span"> </span></p>
29 <p class="p3">(</p>
30 <p class="p3">s.boot.doWhenBooted{</p>
31 <p class="p3"><span class="Apple-tab-span"> </span>b = <span class="s2">Buffer</span>.alloc(s, 512);</p>
32 <p class="p3">};</p>
33 <p class="p3">)</p>
34 <p class="p4">// Reminder: This isn't the intended typical usage! It's OK to do this though.</p>
35 <p class="p3">(</p>
36 <p class="p3">x = {</p>
37 <p class="p3"><span class="Apple-tab-span"> </span><span class="s2">var</span> mags, phases, chain, sig;</p>
38 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span></span>// Create simple undulating magnitudes</p>
39 <p class="p3"><span class="Apple-tab-span"> </span>mags = {<span class="s2">FSinOsc</span>.kr(<span class="s2">ExpRand</span>(0.1, 1)).range(0, 1)}.dup(100);</p>
40 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span></span>// Then give them a "rolloff" to make the sound less unpleasant</p>
41 <p class="p3"><span class="Apple-tab-span"> </span>mags = mags<span class="Apple-converted-space">  </span>* ((1, 0.99 .. 0.01).squared);</p>
42 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span></span>// Let's turn the bins on and off at different rates, I'm *sure* that'll sound interesting</p>
43 <p class="p3"><span class="Apple-tab-span"> </span>mags = mags * {<span class="s2">LFPulse</span>.kr(2 ** <span class="s2">IRand</span>(-3, 5)).range(0, 1)}.dup(100);</p>
44 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span></span>// Let's ignore phase for now</p>
45 <p class="p3"><span class="Apple-tab-span"> </span>phases = 0.dup(100);</p>
46 <p class="p3"><span class="Apple-tab-span"> </span>chain = <span class="s2">FFTTrigger</span>(b, 0.5);</p>
47 <p class="p4"><span class="s3"><span class="Apple-tab-span"> </span></span>// Now we can do the packing</p>
48 <p class="p3"><span class="Apple-tab-span"> </span>chain = <span class="s2">PackFFT</span>(chain, 512, [mags, phases].flop.flatten, 0, 99, 1);</p>
49 <p class="p3"><span class="Apple-tab-span"> </span>sig = <span class="s2">IFFT</span>(chain);</p>
50 <p class="p3"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(0, sig.dup);</p>
51 <p class="p3">}.play(s);</p>
52 <p class="p3">)</p>
53 <p class="p3">x.free;</p>
54 <p class="p3">b.free;</p>
55 </body>
56 </html>