octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ltfat tria window


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:


On Fri, Jan 2, 2015 at 3:54 PM, Jerry <address@hidden> wrote:

On Jan 2, 2015, at 12:29 PM, Doug Stewart <address@hidden> wrote:

> firwin('tria',11,'1')
> ans =
>
>    0.180328
>    0.147541
>    0.114754
>    0.081967
>    0.049180
>    0.016393
>    0.016393
>    0.049180
>    0.081967
>    0.114754
>    0.147541
>
> --
>
>
> This seems to me to be a mistake.
> T was hoping for a triangle window.

It's rotated.
Jerry


Are all the windows in ltfat rotated?
And by being rotated then the unsymmetrical part is at the high part not the zero location at the end?????

So these windows are used quit differently than the ones in signal pkg.
???
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.














reply via email to

[Prev in Thread] Current Thread [Next in Thread]