[LAD] Calculate R M S
    Fons Adriaensen 
    fons at linuxaudio.org
       
    Fri Feb 18 19:02:54 UTC 2011
    
    
  
On Fri, Feb 18, 2011 at 07:53:46PM +0200, Alfs Kurmis wrote:
 
>  It  means block schema of Automatick Gain/Volume Control is
>  (can be)
Please try to avoid those   characters in your mails....
>  Filter -- RMS_Calculator -- Volume_control 
>  In exact such order ?
Yes. The filter is not essential, you can get good results
without it. Most compresssors or AGCs don't have a filter.
>  (- For example in FFT are used Rectangular(no window) , Hann,
>  Hamming, Barlow ... windows. -)
FFT windows have nothing to do with this.
>  What are the most common filters for ACG and "Loudness" control ?
Just a simple first order lowpass acting on the squared samples. 
> >  Nothing special is needed for high frequencies.
>  Why not ?
Because the theory says so. You can either
1. believe me,
2. study the theory yourself,
3. try it out yourself.
2 and 3 would be the best thing to do. See also the example
at the end of this post.
>  So far i unterstand the best way for RMS calc would be SQRT of
>  integral of power2 of sound signal function.
>  Real signal is not sequence of sampled rectangles, but smooth
>  function.
>  Can not happen so what that rectangle inaccuracy of each sample by
>  freq > 10KHZ ,
>  in end effect will accumulate big inaccuracy ?
The analog signal is *not* the samples converted to rectangles
and smoothed a bit. It looks like that for low frequencies, but
what is really happening in DA conversion is something completely
different.
>  U mean that normally full amplitude sine wave is defined as 0dB RMS
>  signal ?
In most cases that is the definition of '0 dB'.
>  Can U plz gimme some examples ?
Take a sine wave with peak amplitude +/- 1. The samples are:
sample [i] = sin (w * i)
i = sample number.
w = 2 * pi * frequency / sample_frequency.
Now the square of sin(x) is  0.5 + 0.5 * cos(2 * x)
The average value of cos(2 * x) is zero, so the average
value of the square of sin(x) is 0.5, and the RMS value
is sqrt(0.5) =~ 0.7071. 
It doesn't matter where the samples are: if there are enough
of them then the average of cos(2 * x) will be zero, and the
result of the RMS calculation will be sqrt(0.5). ** Also for
high frequencies. **
A square wave of amplitude +/- 1 has RMS value 1. So if you
use the sine wave above as the reference (0 dB) then the 
square wave is +3 dB.
But note that if you sample an analog square wave, the samples
will in most case *not* be +/- some single value. And if your
samples are +/- some value, then the analog waveform will in
most cases *not* be a lowpassed square wave (in both cases
it will be close at low frequencies). The relation between
samples and the analog waveform is not as simple as that.
Ciao,
-- 
FA
    
    
More information about the Linux-audio-dev
mailing list