supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / Analysis / RunningSum.html
blob934afa791dce77d3dc7d322a78156165c6496814
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: 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: #ad140d}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
15 span.s1 {font: 21.0px Helvetica}
16 span.s2 {color: #001bb9}
17 span.Apple-tab-span {white-space:pre}
18 </style>
19 </head>
20 <body>
21 <p class="p1"><span class="s1"><b>RunningSum<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>running sum over n frames</b></p>
22 <p class="p2"><br></p>
23 <p class="p1">A running sum over a user specified number of samples, useful for running RMS power windowing.<span class="Apple-converted-space"> </span></p>
24 <p class="p2"><br></p>
25 <p class="p2"><br></p>
26 <p class="p1"><b>*ar(in, numsamp)</b></p>
27 <p class="p2"><br></p>
28 <p class="p1"><b>in<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Input signal</p>
29 <p class="p1"><b>numsamp</b> <span class="Apple-tab-span"> </span>How many samples to take the running sum over<span class="Apple-converted-space"> </span></p>
30 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(initialisation time only, not modulatable. default: <b>40</b>)</p>
31 <p class="p2"><br></p>
32 <p class="p3"><span class="Apple-tab-span"> </span></p>
33 <p class="p3"><br></p>
34 <p class="p4">// distorts of course - would need scaling<span class="Apple-tab-span"> </span></p>
35 <p class="p5">{ <span class="s2">RunningSum</span>.ar(<span class="s2">SoundIn</span>.ar) }.play<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
36 <p class="p3"><span class="Apple-tab-span"> </span></p>
37 <p class="p4">// Running Average over x samples<span class="Apple-tab-span"> </span></p>
38 <p class="p5">(</p>
39 <p class="p5">{<span class="Apple-converted-space"> </span></p>
40 <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span>var</span> x = 100;</p>
41 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">RunningSum</span>.ar(<span class="s2">LFSaw</span>.ar, x) * (x.reciprocal)</p>
42 <p class="p5"><span class="Apple-converted-space"> </span>}.play</p>
43 <p class="p5">)</p>
44 <p class="p3"><br></p>
45 <p class="p4">// RMS Power</p>
46 <p class="p5">(</p>
47 <p class="p5">{<span class="Apple-converted-space"> </span></p>
48 <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span>var</span> input, numsamp;</p>
49 <p class="p3"><span class="Apple-tab-span"> </span></p>
50 <p class="p5"><span class="Apple-tab-span"> </span>input = <span class="s2">LFSaw</span>.ar;</p>
51 <p class="p5"><span class="Apple-tab-span"> </span>numsamp = 30;</p>
52 <p class="p3"><span class="Apple-tab-span"> </span></p>
53 <p class="p5"><span class="Apple-tab-span"> </span>(<span class="s2">RunningSum</span>.ar(input.squared, numsamp) / numsamp).sqrt</p>
54 <p class="p5">}.play</p>
55 <p class="p5">)</p>
56 <p class="p3"><br></p>
57 <p class="p3"><br></p>
58 <p class="p4">// shortcut in class</p>
59 <p class="p5">{ <span class="s2">RunningSum</span>.rms(<span class="s2">SoundIn</span>.ar) }.play<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
60 <p class="p3"><br></p>
61 <p class="p3"><br></p>
62 <p class="p4">// play around</p>
63 <p class="p5">(</p>
64 <p class="p5">{<span class="Apple-converted-space"> </span></p>
65 <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span>var</span> input, numsamp, power;</p>
66 <p class="p5"><span class="Apple-tab-span"> </span>numsamp = 500;</p>
67 <p class="p5"><span class="Apple-tab-span"> </span>input = <span class="s2">SoundIn</span>.ar;</p>
68 <p class="p5"><span class="Apple-tab-span"> </span>power = <span class="s2">MouseX</span>.kr(0.1, 4);</p>
69 <p class="p3"><br></p>
70 <p class="p5"><span class="Apple-tab-span"> </span>(<span class="s2">RunningSum</span>.ar(input ** power, numsamp)/numsamp) ** (power.reciprocal)</p>
71 <p class="p5">}.play</p>
72 <p class="p5">)</p>
73 <p class="p3"><br></p>
74 <p class="p3"><br></p>
75 </body>
76 </html>