Am Donnerstag, den 23. März 2017 um 17:00:14 Uhr (-0300) schrieb Alexandre Torres Porres:
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 ;)
You're almost there: If you average the values in a rectangular window with the amplitude 1 you will get 1, the same value results if averaging the values of a Hanning window with amplitude 2 (you can check that by building the definite integral of the Hanning function cos(x-pi)+1 in the interval [0..6.28] and divide that by the width of the interval (6.28)).
If you use a Hanning window of amplitude 1, you'll get 0.5 as the average. As the windowing is applied to the squared values, after calculating the root (for obtaining the "R"MS), you'll end up with sqrt(0.5) = 0.707 of the "real" RMS value and that equals to -3.0103 dB.
In short: Using a Hanning window with amplitude 2 on the squared values will compensate the loss of the resulting mean value introduced by the windowing function. The result is a compensated RMS value with an emphasis on the center of the analysis window. In this use case the windowing results in smoothing the irregularities you observed when using rectangular windows.
-- Orm