Hello there, I'm currently working on a pitch identification program in MATLAB. It uses the Sliding DFT so I need to apply windowing functions in the frequency domain. I understand this is done by convolution and have managed to find the kernel for the von Hann window: [-0.25 0.5 -0.25], but am struggling to find a concrete answer for other windows like the Hamming and Blackman window. Anyone know? Also, am I right in thinking I should be using the circular convolution (cconv) function to do this in MATLAB? And why doesn't cconv(A,[-0.25 0.5 -0.25]) give a result that's the same size as A? I can't understand where the extra elements come from. Thanks for reading, now wash your hands.

# Windowing in the Frequency Domain

Started by ●April 4, 2009

Reply by ●April 4, 20092009-04-04

On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote:> Hello there, > I'm currently working on a pitch identification program in MATLAB. �It > uses the Sliding DFT so I need to apply windowing functions in the > frequency domain.Ouch... I am not aware of a single application where windows are applied in frequency domain...> I understand this is done by convolution and have managed to find the > kernel for the von Hann window: [-0.25 0.5 -0.25], but am struggling to > find a concrete answer for other windows like the Hamming and Blackman > window. > Anyone know?The window functions - along with the common use - are listed in most textbooks on DSP.> Also, am I right in thinking I should be using the circular convolution > (cconv) function to do this in MATLAB?If you stick with a frequency-domain implementation then yes, circular convolution is what you want. But then, the approach of doing the computations in frequency domain is wrong. The term 'circular convolution' is a warning sign in itself. In the context of DSP circular convolution is almost never what you want. There might be some exceptions, where circular convolution is used in the context of cyclic (circular?) codes, but that's the exception. Once the term comes up, stand back, take a deep breath and think very carefully about what you are doing. Chances are that you are doing something wrong.>�And why doesn't cconv(A,[-0.25 0.5 > -0.25]) give a result that's the same size as A? �I can't understand where > the extra elements come from.It seems you are in above your head, as this is covered in the first month (maybe week) of DSP 101. It will save you a lot of effort (not to mention potential abuse here) if you find a good intro text on DSP (Rick Lyons' "Understanding DSP" comes to mind) and read. Rune

Reply by ●April 4, 20092009-04-04

On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote:> Hello there, > I'm currently working on a pitch identification program in MATLAB. =A0It > uses the Sliding DFT so I need to apply windowing functions in the > frequency domain.Ouch... I am not aware of a single application where windows are applied in frequency domain...> I understand this is done by convolution and have managed to find the > kernel for the von Hann window: [-0.25 0.5 -0.25], but am struggling to > find a concrete answer for other windows like the Hamming and Blackman > window. > Anyone know?The window functions - along with the common use - are listed in most textbooks on DSP.> Also, am I right in thinking I should be using the circular convolution > (cconv) function to do this in MATLAB?If you stick with a frequency-domain implementation then yes, circular convolution is what you want. But then, the approach of doing the computations in frequency domain is wrong. The term 'circular convolution' is a warning sign in itself. In the context of DSP circular convolution is almost never what you want. There might be some exceptions, where circular convolution is used in the context of cyclic (circular?) codes, but that's the exception. Once the term comes up, stand back, take a deep breath and think very carefully about what you are doing. Chances are that you are doing something wrong.>=A0And why doesn't cconv(A,[-0.25 0.5 > -0.25]) give a result that's the same size as A? =A0I can't understand wh=ere> the extra elements come from.It seems you are in above your head, as this is covered in the first month (maybe week) of DSP 101. It will save you a lot of effort (not to mention potential abuse here) if you find a good intro text on DSP (Rick Lyons' "Understanding DSP" comes to mind) and read. Rune

Reply by ●April 4, 20092009-04-04

