True RMS value for audio samples
True RMS value for audio samples
- Subject: True RMS value for audio samples
- From: Luigi Castelli <email@hidden>
- Date: Mon, 9 Jul 2007 10:13:57 -0700 (PDT)
Hi there,
I am working on a true RMS detector and, even though it seems like an easy task to accomplish, I stumbled upon a problem I don't know how to solve.
I know the math for true RMS value detection is:
RMS(x) = sqrt( 1/N * \xAD\xF4 0 to N (x[n] * x[n]) )
To implement the function efficiently I am not using a moving average window like the formula would indicate, but I am rather using a 1-pole lowpass filter to perform the averaging.
So my code looks something like:
float *in = invec;
float *out = outvec;
long n = blocksize;
float relaxcoeff = relax;
float clampcoeff = clamp;
float y0;
float y1 = prevsample;
while (n--) {
float zin = *in++;
y0 = zin * zin;
if (y0 < y1) {
y1 = y0 + relaxcoeff * (y1 - y0);
} else {
y1 = y0 + clampcoeff * (y1 - y0);
}
*out++ = sqrt(y1);
}
To make the algorithm conform to PPM metering I made the clamp time 10 ms and the relax time 1500ms both calculated over 20dB.
Now this works to a certain extent, however when compared to audio metering programs like Spectre or SpectraFoo the value reported by my algorithm is VERY different.
For the same audio material I get something 5-6 dB higher than what I read on those applications.
I would like to know from the experts (I know the author of Spectre reads this list) what I am doing that is giving me an inaccurate RMS value estimation.
Thanks a lot for your time.
Sincerely
- Luigi Castelli
------------------------------------------------------------
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT email@hidden AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC
1-207.
------------------------------------------------------------
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
http://mobile.yahoo.com/go?refer=1GNXIC
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden