I remembered the parameter smoothing, forgot to put RMS in. This is one way to go about it.
Code:
function RMS_set(ms)
instance(coeff, icoeff)
(
coeff = exp(-1/(ms / 1000 * srate));
icoeff = 1-coeff;
);
function RMS(input)
instance(rms_s, coeff, icoeff)
(
rms_s = (rms_s * this.coeff) + (icoeff * input * input);
sqrt(rms_s);
);
usage
Code:
@init
rms0.RMS_set(100); // set rms0 as a 100 ms RMS
@sample
s0 = rms0.RMS(spl0); // s0 now contains the 100 ms RMS of spl0