# [PD] how does env~ work?

Christof Ressi christof.ressi at gmx.at
Thu Mar 23 23:27:26 CET 2017

```> sorry, I guess I didn't get most of what you said :/ kinda over my head...

no worries. just an awkward attempt from my side to explain code with words :-D.

> actually, also, the envelope is applied to the squares of the amplitudes... and this gets me completely lost now on what it means mathematically

https://en.wikipedia.org/wiki/Root_mean_square

in short, RMS means you square each sample, sum them, divide the sum by the number of samples and then take the square root. in case you're wondering where the square root is, it is in powtodb(). compare rmstodb() and powtodb() to see the difference. rmstodb() expects an rms value (the square root already taken) while powtodb() will take the square root for you (and luckily, log(sqrt(x) is simply log(x)/2).

> the hanning envelope itself actually goes from 0 to "2" and not from 0 to 1, so I assume the compensation is done right there...

that's a good observation!

the integral (= running sum) of
f(x) = 0.5 - cos(2pi*x)*0.5 (= Hanning window within range 0-1)
is
F(x) = x*0.5 - sin(2pi*x)/4pi

F(1) (= the sum after a full period) is 0.5. That's the reason why the Hanning window in this case is twice as large to bring the sum to 1. weighting a constant(!) signal with such a Hanning window will yield the same sum as with a non-weighted signal.

Christof

Gesendet: Donnerstag, 23. März 2017 um 21:11 Uhr
Von: "Alexandre Torres Porres" <porres at gmail.com>
An: "pd-list at lists.iem.at" <pd-list at lists.iem.at>
Betreff: Re: [PD] how does env~ work?

actually, also, the envelope is applied to the squares of the amplitudes... and this gets me completely lost now on what it means mathematically

2017-03-23 17:00 GMT-03:00 Alexandre Torres Porres <porres at gmail.com[mailto:porres at gmail.com]>:

2017-03-23 16:53 GMT-03:00 Alexandre Torres Porres <porres at gmail.com[mailto:porres at gmail.com]>:

2017-03-23 16:45 GMT-03:00 Alexandre Torres Porres <porres at gmail.com[mailto:porres at gmail.com]>:

and as I see it, it's just applying a hanning envelope into the input and NOTHING more, right?

the hanning envelope itself actually goes from 0 to "2" and not from 0 to 1, so I assume the compensation is done right there...

tested with an envelope going from 0 to 1 and lost about 3.0103 dB ;)_______________________________________________ Pd-list at lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]

```