|
From: | Peter Søndergaard |
Subject: | Re: Ltfat tria window |
Date: | Fri, 02 Jan 2015 23:18:22 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 |
Den 02-01-2015 21:59, Doug Stewart
skrev:
Yes, these windows are meant to be used in the LTFAT package, and all the function there expects this format. The reason for the strange format is that it is the natural format for some applications: The most significant sample (the peak) is the first sample, so the delay caused by using the windows for filtering is zero. Also, this layout is the same as the layout used for the FFT function (DC term as first sample, Nyquest in the middle). This means that computing the discrete Fourier transform of the window is easy, just use fft(firwin('tria',11,'1')) instead of ifftshift(fft(fftshift(triang(11))) as you should do to avoid a phase shift. OTOH, the LTFAT layout looks weird and is sometimes cumbersome to work with, I agree. Anyway, back to your question: fftshift(firwin('tria',11,'1')) will make the window look nice for plotting. To chime in on the discussion: When I originally created LTFAT it tried using the hanning window functions from Matlab for the transforms, but they where too strange, and I have never found anyone that could explain to me why they have been made that way. From looking at the Matlab code I am tempted to conclude that the people that originally created them simply did not do a good job, or were not experts in the field. When creating a triangular or Hanning window window, there are two main properties that you would like to have: 1) Some kind of mirror symmetry, there are two options. - Symmetric in between two sampling points, this is the default one. It is incompatible with the way FFT is defined, but it is easy to cut a window in half (is the window has even length). If you pass the 'hp' flag to firwin, you get this behaviour. - Symmetric around a sampling point. This is compatible with the FFT, but there will usually be a point with value zero in the window, which some people don't like. This is the default behaviour of firwin 2) The partition-of-unity property (also known as "time domain aliasing cancelling"): If you shift the window by half its length, and add it to itself, the sum should be one. Try this for instance: firwin('hann',10)+fftshift(firwin('hann',10)) I don't know if you should keep the bug-for-bug compatibility with Matlab, or you should change the definition of the window functions to something saner. Personally, I you agree to break compatibility, I would to define hanning(N) as fftshift(firwin('hann',N,'hp')) (and similarly for the other windows) This is not too alien from the original definition (it keep the same symmetry properties), but it restores the partition-of-unity property. Cheers, Peter. |
[Prev in Thread] | Current Thread | [Next in Thread] |