supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / Filters / Median.html
blobef78fa6b6d47eeae0e4dd0218216ac3d8ebbe304
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: 12.0px Helvetica; color: #0021e7}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d; min-height: 12.0px}
18 span.s1 {font: 18.0px Helvetica}
19 span.s2 {color: #000000}
20 span.s3 {color: #001bb9}
21 span.s4 {color: #0021e7}
22 span.Apple-tab-span {white-space:pre}
23 </style>
24 </head>
25 <body>
26 <p class="p1"><span class="s1"><b>Median<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>median filter</b></p>
27 <p class="p2"><br></p>
28 <p class="p3"><span class="s2"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s3"><b>Object</b></span></a></span><span class="s3"><b> : </b><a href="../../Core/Kernel/AbstractFunction.html"><span class="s4"><b>AbstractFunction</b></span></a><b> : </b><a href="../UGen.html"><span class="s4"><b>UGen</b></span></a><b> : </b><a href="../Filter.html"><span class="s4"><b>Filter</b></span></a><b><span class="Apple-converted-space"> </span></b></span></p>
29 <p class="p2"><br></p>
30 <p class="p1"><b>Median.ar(length, in, mul, add)</b></p>
31 <p class="p1"><b>Median.kr(length, in, mul, add)</b></p>
32 <p class="p2"><br></p>
33 <p class="p2"><br></p>
34 <p class="p1">Returns the median of the last <b>length</b> input points.<span class="Apple-converted-space"> </span></p>
35 <p class="p1">This non linear filter is good at reducing impulse noise<span class="Apple-converted-space">  </span>from a signal.</p>
36 <p class="p1"><b>length</b> - number of input points in which to find the median. Must be an odd number from 1 to 31.</p>
37 <p class="p1">If length is 1 then Median has no effect.</p>
38 <p class="p1"><b>in</b> - input signal to be processed</p>
39 <p class="p4"><br></p>
40 <p class="p5">// a signal with impulse noise.</p>
41 <p class="p6">{ <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9) }.play;</p>
42 <p class="p7"><br></p>
43 <p class="p5">// after applying median filter</p>
44 <p class="p6">{ <span class="s3">Median</span>.ar(3, <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9)) }.play;</p>
45 <p class="p7"><br></p>
46 <p class="p5">// The median length can be increased for longer duration noise.</p>
47 <p class="p8"><br></p>
48 <p class="p5">// a signal with longer impulse noise.</p>
49 <p class="p6">{ <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">LPZ1</span>.ar(<span class="s3">Dust2</span>.ar(100, 0.9)) }.play;</p>
50 <p class="p7"><br></p>
51 <p class="p5">// length 3 doesn't help here because the impulses are 2 samples long.</p>
52 <p class="p6">{ <span class="s3">Median</span>.ar(3, <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">LPZ1</span>.ar(<span class="s3">Dust2</span>.ar(100, 0.9))) }.play;</p>
53 <p class="p7"><br></p>
54 <p class="p5">// length 5 does better</p>
55 <p class="p6">{ <span class="s3">Median</span>.ar(5, <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">LPZ1</span>.ar(<span class="s3">Dust2</span>.ar(100, 0.9))) }.play;</p>
56 <p class="p7"><br></p>
57 <p class="p5">// long Median filters begin chopping off the peaks of the waveform</p>
58 <p class="p6">(</p>
59 <p class="p6">{<span class="Apple-converted-space"> </span></p>
60 <p class="p6"><span class="Apple-tab-span"> </span>x = <span class="s3">SinOsc</span>.ar(1000, 0, 0.2);</p>
61 <p class="p6"><span class="Apple-tab-span"> </span>[x, <span class="s3">Median</span>.ar(31, x)]</p>
62 <p class="p6">}.play;</p>
63 <p class="p6">)</p>
64 <p class="p7"><br></p>
65 <p class="p5">// another noise reduction application:</p>
66 <p class="p8"><br></p>
67 <p class="p6"><span class="s3">Synth</span>.play({ <span class="s3">WhiteNoise</span>.ar(0.1) + <span class="s3">SinOsc</span>.ar(800,0,0.1) });</p>
68 <p class="p7"><br></p>
69 <p class="p5">// use Median filter for high frequency noise</p>
70 <p class="p6"><span class="s3">Synth</span>.play({ <span class="s3">Median</span>.ar(31, <span class="s3">WhiteNoise</span>.ar(0.1) + <span class="s3">SinOsc</span>.ar(800,0,0.1)) });</p>
71 <p class="p7"><br></p>
72 <p class="p6">(</p>
73 <p class="p5">// use LeakDC for low frequency noise</p>
74 <p class="p6"><span class="s3">Synth</span>.play({<span class="Apple-converted-space"> </span></p>
75 <p class="p6"><span class="Apple-tab-span"> </span><span class="s3">LeakDC</span>.ar(<span class="s3">Median</span>.ar(31, <span class="s3">WhiteNoise</span>.ar(0.1) + <span class="s3">SinOsc</span>.ar(800,0,0.1)), 0.9)</p>
76 <p class="p6">});</p>
77 <p class="p6">)</p>
78 </body>
79 </html>