[LAD] Total and Agerage RMS power calculation
Fons Adriaensen
fons at kokkinizita.net
Mon Jun 25 13:19:38 UTC 2007
On Mon, Jun 25, 2007 at 07:56:09PM +0900, chandrashekhar singh wrote:
> I have written a small test application to calculate Average RMS
> and max RMS power of a wave file.
Your terminology is not very clear. What exactly do you mean by
'average' RMS and 'max' RMS ? The 'M' in RMS stands for 'mean',
so it is already an average over all samples considered, and
the additional 'average' is meaningless. It is completely
unclear what you mean by 'max RMS'.
> Wave file audio data having 16 bit sample and mono.
> i'm using the following algorithm :
>
> i=N-1
> rms = sqrt(1/N ∑ sample[i] * sample[i] ) (1)
> i=0
That is, by definition of RMS = square Root of the Mean of the
Squares, the RMS value of the N samples, expressed in the same
unit as the samples themselves.
> AvgRMS = 20.0 * log10 ( rms /2^N-1)
You may be confusing two values of N here, the first being the
number of samples, as in equation (1), and the second being
the number of bits.
Equation (1) is still expressed using the same unit as the 16-bit
samples themselves, i.e. if all samples are 10000 then the RMS
value will be 10000 as well. When converting to dB, it is
customary to set 0 dB to the maximum possible value, i.e.
2^(B-1), where B is the number of bits in a sample. To do this,
we divide by the maximum value:
normalised_rms = rms / (2^(B-1))
and then convert to dB:
normalised_rms_in_dB = 20 * log10 (normalised_rms).
Hope this helps a bit ...
--
FA
Follie! Follie! Delirio vano è questo !
More information about the Linux-audio-dev
mailing list