Can you help me to understand how RMS works?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hi guys!!!

Recently I've discovered that my Compressor Envelope is calculated by the EF of the RMS input signal, not by the EF of the input itself. What a found for me :ud:

I also understand that when I increase the Attack of the compressor, the peaks of the RMS signal decrease (using a Sinewave as input, for example).
Well, this is not clear at all for me.

Maybe because I don't completely get how the RMS signal is build from the input. I know it become a square wave. Can you explain to me how a RMS is build up (more or less; I don't need math here). Maybe a tool that take an input and with some param show the RMS in a smart way.

So I'll understand why Attack decrease RMS peaks...

Thank you!

Post


Post

Already read it. But it explains how it supposed to be, there isnt a graphic view to see the result RMS of a input signal. For example, the resulting (square) conversion from a sine signal with different attack/sustain RMS window...

Post

If the input signal is a sine and you take the mathematical average, the outcome is always zero because there is as much part of the signal positive as there is negative. So that's why you'd take the RMS because the outcome of squared is always positive (+ * + = + and - * - = + ) and with the square root it's taken back to its normal proportions: V(x^2) = abs(x).

If you do this on a per sample basis, you don't get the strength of the signal because it's still varying over time. So you'd do this for a section of time (eg 0.01 sec) containing multiple waves. Then you get an average signal strength usable for an envelope follower.

Code: Select all

Raw sine:
       _       _       _
      / \     / \     / \
_____|___|___|___|___|___|_________
         |   |   |   |   |   |
          \_/     \_/     \_/

Root squared, not averaged:
       _   _   _   _   _   _
      / \ / \ / \ / \ / \ / \
_____|___|___|___|___|___|___|____

Root squared, averaged (RMS):
       ______________________
      /                      \
_____/________________________\___

Envelope Follower signal after attack & release:
        ______________________
      _/                      \_
_____/__________________________\___

(signal raises and decays with a flatter slope)
If the "attack" parameter is built into the envelope follower itself, then it is logical that the output of the EF takes some time (the attack time) to represent the signal went from silence to on. Another architecture is to let the EF just follow the input signal and derive what the compressor has to do with that by applying attack & release times. But given your observations that doesn't seem to be the case, or what you expected to observe is only visible inside the EF and not on what it outputs.
Last edited by BertKoor on Wed Oct 07, 2015 12:13 pm, edited 1 time in total.
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

Can you explain to me how a RMS is build up (more or less; I don't need math here)
Math is ALL you do need in here. Store the buffer of last n samples (let's say, 100) and calculate RMS for it. at every time point.
Blog ------------- YouTube channel
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)

Post

BertKoor wrote: If you do this on a per sample basis, you don't get the strength of the signal because it's still varying over time. So you'd do this for a section of time (eg 0.01 sec) containing multiple waves. Then you get an average signal strength usable for an envelope follower.
But how do you take this section (window) of time? Due to it the RMS change, and create different point not related to the real averange of the signal, but it depends by this window size. I guess its an intersection between input signal and the time at which Ill sample the new point for the RMS :ud: Which makes no sense...

Post

DJ Warmonger wrote:
Can you explain to me how a RMS is build up (more or less; I don't need math here)
Math is ALL you do need in here. Store the buffer of last n samples (let's say, 100) and calculate RMS for it. at every time point.
Can you give to me a visual of this? What does it means "averenge" of samples?

Post

I edited my first post and added some visualisation while the discussion went on.
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

BertKoor wrote:I edited my first post and added some visualisation while the discussion went on.
I see.

But RMS automatically calculate the mean every cycle? Because if you change the section time (i.e. here for example is every cycle, 0.01s; change it to 1 cycle and half) the resulting RMS will be different. Is it fixed at 1/2 period?

Also, for definition: RMS averages the input values and builds a square version of them, which is gonna be less for a sine. In your diagram, RMS peaks are the same of the RAW sine.

Post

It's a partial average, so 1?n * sum of n (elements squared).
So, no, it's not take the average of n elements and then square it, it's take n elements, square them, and then average them.

Post

Nowhk wrote:
BertKoor wrote:I edited my first post and added some visualisation while the discussion went on.
I see.

But RMS automatically calculate the mean every cycle? Because if you change the section time (i.e. here for example is every cycle, 0.01s; change it to 1 cycle and half) the resulting RMS will be different. Is it fixed at 1/2 period?

Also, for definition: RMS averages the input values and builds a square version of them, which is gonna be less for a sine. In your diagram, RMS peaks are the same of the RAW sine.
The point of the squaring operation is to guarantee that you always have a positive number to average. Otherwise, as the signal oscillates around the zero point, it will wind up as roughly zero most of the time.

The window will determine the length of the averaging period: it can be hundreds of milliseconds and so many, many cycles of the input waveform.

Post

You could have a rms window length of 1 ms which would completely butcher the audio going thru a comptessor, because there is lots of audio frequency in the envelope. For instance a 250 Hz hz sine wave (a wave period of 4 ms), when the 1 ms window is over a hump of the wave the short rms measurement is big, but when the 1 ms window is over the zero crossing the measuered value is small. So the envelope rapidly flutters up and down at audio rate and causes lots of intetmodulation distortion in the compressor. Audio leaking into the control signal is called ripple.

On the other extreme, you could have an rms window many seconds or many minutes long. Such a long window would change very gradually. There would be very little risk of distortion, but the envelope would not change short term dynamics of the song. It would just gently and gradually try to keep overall dynamics at about the same level. Such devices are sometimes called auto level or AGC (Auto Gain Control).

Ideally you want a window size short enough to control the song dynamics as you desire, but long enough to avoid gross intermodulation distortion. It can be tricky to reach acceptable compromises.

There is also an average measurement in addition to rms measurement. With rms you square, sum, divide the sum by window size, and square root. With average you full wave rectify to get all positive signals (in code, abs(input) ), then sum, then divide the sum by the window size. This gives different values.

RMS of a sine wave is 0.707 * peak, but average of a sine wave is 0.637 * peak. Different wave shapes have different ratio between peak and rms. Cheap hardware meters are often average reading because it is cheaper to manufacture than rms.

http://www.electronics-tutorials.ws/acc ... ltage.html

If you need to compress tall peaks, rms or average is not very good. For instance a sine wave at 1 volt peak would have an rms of 0.707, but a tamborine track at 1 volt peak would have a very small rms reading. Because the rms is average power, and the tamborine has lots of loud impulses but not much power.

A peak reading envelope can be better to control impulsive tracks. The peak follower smoothly rides the top of peaks rather riding the middle of the rms.

Post

i once wrote a little tutorial about this:

http://www.rs-met.com/documents/tutoria ... werRms.pdf

i think, the standard way is to implement the averaging with a "leaky integrator" filter and the averaging window is expressed in terms of the time-constant of this filter. however, in case of dynamics processors, there's often a variation of this filter: it switches between two time constants, depending on whether the current input is greater or smaller than the previous output. in the former case, the "attack" time-constant would be used, in the latter case, the "release" time-constant is used
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

For my plugins, I have two stages, one to compute RMS, and then another one for the attack/release coefficients.

Post

i once wrote a little tutorial about this:
Sorry, but his looks more like a page from DSP book rather than tutorial. Tutorials are for people. Integrals are for mathematicans.
Blog ------------- YouTube channel
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)

Post Reply

Return to “DSP and Plugin Development”