| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 
 | class:: PeakFollower
summary:: Track peak signal amplitude.
related:: Classes/Peak
categories::  UGens>Analysis>Amplitude
Description::
Outputs the peak amplitude of the signal received at the input. If level
is below maximum, the level decreases by the factor given in
code::decay:: .
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
link::Classes/RunningMin::  and  link::Classes/RunningMax::  UGens.
classmethods::
method::ar, kr
argument::in
The input signal.
argument::decay
Decay factor.
Examples::
code::
s.boot;
// no decay
(
{
	SinOsc.ar(
			PeakFollower.ar(Dust.ar(20, Line.kr(0, 1, 4)), 1.0) * 1500 + 200,
			0, 0.2
	)
}.play;
)
// a little decay
(
{
	SinOsc.ar(
			PeakFollower.ar(Dust.ar(20, Line.kr(0, 1, 4)), 0.999) * 1500 + 200,
			0, 0.2
	)
}.play;
)
// mouse x controls decay, center of the
(
{
	var decay;
	decay = MouseX.kr(0.99, 1.00001).min(1.0);
	SinOsc.ar(
			PeakFollower.ar(Dust.ar(20), decay) * 1500 + 200,
			0, 0.2
	);
}.play;
)
// follow a sine lfo, decay controlled by mouse x
(
{
	var decay;
	decay = MouseX.kr(0, 1.1).min(1.0);
	SinOsc.ar(
			PeakFollower.kr(SinOsc.kr(0.2), decay) * 200 + 500,
			0, 0.2
	)
}.play;
)
::
 |