DSPRelated.com
Forums

Frequency Domain Convolution

Started by sandwich_20082001 August 5, 2008
Hi all this is my first post,

I was looking for some help with frequnecy domain convolution.

>From what I understand multiplication in the time domain is equivalent
to convolution in the frequency domain and vice versa.

What I would like to do is produce the same frequency spectrum
produced by hann windowed audio (in the time domain), which is done
through time domain multiplication, but I would like to do this by
taking the unwindowed audio frequnecy spectrum and convolving it in
the frequnecy domain with the frequnecy spectrum of the hann window.

If a hann window of length A and an audio frame of length B are
convolved the the result length will be A+B-1.

I am using Matlab and convolving A and B (frequency spectrums) and
taking the IFFT This does not produce the same result as time domain
multipliction. The most obvious problem being there are A+B-1 samples
and not A samples.

Basically my question is how do I hann window audio in the frequency
domain.

Any help much appreciated.

Thanks

J
Hello JThe frequency domain convolution kernel for a von Hann window is particularly simple because it is a symmetric sum of cosines window. It is:

h = [-0.5 1 -0.5]
independent of the length of the time domain window. Regarding the length of the convolution: you have to use circular convolution in the frequency domain to get proper time domain windowing. This won't change the length of the frequency domain signal vector. I'm not sure if Matlab has a circular convolution function.

Regards,
Andor

To: a...From: j...@york.ac.ukDate: Mon, 4 Aug 2008 13:16:22 +0000Subject: [audiodsp] Frequency Domain Convolution

Hi all this is my first post,I was looking for some help with frequnecy domain convolution.From what I understand multiplication in the time domain is equivalentto convolution in the frequency domain and vice versa.What I would like to do is produce the same frequency spectrumproduced by hann windowed audio (in the time domain), which is donethrough time domain multiplication, but I would like to do this bytaking the unwindowed audio frequnecy spectrum and convolving it inthe frequnecy domain with the frequnecy spectrum of the hann window.If a hann window of length A and an audio frame of length B areconvolved the the result length will be A+B-1.I am using Matlab and convolving A and B (frequency spectrums) andtaking the IFFT This does not produce the same result as time domainmultipliction. The most obvious problem being there are A+B-1 samplesand not A samples.Basically my question is how do I hann window audio in the frequencydomain.Any help much appreciated.ThanksJ
Hi J

You have to convolve with [-0.5 1 0.5]. You don't need to zero pad (because the zero coefficients won't affect the convolution sum). As an example, if your frequency domain signal looks like this (N=8):

[A0; A1; A2; A3; A4; A5; A6; A7]

then the circularly convolved vector will look like this:
[-0.5 A7+A0-0.5 A1; -0.5 A0+A1-0.5 A2; ....; -0.5 A6+A7-0.5 A0]

Regards,
Andor

