QcPenPrinter: no need to allocate QPrintDialog on heap
[supercollider.git] / HelpSource / Classes / PeakFollower.schelp
blob5adb37b6b0286d7138606fffd6636d33fd78c2a1
1 class:: PeakFollower
2 summary:: Track peak signal amplitude.
3 related:: Classes/Peak
4 categories::  UGens>Analysis>Amplitude
7 Description::
9 Outputs the peak amplitude of the signal received at the input. If level
10 is below maximum, the level decreases by the factor given in
11 code::decay:: .
14 Internally, the absolute value of the signal is used, to prevent
15 underreporting the peak value if there is a negative DC offset. To obtain
16 the minimum and maximum values of the signal as is, use the
17 link::Classes/RunningMin::  and  link::Classes/RunningMax::  UGens.
20 classmethods::
22 method::ar, kr
24 argument::in
26 The input signal.
29 argument::decay
31 Decay factor.
34 Examples::
36 code::
38 s.boot;
40 // no decay
43         SinOsc.ar(
44                         PeakFollower.ar(Dust.ar(20, Line.kr(0, 1, 4)), 1.0) * 1500 + 200,
45                         0, 0.2
46         )
48 }.play;
51 // a little decay
54         SinOsc.ar(
55                         PeakFollower.ar(Dust.ar(20, Line.kr(0, 1, 4)), 0.999) * 1500 + 200,
56                         0, 0.2
57         )
59 }.play;
62 // mouse x controls decay, center of the
65         var decay;
66         decay = MouseX.kr(0.99, 1.00001).min(1.0);
67         SinOsc.ar(
68                         PeakFollower.ar(Dust.ar(20), decay) * 1500 + 200,
69                         0, 0.2
70         );
72 }.play;
78 // follow a sine lfo, decay controlled by mouse x
81         var decay;
82         decay = MouseX.kr(0, 1.1).min(1.0);
83         SinOsc.ar(
84                         PeakFollower.kr(SinOsc.kr(0.2), decay) * 200 + 500,
85                         0, 0.2
86         )
88 }.play;