View Single Post
Old 02-03-2015, 12:35 AM   #63
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

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
SaulT is offline   Reply With Quote