General > General Technical Chat
FFT window function calculation detail
<< < (5/8) > >>
gf:

--- Quote from: Nominal Animal on November 24, 2022, 01:06:24 pm ---There is no Hanning window function!  There is Hann, and there is Hamming.  They are closely related, but different.

--- End quote ---

The name of the guy was indeed "Julius von Hann". Nevertheless I see "Hann" and "Hanning" being used as synonyms for each other almost everywhere. The matlab function is hanning(), too.
Nominal Animal:

--- Quote from: gf on November 24, 2022, 01:36:32 pm ---
--- Quote from: Nominal Animal on November 24, 2022, 01:06:24 pm ---There is no Hanning window function!  There is Hann, and there is Hamming.  They are closely related, but different.

--- End quote ---
The name of the guy was indeed "Julius von Hann". Nevertheless I see "Hann" and "Hanning" being used as synonyms for each other almost everywhere. The matlab function is hanning(), too.

--- End quote ---
Well, people can call poop chocolate if they want, but it does not make it true.  (Anyway, I do believe Matlab/Octave have hann() and hamming(), too, so maybe hanning() is just an alias to help stupid people?)

I would actually prefer the functions have descriptive names instead of people names, but we humans aren't rational that way.

The reason the two are conflated is that both are examples of \$K=1\$ cosine sum window functions,
$$w_n = \sum_{k=0}^K (-1)^k a_k \cos\left(\frac{2 \pi k n}{N}\right), \quad 0 \le n \le N$$
i.e. both described using the same formula,
$$w_n = a_0 - (1 - a_0) \cos\left(\frac{2 \pi n}{N}\right), \quad 0 \le n \le N \tag{Both}\label{Both}$$
with \$a_0 = 0.5\$ being a Hann window, simplifying (via \$\cos(2 x) = 1 - 2 \sin^2(x)\$) to
$$w_n = \sin^2\left(\frac{\pi n}{N}\right), \quad 0 \le n \le N \tag{Hann}\label{Hann}$$
and \$a_0 = \frac{25}{46} \approx 0.54\$ being a Hamming window, simplifying to
$$w_n = \frac{25}{46} - \frac{21}{46}\cos\left(\frac{2 \pi n}{N}\right), \quad 0 \le n \le N \tag{Hamming}\label{Hamming}$$
rhb:
The windows in the left column of the initial post are correct.  As anything multiplied by zero is zero, any other implementation is naive.

An odd length window introduces a half sample phase delay in the output.  So forcing even length windows to be odd avoids that at the cost of not being the specified transfer function.  That may or may not matter.  Normally for a window function it doesn't matter.  I like Bartlett and Gaussian windows because of the frequency domain behavior.

In any case, one should always look at both the frequency and time domain impulse responses to verify you are getting the window you expect.  Doesn't matter if you wrote it or your employer paid >$100k for a seat.  Take a Reagan approach, "Trust, but verify."  Every time!

FWIW The assertion that there is an N log N solution for prime lengths is not correct.  In that case there are no periodicities and thus no escape from N**2.

It took me *years* to grasp the FFT properly because the explanations were so bad.  The concept is simple, add all the samples of the form  i*2*pi for all integer i  *before* multiplying rather than after.  That's all it is.  Or put differently, you can decompose an FFT by *any* factor, not just 2.  The DFT is sampled at (i/N)*2*Pi.  So for all values of i/N which are integers you can exchange the order of operation and rop lots of expensive multiplies.  But as should be clear, for N integer there are no integer values of i/N.

Unfortunately, there are a lot of very bad DSP codes floating around.  And minor differences in jargon and definitions just makes matters worse.

Have Fun!
Reg
Nominal Animal:

--- Quote from: rhb on December 10, 2022, 01:51:37 am ---FWIW The assertion that there is an N log N solution for prime lengths is not correct.  In that case there are no periodicities and thus no escape from N**2.

--- End quote ---
Utter bullshit.  Just because Cooley-Tukey cannot do prime N, does not mean it cannot be done in general.

For examples of O(N log N) for prime N, look at Bluestein and Rader FFT algorithms.

For practical implementation you can trivially verify for yourself, just go take a look at the FFTW library.


--- Quote from: rhb on December 10, 2022, 01:51:37 am ---It took me *years* to grasp the FFT properly because the explanations were so bad.
--- End quote ---
Are you sure you actually did?
electr_peter:

--- Quote from: rhb on December 10, 2022, 01:51:37 am ---The windows in the left column of the initial post are correct.  As anything multiplied by zero is zero, any other implementation is naive.

--- End quote ---
I am going with this implementation (zero - non-zero fashion) described in left column. Filters based on functions, which have single peak in the middle, will have single peak with even \$N\$ and "flat top" with odd \$N\$. And almost all filters will have single zero as first weight (except raised cosine and other special cases), but non-zero as last weight.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod