DSPRelated.com
Forums

How to compute RMS in frequency domain

Started by Afinko January 23, 2010
Hi,

my question is very simple:
How to compute RMS in frequency domain?
I do NOT want to transform signal to the time domain by inverse DFT(FFT)
and compute then the RMS. 

Is there a way, how to compute RMS directly in frequency domain?
The signal is general (random), not only sine waves.

Thanks in advance.
Afi
On 23 Jan, 15:37, "Afinko" <afi...@gmail.com> wrote:
> Hi, > > my question is very simple: > How to compute RMS in frequency domain?
The same way that you compute RMS values in time domain? The only problem would be to keep track of the odd scaling coeffcient through the DFT, but you would have to consult the docs for your FFT imp,ementation for that. Rune
Parseval's Theorem.

See http://www.mathworks.nl/matlabcentral/newsreader/view_thread/137712, 
message 6.

Greg
Afinko wrote:
> Hi, > > my question is very simple: > How to compute RMS in frequency domain? > I do NOT want to transform signal to the time domain by inverse DFT(FFT) > and compute then the RMS. > > Is there a way, how to compute RMS directly in frequency domain? > The signal is general (random), not only sine waves.
RMS applies to a short-time mean; on the order of the longest period in the (time) waveform. Define carefully what RMS means in the frequency domain and the kind of calculation you want will probably be clear. (I suspect that the meaning will always remain murky except in certain special cases.) Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins <jya@ieee.org> wrote:
(snip)
 
> RMS applies to a short-time mean; on the order of the longest period in > the (time) waveform. Define carefully what RMS means in the frequency > domain and the kind of calculation you want will probably be clear. (I > suspect that the meaning will always remain murky except in certain > special cases.)
Well, you can calculate RMS for any time duration you want, including infinite for theoretical signals. In many cases you want the shorter term version, though, I agree. I have a program that will compute the peak and RMS for a WAV file, such as recorded by a digital audio recorder. I sometimes try to use the peak and RMS to equalize the level between tracks, but it isn't quite as easy as I might like. -- glen
> > I have a program that will compute the peak and RMS for a WAV > file, such as recorded by a digital audio recorder. &#4294967295;I sometimes > try to use the peak and RMS to equalize the level between tracks, > but it isn't quite as easy as I might like. &#4294967295; > > -- glen
Glen... you are doing this i presume to attempt to equalize the "loudness" between tracks.. I'm sure you have found that equalizing the peak does not do a good job of equalizing loudnes.. How well do you find the RMS works for this? My guess is it would work pretty well as long as there are no long periods of silence in the track. Mark
Mark <makolber@yahoo.com> wrote:

>> I have a program that will compute the peak and RMS for a WAV >> file, such as recorded by a digital audio recorder. ?I sometimes >> try to use the peak and RMS to equalize the level between tracks, >> but it isn't quite as easy as I might like. ?
> you are doing this i presume to attempt to equalize the "loudness" > between tracks..
Yes.
> I'm sure you have found that equalizing the peak does not do a good > job of equalizing loudnes..
If I do the recording without changing the record level then it would seem that not changing the relative level would be right, even though the RMS and peak might change. That is, represent the level variations of the original. Also, my current system allows for level changes in multiple of 6dB. (Also known as bits.) It isn't hard to change that, but I haven't done it yet.
> How well do you find the RMS works for this?
Lately I consider both peak and RMS.
> My guess is it would work pretty well as long as there are no long > periods of silence in the track.
Most of it is classical music, which can have long periods of lower levels and then loud endings. I believe it is more usual to do a weighted RMS but I haven't done that yet, either. -- glen
Jerry Avins wrote:
> Afinko wrote: >> Hi, >> >> my question is very simple: >> How to compute RMS in frequency domain? >> I do NOT want to transform signal to the time domain by inverse DFT(FFT) >> and compute then the RMS. >> Is there a way, how to compute RMS directly in frequency domain? >> The signal is general (random), not only sine waves. > > RMS applies to a short-time mean; on the order of the longest period in > the (time) waveform. Define carefully what RMS means in the frequency > domain and the kind of calculation you want will probably be clear. (I > suspect that the meaning will always remain murky except in certain > special cases.) > > Jerry
I think I'll sort-of disagree (was that weasel worded ;) I suspect the OP didn't use the optimum phrasing of his question/problem. I think he has a frequency domain representation of a signal (probably complex) and is looking for its absolute value as a function of frequency.
On Jan 23, 9:37 am, "Afinko" <afi...@gmail.com> wrote:
> Hi, > > my question is very simple: > How to compute RMS in frequency domain? > I do NOT want to transform signal to the time domain by > inverse DFT(FFT) and compute then the RMS. > > Is there a way, how to compute RMS directly in frequency > domain? The signal is general (random), not only sine > waves.
X = fft(x) Parseval's Theorem sum(x.^2) = sum(abs(X).^2)/N RMS == sqrt(sum(x.^2))/N) = sqrt(sum(abs(X/N).^2)) For details see (the URL is wrapped) http://groups.google.com/group/comp.soft-sys.matlab/msg/ 2222327db2ea7f51?hl=en Hope this helps. Greg
Thank you Greg.

With Parseval's theorem it works great.
I am attaching MATLAB code for verification:

f1 = 50;         % [Hz]
fs = 10000;      % [Hz]
t_max = 1;       % [sec]

x = sin(2*pi*f1*(0:1/(fs-1):t_max));
% x = randn(10000,1);   % It works for any input
X = fft(x);

RMS_t = sqrt((sum(x.^2))/length(x));
RMS_f = sqrt(sum(abs(X/length(X)).^2));

error = RMS_t - RMS_f

error =

  1.8874e-015