supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / Triggers / PeakFollower.html
blob05b1c21a317257a1c787da98bfe24eacd506a0fc
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.42">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.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: #a71e12; min-height: 12.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a71e12}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0019b7}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
18 span.s1 {font: 18.0px Helvetica}
19 span.s2 {color: #0000ff}
20 span.s3 {color: #000000}
21 span.s4 {color: #0019b7}
22 span.Apple-tab-span {white-space:pre}
23 </style>
24 </head>
25 <body>
26 <p class="p1"><span class="s1"><b>PeakFollower<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>track peak signal amplitude</b></p>
27 <p class="p2"><br></p>
28 <p class="p3"><b>PeakFollower.ar(in, decay)</b></p>
29 <p class="p2"><br></p>
30 <p class="p3">Outputs the peak amplitude of the signal received at the input.<span class="Apple-converted-space"> </span></p>
31 <p class="p3">if level is below maximum, the level decreases by the factor given in decay.</p>
32 <p class="p2"><br></p>
33 <p class="p3"><b>in</b> - input signal.</p>
34 <p class="p3"><b>decay</b> - decay factor.</p>
35 <p class="p2"><br></p>
36 <p class="p3">Internally, the absolute value of the signal is used, to prevent underreporting the peak value if there is a negative DC offset. To obtain the minimum and maximum values of the signal as is, use the <a href="RunningMin.html"><span class="s2">RunningMin</span></a> and <a href="RunningMax.html"><span class="s2">RunningMax</span></a> UGens.</p>
37 <p class="p2"><br></p>
38 <p class="p4">s.boot;</p>
39 <p class="p5"><br></p>
40 <p class="p6">// no decay</p>
41 <p class="p4">(</p>
42 <p class="p4">{<span class="Apple-converted-space"> </span></p>
43 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span>SinOsc<span class="s3">.ar(</span></p>
44 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">PeakFollower</span>.ar(<span class="s4">Dust</span>.ar(20, <span class="s4">Line</span>.kr(0, 1, 4)), 1.0) * 1500 + 200,<span class="Apple-converted-space"> </span></p>
45 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, 0.2</p>
46 <p class="p4"><span class="Apple-tab-span"> </span>)</p>
47 <p class="p8"><span class="Apple-tab-span"> </span></p>
48 <p class="p4">}.play;</p>
49 <p class="p4">)</p>
50 <p class="p8"><br></p>
51 <p class="p6">// a little decay</p>
52 <p class="p4">(</p>
53 <p class="p4">{<span class="Apple-converted-space"> </span></p>
54 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span>SinOsc<span class="s3">.ar(</span></p>
55 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">PeakFollower</span>.ar(<span class="s4">Dust</span>.ar(20, <span class="s4">Line</span>.kr(0, 1, 4)), 0.999) * 1500 + 200,<span class="Apple-converted-space"> </span></p>
56 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, 0.2</p>
57 <p class="p4"><span class="Apple-tab-span"> </span>)</p>
58 <p class="p8"><span class="Apple-tab-span"> </span></p>
59 <p class="p4">}.play;</p>
60 <p class="p4">)</p>
61 <p class="p8"><br></p>
62 <p class="p6">// mouse x controls decay, center of the</p>
63 <p class="p4">(</p>
64 <p class="p4">{<span class="Apple-converted-space"> </span></p>
65 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">var</span> decay;</p>
66 <p class="p4"><span class="Apple-tab-span"> </span>decay = <span class="s4">MouseX</span>.kr(0.99, 1.00001).min(1.0);</p>
67 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span>SinOsc<span class="s3">.ar(</span></p>
68 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">PeakFollower</span>.ar(<span class="s4">Dust</span>.ar(20), decay) * 1500 + 200,<span class="Apple-converted-space"> </span></p>
69 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, 0.2</p>
70 <p class="p4"><span class="Apple-tab-span"> </span>);</p>
71 <p class="p8"><span class="Apple-tab-span"> </span></p>
72 <p class="p4">}.play;</p>
73 <p class="p4">)</p>
74 <p class="p8"><br></p>
75 <p class="p8"><br></p>
76 <p class="p8"><br></p>
77 <p class="p8"><br></p>
78 <p class="p6">// follow a sine lfo, decay controlled by mouse x</p>
79 <p class="p4">(</p>
80 <p class="p4">{<span class="Apple-converted-space"> </span></p>
81 <p class="p4"><span class="Apple-tab-span"> </span><span class="s4">var</span> decay;</p>
82 <p class="p4"><span class="Apple-tab-span"> </span>decay = <span class="s4">MouseX</span>.kr(0, 1.1).min(1.0);</p>
83 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span>SinOsc<span class="s3">.ar(</span></p>
84 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">PeakFollower</span>.kr(<span class="s4">SinOsc</span>.kr(0.2), decay) * 200 + 500,<span class="Apple-converted-space"> </span></p>
85 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, 0.2</p>
86 <p class="p4"><span class="Apple-tab-span"> </span>)</p>
87 <p class="p8"><span class="Apple-tab-span"> </span></p>
88 <p class="p4">}.play;</p>
89 <p class="p4">)</p>
90 <p class="p8"><br></p>
91 <p class="p8"><br></p>
92 <p class="p8"><br></p>
93 </body>
94 </html>