On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote:> Hello there, > I'm currently working on a pitch identification program in MATLAB. �It > uses the Sliding DFT so I need to apply windowing functions in the > frequency domain.Ouch... I am not aware of a single application where windows are applied in frequency domain...> I understand this is done by convolution and have managed to find the > kernel for the von Hann window: [-0.25 0.5 -0.25], but am struggling to > find a concrete answer for other windows like the Hamming and Blackman > window. > Anyone know?The window functions - along with the common use - are listed in most textbooks on DSP.> Also, am I right in thinking I should be using the circular convolution > (cconv) function to do this in MATLAB?If you stick with a frequency-domain implementation then yes, circular convolution is what you want. But then, the approach of doing the computations in frequency domain is wrong. The term 'circular convolution' is a warning sign in itself. In the context of DSP circular convolution is almost never what you want. There might be some exceptions, where circular convolution is used in the context of cyclic (circular?) codes, but that's the exception. Once the term comes up, stand back, take a deep breath and think very carefully about what you are doing. Chances are that you are doing something wrong.>�And why doesn't cconv(A,[-0.25 0.5 > -0.25]) give a result that's the same size as A? �I can't understand where > the extra elements come from.It seems you are in above your head, as this is covered in the first month (maybe week) of DSP 101. It will save you a lot of effort (not to mention potential abuse here) if you find a good intro text on DSP (Rick Lyons' "Understanding DSP" comes to mind) and read. Rune

Reply by ●April 4, 20092009-04-04

Hello, thanks for the help>On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote: >> Hello there, >> I'm currently working on a pitch identification program in MATLAB.=A0It>> uses the Sliding DFT so I need to apply windowing functions in the >> frequency domain. > >Ouch... I am not aware of a single application where >windows are applied in frequency domain...It is impossible to window in the time domain when using the SDFT, so I must do that process in the frequency domain.>> I understand this is done by convolution and have managed to find the >> kernel for the von Hann window: [-0.25 0.5 -0.25], but am strugglingto>> find a concrete answer for other windows like the Hamming and Blackman >> window. >> Anyone know? > >The window functions - along with the common use - are listed >in most textbooks on DSP.Most sources list the time domain functions. I don't know how to translate them to the convolution kernels I need. So far I have found two sources that give them but they don't seem to agree. Maybe I'm reading them wrong.>> Also, am I right in thinking I should be using the circularconvolution>> (cconv) function to do this in MATLAB? > >If you stick with a frequency-domain implementation then >yes, circular convolution is what you want. But then, the >approach of doing the computations in frequency domain >is wrong. > >The term 'circular convolution' is a warning sign in itself. >In the context of DSP circular convolution is almost never >what you want. There might be some exceptions, where >circular convolution is used in the context of cyclic >(circular?) codes, but that's the exception. Once the term >comes up, stand back, take a deep breath and think very >carefully about what you are doing. Chances are that you >are doing something wrong. > >>=A0And why doesn't cconv(A,[-0.25 0.5 >> -0.25]) give a result that's the same size as A? =A0I can't understandwh=>ere >> the extra elements come from. > >It seems you are in above your head, as this is covered >in the first month (maybe week) of DSP 101. It will save >you a lot of effort (not to mention potential abuse here) >if you find a good intro text on DSP (Rick Lyons' >"Understanding DSP" comes to mind) and read. > >Rune >Yeah, I guess I had a moment of stupidity there. Happens sometimes.

Reply by ●April 4, 20092009-04-04

Rune Allnor wrote:> On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> > wrote:>> I'm currently working on a pitch identification program in >> MATLAB. �It uses the Sliding DFT so I need to apply windowing >> functions in the frequency domain. > > Ouch... I am not aware of a single application where > windows are applied in frequency domain...The application is when you have a spectrum in hand and the window's spectrum has small support.>> I understand this is done by convolution and have managed to >> find the kernel for the von Hann window: [-0.25 0.5 -0.25], but >> am struggling to find a concrete answer for other windows like >> the Hamming and Blackman window.It's always the transform of the time-domain window function. For windows defined as cosine sums, like your other examples, that means the central kernal value is the window's constant term and the other values are half the coefficients on the cosines; half because each occurs twice.>>�And why doesn't cconv(A,[-0.25 0.5 -0.25]) give a result that's >> the same size as A?Read the documentation: "If you omit n, it defaults to length(a)+length(B)-1. When n = length(a)+length(B)-1, the circular convolution is equivalent to the linear convolution computed with conv." Martin -- Quidquid latine scriptum est, altum videtur.

Reply by ●April 4, 20092009-04-04

On Sat, 4 Apr 2009 10:48:09 -0700 (PDT), Rune Allnor <allnor@tele.ntnu.no> wrote:>On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote: >> Hello there, >> I'm currently working on a pitch identification program in MATLAB. �It >> uses the Sliding DFT so I need to apply windowing functions in the >> frequency domain. > >Ouch... I am not aware of a single application where >windows are applied in frequency domain...Just as an example, when doing fast convolution or fast correlation with FT-mult-FT applying the window function as part of the inter-transform multiplication (which is in the frequency domain if the signals are in the time domain) controls the sidelobe levels in the output. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php

Reply by ●April 4, 20092009-04-04

OldUncleSilas wrote: ...> It is impossible to window in the time domain when using the SDFT, so I > must do that process in the frequency domain.Why do you want a window at all? Windows are applied to blocks of data. The SFFT is usually applied to streaming data. What is your plan? ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●April 4, 20092009-04-04

On 4 Apr, 22:12, Eric Jacobsen <eric.jacob...@ieee.org> wrote:> On Sat, 4 Apr 2009 10:48:09 -0700 (PDT), Rune Allnor > > <all...@tele.ntnu.no> wrote: > >On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote: > >> Hello there, > >> I'm currently working on a pitch identification program in MATLAB. �It > >> uses the Sliding DFT so I need to apply windowing functions in the > >> frequency domain. > > >Ouch... I am not aware of a single application where > >windows are applied in frequency domain... > > Just as an example, when doing fast convolution or fast correlation > with FT-mult-FT applying the window function as part of the > inter-transform multiplication (which is in the frequency domain if > the signals are in the time domain) controls the sidelobe levels in > the output.Are we talking about the same thing? The OP wants - rightly or wrongly - to do a convolution in frequency domain. The numbers he states are similar (I'm not sure they are equal [*]) to a standard window. This is equivalent to the usual element-wise multiplication of the contents of a time-domain segment prior to the DFT. As far as i can tell, the OP chooses the computationally expensive alternative to the usual window weighting? I can see no reason, formally or computationally, to start messing around in frequency domain? Rune [*] The amplitudes of the sinusoidals are similar to the usual window function, but I think there are some 1/(N-1) terms in the arguments to the cosines that 'spreads' the window frequency function across all N coefficients.

