// Compute approximate RMS by leaky integration // (one pole filter) of squared signal // by Perry R. Cook, updated January 2014 adc => Gain g => OnePole p => blackhole; // basic patch adc => g; 3 => g.op; // now we have a squarer 1.0 => p.pole; 0.0 => float myRMS; spork ~ RMS(0.05); // setup a 50 ms. update loop while (1) { // do stuff if you like here 0.5 :: second => now; <<< "RMS = ", Math.pow(myRMS,0.5) >>>; } fun void RMS(float howoften) { while (1) { howoften :: second => now; Math.sqrt(p.last()) => myRMS; 0 => p.pole; 1.0 :: samp => now; 1.0 => p.pole; } }