> Date: Wed, 6 Aug 2008 23:04:09 +0100> From: j...@york.ac.uk> To: a...@hotmail.com> Subject: Re: [audiodsp] Frequency Domain Convolution> > Hi Andor,> > Thankyou very much for your response. I understand how circular > convolution is performed so I think I have an idea of how to implement > it. I would just like to ask you a few questions about the information > you have given.> > Do I convolve the audio spectrum with [-0.5 1 -0.5] or the FFT of [-0.5 > 1 -0.5]? Are the real and imaginary parts convolved separately? Or how > would I convolve [-0.5 1 -0.5] with a complex value spectrum?> > Presumably I should zero pad [-0.5 1 -0.5] to match the the size of the > audio frequency spectrum.> > eg (In the case of a window size of 8)> > [-0.5 1 -0.5 0 0 0 0 0 0]> > then for the 2nd circular convolution calculation this would change to> > [0 -0.5 1 -0.5 0 0 0 0 0 ]> > Regards,> J> > Andor Bariska wrote:> > Hello J> >> > The frequency domain convolution kernel for a von Hann window is > > particularly simple because it is a symmetric sum of cosines window. > > It is:> > > > h = [-0.5 1 -0.5]> >> > independent of the length of the time domain window. Regarding the > > length of the convolution: you have to use circular convolution in the > > frequency domain to get proper time domain windowing. This won't > > change the length of the frequency domain signal vector. I'm not sure > > if Matlab has a circular convolution function.> > > > Regards,> > Andor> >> > > >> > To: a...> > From: j...@york.ac.uk> > Date: Mon, 4 Aug 2008 13:16:22 +0000> > Subject: [audiodsp] Frequency Domain Convolution> >> >> > Hi all this is my first post,> >> > I was looking for some help with frequnecy domain convolution.> >> > From what I understand multiplication in the time domain is equivalent> > to convolution in the frequency domain and vice versa.> >> > What I would like to do is produce the same frequency spectrum> > produced by hann windowed audio (in the time domain), which is done> > through time domain multiplication, but I would like to do this by> > taking the unwindowed audio frequnecy spectrum and convolving it in> > the frequnecy domain with the frequnecy spectrum of the hann window.> >> > If a hann window of length A and an audio frame of length B are> > convolved the the result length will be A+B-1.> >> > I am using Matlab and convolving A and B (frequency spectrums) and> > taking the IFFT This does not produce the same result as time domain> > multipliction. The most obvious problem being there are A+B-1 samples> > and not A samples.> >> > Basically my question is how do I hann window audio in the frequency> > domain.> >> > Any help much appreciated.> >> > Thanks> >> > J> >> >> > > >
There seem to be two problems. First, it looks like I was off by a factor of two for the kernel. Second, you probably didn't use the 'periodic' switch for the Hann window. Try this:

x=sin(2*pi*1000/44100*(0:7)');
h=hann(8,'periodic');y=x.*h;

Xt(x);
Yt(y);

-0.25*X(8)+0.5*X(1)-0.25*X(2) - Y(1)
-0.25*X(1)+0.5*X(2)-0.25*X(3) - Y(2)

etc.

Regards,
Andor

> Date: Thu, 7 Aug 2008 17:28:24 +0100> From: j...@york.ac.uk> To: a...@hotmail.com> Subject: Re: [audiodsp] Frequency Domain Convolution> > Hi Andor> > I'm not quite sure how this would work. Consider this example I am > working with;> > Complex Spectrum of a 1kHz sine wave multiplied by a hann window in time > domain (8 samples).> > I will call this spectrum A,> > Columns 1 through 4> > 1.4018, -0.8980 - 0.0381i , 0.1694 - 0.0275i, 0.0250 + > 0.0126i,> > Columns 5 through 8> > 0.0055 0.0250 - 0.0126i, 0.1694 + 0.0275i , -0.8980 + > 0.0381i> > Complex spectrum of a sine wave with no windowing> > I will call this spectrum B> > Columns 1 through 4> > 3.0856 -0.5111 + 0.9669i, -0.4222 + 0.3906i, -0.4074 + > 0.1611i,> > Columns 5 through 8> > -0.4043 -0.4074 - 0.1611i, -0.4222 - 0.3906i, -0.5111 - > 0.9669i> > So, with convolution I would like to make spectrum A from spectrum B.> > From your example I should be able to calculate the 0th bin as follows> > -0.5*(-0.5111 - 0.9669i) + (3.0856) - 0.5*(-0.5111 + 0.9669i)> > =3.5966> > The whole spectrum would infact be> > Columns 1 through 4> > 3.5966 -1.8428 + 0.7716i 0.0370 - 0.1734i 0.0058 - 0.0342i> > Columns 5 through 8> > 0.0031 0.0058 + 0.0342i 0.0370 + 0.1734i -1.8428 - 0.7716i> > This spectrum does not match with spectrum A. I think I must have > missed something? Is this the correct way of doing things?> > Regards,> J> > > Andor Bariska wrote:> >> > Hi J> >> > You have to convolve with [-0.5 1 0.5]. You don't need to zero pad > > (because the zero coefficients won't affect the convolution sum). As > > an example, if your frequency domain signal looks like this (N=8):> >> > [A0; A1; A2; A3; A4; A5; A6; A7]> >> > then the circularly convolved vector will look like this:> > [-0.5 A7+A0-0.5 A1; -0.5 A0+A1-0.5 A2; ....; -0.5 A6+A7-0.5 A0]> >> > Regards,> > Andor