Reply by ●April 4, 20092009-04-04

On Apr 4, 2:13 pm, Rune Allnor <all...@tele.ntnu.no> wrote:> On 4 Apr, 22:12, Eric Jacobsen <eric.jacob...@ieee.org> wrote: > > > > > On Sat, 4 Apr 2009 10:48:09 -0700 (PDT), Rune Allnor > > > <all...@tele.ntnu.no> wrote: > > >On 4 Apr, 18:28, "OldUncleSilas" <gibbering.babo...@gmail.com> wrote: > > >> Hello there, > > >> I'm currently working on a pitch identification program in MATLAB. It > > >> uses the Sliding DFT so I need to apply windowing functions in the > > >> frequency domain. > > > >Ouch... I am not aware of a single application where > > >windows are applied in frequency domain... > > > Just as an example, when doing fast convolution or fast correlation > > with FT-mult-FT applying the window function as part of the > > inter-transform multiplication (which is in the frequency domain if > > the signals are in the time domain) controls the sidelobe levels in > > the output. > > Are we talking about the same thing? The OP wants - rightly or > wrongly - to do a convolution in frequency domain. The numbers he > states are similar (I'm not sure they are equal [*]) to a standard > window. > This is equivalent to the usual element-wise multiplication of > the contents of a time-domain segment prior to the DFT. > > As far as i can tell, the OP chooses the computationally expensive > alternative to the usual window weighting? I can see no reason, > formally or computationally, to start messing around in frequency > domain? > > Rune > > [*] The amplitudes of the sinusoidals are similar to the usual > window function, but I think there are some 1/(N-1) terms > in the arguments to the cosines that 'spreads' the window > frequency function across all N coefficients.The values the OP suggests are the frequency domain coefficients for the von Hann window. An example of these is given in the harris paper on page 62: http://web.mit.edu/xiphmont/Public/windows.pdf As harris points out, one of the advantages of the von Hannn window in the frequency domain is that it is applied with only binary shifts and adds instead of the expensive multiplies required in the time domain. An appendix to the harris paper demonstrates the equivalence of windowing in frequency and time domains. The commonly used frequency domain windows are those "cosine summed" windows that require a relatively small number of terms to be summed in the frequency domain convolution. Frequency domain windowing may be preferable when data is more readily available in the frequency domain as in the OP's case, where more than one window type is desired and can be provided without performing an additional FFT for each additional window, and in the cases where the frequency domain implementation can be more efficient as is the case with low level implementation of von Hann weighting. Dale B. Dalrymple