Re: [LAD] Calculate R M S

From: Dominique Michel <dominique.michel@email-addr-hidden>
Date: Wed Feb 16 2011 - 22:31:18 EET

Le Wed, 16 Feb 2011 19:51:09 +0200,
Alfs Kurmis <kallipygos@inbox.lv> a écrit :

>
> Hi Experts.
> I wanna normalize my sound stream by loudness (energy / pressure /
> intensity) , not by peaks.
> How i do it ?
> Is available Jack plugin for so what ?
> What is (we hear as) "loudness" ?

Loudness is an adaptive filtering that depend on the position of the
volume knob. At full volume, no filtering is done, at low volume, the
low and high frequencies are more amplified than the medium ones.

> RMS or +(average) or something else ?

In Audio, that is a mean to express or measure the sound volume.
http://en.wikipedia.org/wiki/Root_mean_square

It is different ways to measure the sound level. For low end home
equipment, the sinus power is used. Such a sound doesn't correspond
well to a real life situation, that is when your are listening to some
music. It can also be very stressful for an amplifier.

A much better way to express the power of a sound equipment, is to use
some kind of white or pink noise instead of a sinus. That is how the
rms power is measured. In such, it doesn't tell anything because you
have to know the condition of the measure (usually the characteristics
of the white or pink noise, and a given rate of distortion) in order to
be able to interpret it.

In practice, the rms power is usually a little bit lower than the sinus
power measured at the same rate of distortion.

> Is somewhere available examples how to calculate RMS ?
> Is it done simlpe by :
> &#160;int i, n;&#160; double sums, rms;
> &#160;sums=0.0;&#160; n=10;&#160; rms=0;
> &#160;for(i=0; i<n;i++)
> &#160;{&#160;&#160; sums = sums + ( (double)i * (double)i );&#160; }
> &#160;rms = sqrt(sums / n);
> &#160;printf("&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
> rms = %12.12fnn", rms );
> Is so sipmple algo good enough for frequencies > 10 kHz ?
> How to calculate RMS with hi-precision for frequencies > 10 kHz ?
> With inerpolation or so ?
> What is reference ( 0dB ) RMS for example for 16bit PCM signal 1024
> samples ?
> &#160; sqrt( 1024*(0x7FFF ^ 2) / 1024 )&#160; ==&#160; sqrt( (0x7FFF
> ^ 2)&#160; ) == 0x7FFF&#160;
> Is it simple&#160; 0x7FFF (32000 dec) ?
> How to calc RMS for stereo signal ?
> So , or somehow else ?
> for(i=0; i<n;i++)
> &#160;{&#160; ....
> &#160;&#160; sums = sampleL/2 + sampleR/2;
> &#160;}
> In case operating with float point, what should be a bit
> faster,&#160; / 2&#160; or * 0.5 ?
> How to gotta RMS value in dB ?
> &#160;&#160; 20 x log10(Measured/Reference0_dB)&#160;
> or 10 x log10(Measured/Reference0_dB)&#160; ??
> Im just physics student and im new in DSP,
> so pleaz no angree about simple or stuppid questions.
> Any examples and hints welcomed.
> Many Tnx in advance.
> Alf
> ----

RMS is used in audio to express the power. By analogy, some
manufacturers are using it to express the output or input voltage
of their equipments. But it doesn't change anything, the math is always
the same with the db, When you are talking about power, you have
10 * log (P1/P2). When talking about voltage or current, it become
20 * log (U1/U2) = 20 * log (I1/I2)

http://en.wikipedia.org/wiki/Decibel

The 0 db of an audio equipment is the maximum level it can handle at a
given rate of distortion, and with a given and constant waveform or
noise.

With the analog electronic, your equipment will be able to handle
higher values of the input signal during a short period of time (in
some cases even much higher values). This is what we call the headroom.
It can be expressed by the measure of the musical power, it is the
same issue than with the measure of the rms or sinus power, you have to
know the exact condition of the measure in order to be able to
interpret it.

In other words, the specifications must tell you enough in order to be
able to reproduce exactly the same measurements and all the described
measurements. If it is not the case, they are just bullshit.

Another issue is that it is no normalised way to measure and express
the specifications of an audio equipment. Each manufacturer is using its
own measure protocol. So, it can be difficult to compare them on the
paper. And many specification sheets are just bullshit because they
doesn't tell enough about the conditions of the measurements.

With a digital signal, you will get no headroom at all. The maximum is
when all the bits are to 1. If you add something, the bit number
doesn't change and you will get a wrong result.

It is one point on which jack with its floating point approach is
better. You can do calculations inside jack that will be outside the
scope of the sound card but valid inside jack. With a floating point
approach, you can define the 0 db to be somewhere on the middle, and do
calculations with a good approximation, calculations that would be
impossible in practice with an integer based system (because of the
added complexity to take the errors in account). Of course, you
will still have to insure that the d/a converters of the sound card will
handle the result of your calculation. Such converters know only about
integers, if the digital sound level inside jack is too high, it will
be clipped by the sound card.

Inside jack, all you will have to do is to be sure that the result
of your calculation will be inside the limits of jack. When outputing
to the sound card, a mixer and a vu-meter are good things to have.

Dominique

-- 
"We have the heroes we deserve."
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Thu Feb 17 00:15:04 2011

This archive was generated by hypermail 2.1.8 : Thu Feb 17 2011 - 00:15:04 EET