Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formula for windowing algorithms #63

Open
jerabaul29 opened this issue Jan 13, 2021 · 9 comments
Open

formula for windowing algorithms #63

jerabaul29 opened this issue Jan 13, 2021 · 9 comments

Comments

@jerabaul29
Copy link

I am confused about the formula used for the windowing algorithms. Do you have a reference document describing these?

For example:

case FFT_WIN_TYP_HANN: // hann
weighingFactor = 0.54 * (1.0 - cos(twoPi * ratio));
break;

does not seem to agree with the amplitude or energy correction factors here:

https://community.sw.siemens.com/s/article/window-correction-factors

Maybe I am just confused though.

@kosme
Copy link
Owner

kosme commented Jan 13, 2021 via email

@jerabaul29
Copy link
Author

Mmh, if I remember well FFT(a f) = a FFT(f), so applying the correction before or after the transform should be the same, right? Or am I missing something? ...

@hugke729
Copy link

@jerabaul29 : your expression is correct if a is a constant, but in this case it is a window. Look at the second panel in the first figure of the article you linked to. Note, also, that weighingFactor is a confusing name here. It's not a single factor, it's a window.. Finally, per issue #61, the Hann window isn't quite right.

@jerabaul29
Copy link
Author

Mmh, agree I should have been clearer and write that:

FFT(a * signal * windowing) = a * FFT(signal * windowing),

I wrote in the way I did because it is the usual notation when working with proofs of linearity on vector spaces.

But with a the constant scaling factor, it should be the same before or after applying the FFT I would think? ...

Just to be clear: I am aware that the Hanning window looks like a 'bell', I am thinking of the factor 0.54 that seems to disagree with other sources I have found.

@DrDiettrich
Copy link

DrDiettrich commented Jan 15, 2021 via email

@jerabaul29
Copy link
Author

Yes, I am aware of that. What we discuss here is the factor to use so that the windowing does not change the energy content.

@jerabaul29
Copy link
Author

If someone else looks into this and finds this thread. I took a bit of time to double check this. I am pretty confident that these formula are not right:

case FFT_WIN_TYP_HAMMING: // hamming
weighingFactor = 0.54 - (0.46 * cos(twoPi * ratio));
break;
case FFT_WIN_TYP_HANN: // hann
weighingFactor = 0.54 * (1.0 - cos(twoPi * ratio));
break;

I take as a reference the reference numpy documentation, which I have much trust in:

https://numpy.org/doc/stable/reference/generated/numpy.hanning.html

https://numpy.org/doc/stable/reference/generated/numpy.hamming.html

And a table from univ. Zurich for the "scaling coefficients":

https://www.physik.uzh.ch/local/teaching/SPI301/LV-2015-Help/lvanlsconcepts.chm/Scaling_Smoothing_Windows.html

which are in agreement with the previous link.

I am personally moving to kissfft, as it fits my needs better.

@jerabaul29
Copy link
Author

jerabaul29 commented Feb 20, 2021

Sorry, the Hamming should be good, but the Hann is probably wrong. It is right as pointed higher up that this is the same issue as #61.

@jerabaul29
Copy link
Author

(but I still think that these windows are not compensated; which is fine, but may be worth having a line of comment about the need to compensate to keep either amplitude or energy constant :) ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants