DSPRelated.com
Forums

How to compute RMS in frequency domain

Started by Afinko January 23, 2010
>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 >
I added this information also to the wikipedia: http://en.wikipedia.org/wiki/Root_mean_square#RMS_in_frequency_domain
In article <a5b54ee5-fe98-4652-828c-
437f64dc1ffb@h2g2000vbd.googlegroups.com>, makolber@yahoo.com says...
> > > >> >> 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.
http://en.wikipedia.org/wiki/Replay_Gain
> > >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. > > http://en.wikipedia.org/wiki/Replay_Gain- Hide quoted text - >
thanks Robert... Mark
>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 >
In the RMS calculation if I include abs(X) at only few frequencies among the entire range for which X has been evaluated, would it be equivalent to applying band pass filter to the original time signal and then taking RMS of it? Rahul