SuperCollider CLASSES (extension)


Measure the temporal crest factor of a signal
Inherits from: UGen : AbstractFunction : Object


This UGen measures the "crest factor" of a time-domain signal (not to be confused with FFTCrest which does the same thing for spectral data). The "crest factor" is the ratio of the absolute peak to the absolute mean over a certain time period. In pseudocode:

crest = (samples.abs.max) / (samples.abs.mean)

For Pulse waves the value will be 1 - because the mean and the maximum are the same. For SinOsc the theoretical value is 2.sqrt. For Saw it is 3.sqrt. These exact values might not occur in practice, because of anti-aliasing and other sampling factors.

Class Methods

*kr (in, numsamps: 400, gate: 1, mul: 1, add: 0)



the signal to analyse. Can be audio rate or control rate.


the number of samples over which to take the measurement. A buffer of this size is created internally (so be careful about specifying a massive number here). This value cannot be modulated.


normally the statistic is calculated on every control block cycle. If you want it less often (eg to reduce CPU usage) you can modulate this - calculation only occurs if gate>0



crest factor, measured on a linear scale. Sometimes it is required in dB values, for which you can simply use ampdb to convert the data. You may also wish to add a slight lag to the values you produce, if your window is short and/or your signal includes strong low frequencies, because the phase of the signal may affect the result.

Inherited class methods

Instance Methods

Inherited instance methods


// Move the mouse. This varies from sinewave (left) to almost-square (right)
var sig = (, 1000, 1)) *,10)).clip2(1);
var val =, 440).poll;
(sig * 0.1).dup

// Or as a plot (which shows the odd results you get over the first few samples):
var sig = (, pi.rand) *,10, 5)).clip2(1);
var val =, 440).poll;, sig * 0.1.dup);;
}.plot(5, minval:1, maxval: 4)