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.
in |
the signal to analyse. Can be audio rate or control rate. |
numsamps |
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. |
gate |
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 |
mul | |
add |
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.