Can you help me to understand how RMS works?
- KVRian
- Topic Starter
- 878 posts since 2 Oct, 2013
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
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!
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
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!
-
- KVRian
- 853 posts since 13 Mar, 2012
- KVRian
- Topic Starter
- 878 posts since 2 Oct, 2013
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...PurpleSunray wrote:https://en.wikipedia.org/wiki/Root_mean_square
- KVRAF
- 15269 posts since 8 Mar, 2005 from Utrecht, Holland
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.
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.
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)
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.
My MusicCalc is served over https!!
My MusicCalc is served over https!!
- KVRAF
- 4590 posts since 7 Jun, 2012 from Warsaw
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 explain to me how a RMS is build up (more or less; I don't need math here)
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(...)
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(...)
- KVRian
- Topic Starter
- 878 posts since 2 Oct, 2013
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 Which makes no sense...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.
- KVRian
- Topic Starter
- 878 posts since 2 Oct, 2013
Can you give to me a visual of this? What does it means "averenge" of samples?DJ Warmonger wrote: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 explain to me how a RMS is build up (more or less; I don't need math here)
- KVRAF
- 15269 posts since 8 Mar, 2005 from Utrecht, Holland
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.
My MusicCalc is served over https!!
My MusicCalc is served over https!!
- KVRian
- Topic Starter
- 878 posts since 2 Oct, 2013
I see.BertKoor wrote:I edited my first post and added some visualisation while the discussion went on.
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.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
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.
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.
-
- KVRAF
- 5716 posts since 8 Jun, 2009
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.Nowhk wrote:I see.BertKoor wrote:I edited my first post and added some visualisation while the discussion went on.
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 window will determine the length of the averaging period: it can be hundreds of milliseconds and so many, many cycles of the input waveform.
-
- KVRAF
- 3080 posts since 17 Apr, 2005 from S.E. TN
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.
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.
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4289 posts since 8 Mar, 2004 from Berlin, Germany
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
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
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
For my plugins, I have two stages, one to compute RMS, and then another one for the attack/release coefficients.
- KVRAF
- 4590 posts since 7 Jun, 2012 from Warsaw
Sorry, but his looks more like a page from DSP book rather than tutorial. Tutorials are for people. Integrals are for mathematicans.i once wrote a little tutorial about this:
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(...)
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(...)