# [music-dsp] RMS / time coeff. / gain smoothing (was Please check ...)

Citizen Chunk citizenchunk at nyc.rr.com
Sat Dec 13 10:28:01 EST 2003

```Furi:

by coincidence, i did a search for "RMS detection TAV" to learn more
about how the averaging coefficient is formulated, and i found this
http://www.ktl.elf.stuba.sk/projects/audio/drc/realization/
realization.htm

it seems that someone implemented this in his design. of further note
is his peak detection difference equation:

xpeak(n) = (1 – AT – RT) . xpeak(n-1) + AT.|x(n)|

i found it curious that the author incorporated both the attack/release
coefficients into 1 equation. i am using an if/else structure for
attack/release.

input = |x|
if ( input > env )
env = input + AT * ( env - input )
else
env = input + RT * (env - input )

is there some advantage to the former over the latter?

also, i wondered how the author was formulating his time coefficients.
i am using someone else's algo:

AT = e ^ ( ln (0.01) / Attack_in_samples )
RT = e ^ ( ln (0,01) / Release_in_samples )

i am also struggling with the concept of gain smoothing and
"soft-knee". is this essentially implemented in the AT and RT
coefficient equations? or is this a separate calculation that occurs
after the control gain (gain reduction) is calculated?

getting back to RMS detection, in the linked article, the author states
that the TAV coeff. can be equal to either AT or RT and between 0 and
1. what if one were to create an "RMS Average" parameter, similar to
traditional "attack" and "release" time parameters (translating from
user input in ms to samples in the back-end), and use the above
attack/release coeff. equations to calculate TAV. in other words:

TAV = e ^ ( ln (0.01) / RMS_average_in_samples )

and then to plug that into your RMS equation.

the aforementioned author uses a different equation for calculating AT
and RT, which i don't quite understand. (see the section "Gain Factor
Smoothing".) though, isn't this essentially what i'm already doing with
my time coefficients? what if i replaced the value "0.01" with a
parameter k, where k is between 0.01 and 1? would that effectively be a
soft-knee parameter?

On Dec 12, 2003, at 1:09 AM, Furi Andi Karnapi wrote:

> Hi,
>
> I'm not sure about DAFX book. Anyway, the RMS measurement equation is
> xRMS(n) = (1 - TAV).xRMS(n - 1) + TAV.x^2(n), where TAV is an
> averaging coefficient. You need to take the square root of xRMS(n) to
> get the RMS value.
>
> Regards,
> Furi
>
> -----------------------------------------------
> Furi Andi Karnapi
> DSP Lab S2-B4a-03
> School of EEE, Nanyang Tech. University
> Singapore 639798
> Phone: +65-6790-6901
> -----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2669 bytes
Desc: not available
Url : http://music.columbia.edu/pipermail/music-dsp/attachments/20031213/c827bf78/attachment-0001.bin
```