Add abstrat type matrix and data.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / benchmark / rms.dsp
1 // Root Mean Square of n consecutive samples
2 RMS(n) = square : mean(n) : sqrt ;
3
4 // the square of a signal
5 square(x) = x * x ;
6
7 // the mean of n consecutive samples of a signal
8 // uses fixpoint to avoid the accumulation of
9 // rounding errors
10 mean(n) = float2fix : integrate(n) : fix2float : /(n);
11
12 // the sliding sum of n consecutive samples of a signal
13 integrate(n,x) = x - x@n : +~_ ;
14
15 // convertion between float and fix point
16 float2fix(x) = int(x*(1<<20));
17 fix2float(x) = float(x)/(1<<20);
18
19 // Root Mean Square of 1000 consecutive samples
20 process = RMS(1000) ;