0
0

hi folks!
How to get the RMS (Root Mean Square) level of a wave file ?
please help me

  • You must to post comments
0
0

Maybe this C code is going to be useful:

Get_RMS (signed short *buffer,unsigned long samples,float *left_rms,float *right_rms)
{
unsigned long i;
const float divisor=32768;
const float multiplier=1/divisor;
float left_raw_rms=0;
float left_te_sample;
float right_raw_rms=0;
float right_te_sample;

for (i=0;i<samples;i=i+2)
{
    left_te_sample=(float)(buffer[i]*multiplier);
    left_raw_rms+=left_te_sample*left_te_sample;

    right_te_sample=(float)(buffer[i+1]*multiplier);
    right_raw_rms+=right_te_sample*right_te_sample;
}

*left_rms=(float)sqrt(left_raw_rms/(samples>>1));
*right_rms=(float)sqrt(right_raw_rms/(samples>>1));

return;

}

RMS is just the square root of the square of all the samples summed up divided by the number of samples:

rms=sqrt((s[0]s[0] + s[1]s[1] + … + s[n]*s[n]) / n)

Check also (discrete distrubution):

http://mathworld.wolfram.com/Root-Mean-Square.html

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.