Refactoring in faustexp.ml.
[Faustine.git] / interpretor / faust-0.9.47mr3 / tests / mathdoc / rms.dsp
1 declare name "rms";
2 declare version "1.0";
3 declare author "Grame";
4 declare license "BSD";
5 declare copyright "(c)GRAME 2009";
6
7
8 // Root Mean Square of n consecutive samples
9 RMS(n) = square : mean(n) : sqrt ;
10
11 // the square of a signal
12 square(x) = x * x ;
13
14 // the mean of n consecutive samples of a signal
15 // uses fixpoint to avoid the accumulation of
16 // rounding errors
17 mean(n) = float2fix : integrate(n) : fix2float : /(n);
18
19 // the sliding sum of n consecutive samples of a signal
20 integrate(n,x) = x - x@n : +~_ ;
21
22 // convertion between float and fix point
23 float2fix(x) = int(x*(1<<20));
24 fix2float(x) = float(x)/(1<<20);
25
26 // Root Mean Square of 1000 consecutive samples
27 process = RMS(1000) ;