Reply by Mike Rosing August 7, 20092009-08-07
Howdy Saba,

What you are missing is the phase relationship. The IFFT assumes all the
phases start at zero, which is a false assumption. So the result is
totally different in terms of time domain.

If you listen to the sample it will sound pretty close to the original,
but it's so short it'd be hard to really tell. It will be dispersion
shifted (as if the sound went through a phase shift medium).

To correct for that you need the imaginary component to start with. The
idea behind using the imaginary component to help with efficiency makes
the assumption you don't need to go backwards - it assumes phase
information is not relevant. Usually that's the case when you are looking
for a particular frequency or band of frequencies. But in this case, you
want to recover the original signal, so what you want to do is fill in the
imaginary part with zeros and use the full complex result for the inverse.
That should maintain the phase relationship between all the frequency
components.

But it will still be wrong to some extent because there is an implied sync
filter in both the FFT and IFFT. They don't cancel, they add. That's why
people add the cosine filter before computing the overlap - it reduces the
effect of mismatch at the boundaries.

One way to see how this works is to feed in pure tones. Take a sine wave
with 0, 45 and 135 degree phase shifts and feed it into your routine.
Watch what comes out with no imaginary component, and an all zero
imaginary component. Look at the IFFT of each version and compare it to
the original. By starting with a pure tone and seeing how all the changes
happen, the results you are getting will make a lot more sense.

Patience, persistence, truth,
Dr. mike

On Thu, 6 Aug 2009, Saba Taseer wrote:

>
> The problem that I am facing is that if I take fft of 512 samples and then take ifft immediately without changing anything, the amplitudes of the result and the input are not matching. I also changed the code to use overlap-add method. Length of the input buffers is 1432 in total.
>
> block_exponentt1024(SPORT0_Tx_Buffer_1, SPORT0_Tx_Buffer_1+408, real_output, SPORT0_Rx_Buffer_1);
>
> block_exponent=ifft1024(real_output, SPORT0_Rx_Buffer_1, SPORT0_Tx_Buffer_1, imag_out_i);
>
> for(i@8;i<1024;i++)
> SPORT0_Tx_Buffer_1[i]=SPORT0_Tx_Buffer_1[i]+imag_out_i[i-408];
> for(i;i<1432;i++)
> SPORT0_Tx_Buffer_1[i]=imag_out_i[i-408];
> The input is real so instead of inputting the imaginary partm I input the other overlapping part of the signal. I read on the internet that we can optimize the code htis way. Then for the output I simply add the overlapping indexes. Do I need to take care of block_exponent in someway? Even of I just take 1024 point fft of the first 1024 values in the buffer, and then take ifft, the values dont match. What am I missing here?
> Thanks and Regards,
> Saba Taseer
Reply by Saba Taseer August 6, 20092009-08-06
The problem that I am facing is that if I take fft of 512 samples and then take ifft immediately without changing anything, the amplitudes of the result and the input are not matching. I also changed the code to use overlap-add method. Length of the input buffers is 1432 in total.

block_exponentt1024(SPORT0_Tx_Buffer_1, SPORT0_Tx_Buffer_1+408, real_output, SPORT0_Rx_Buffer_1);

block_exponent=ifft1024(real_output, SPORT0_Rx_Buffer_1, SPORT0_Tx_Buffer_1, imag_out_i);

for(i@8;i<1024;i++)
SPORT0_Tx_Buffer_1[i]=SPORT0_Tx_Buffer_1[i]+imag_out_i[i-408];
for(i;i<1432;i++)
SPORT0_Tx_Buffer_1[i]=imag_out_i[i-408];
The input is real so instead of inputting the imaginary partm I input the other overlapping part of the signal. I read on the internet that we can optimize the code htis way. Then for the output I simply add the overlapping indexes. Do I need to take care of block_exponent in someway? Even of I just take 1024 point fft of the first 1024 values in the buffer, and then take ifft, the values dont match. What am I missing here?
Thanks and Regards,
Saba Taseer

To: s...@hotmail.com
CC: a...
From: e...@eskimo.com
Date: Wed, 5 Aug 2009 20:43:55 -0700
Subject: Re: [adsp] FFT and ifft with block exponent

You don't have a good match of filter. By adding zeros to the third
buffer you are changing the input significantly, and by chopping the
signal with no overlap you are using a sync filter which gives lots of
nasty harmonics. The fouier transform of a square pulse is a sync
function, and the filter you are using is a square block in time. If you
overlap the samples and multiply by a cosine or other filter (see Blackman
window) you will get a much cleaner result.

Look up "overlap add method". That will help you a lot.

Patience, persistence, truth,
Dr. mike

On Wed, 5 Aug 2009, s...@hotmail.com wrote:

> I am trying to take fft of an audio signal. The buffer length is 1432, so I take 3 FFTs of 512 length each, padding zeros for last execution. This is just the start so I am taking FFT and then IFFT and play the audio. The problem is that I am not able to get the sound back. The is rhythemic sound in the output. The noise is so high that I am seldom able to hear the original audio, but it is there. The example code is pasted below. The commented code shows the things tht I have tried to take the block exponent in consideration.
> block_exponentt512(SPORT0_Tx_Buffer_1, imag_in, real_output, imag_output);
>
> /*for(i=0;i<512;i++)
> {
> real_output[i]=real_output[i]>>(block_exponent);
> imag_output[i]=imag_output[i]>>(block_exponent);
> }
> block_exponent=ifft512(real_output, imag_output, SPORT0_Tx_Buffer_1, imag_out_i);
> for(i=0;i<512;i++)
> SPORT0_Tx_Buffer_1[i]=SPORT0_Tx_Buffer_1[i]>>(block_exponent);
>
> I want to know how can I get the real audio back. What is missing here?
> Thanks and Regards,
> Saba
>

_________________________________________________________________
Get free photo software from Windows Live
http://www.windowslive.com/online/photos?ocid=PID23393::T:WLMTAGL:ON:WL:en-US:SI_PH_software:082009
Reply by Mike Rosing August 6, 20092009-08-06
You don't have a good match of filter. By adding zeros to the third
buffer you are changing the input significantly, and by chopping the
signal with no overlap you are using a sync filter which gives lots of
nasty harmonics. The fouier transform of a square pulse is a sync
function, and the filter you are using is a square block in time. If you
overlap the samples and multiply by a cosine or other filter (see Blackman
window) you will get a much cleaner result.

Look up "overlap add method". That will help you a lot.

Patience, persistence, truth,
Dr. mike

On Wed, 5 Aug 2009, s...@hotmail.com wrote:

> I am trying to take fft of an audio signal. The buffer length is 1432, so I take 3 FFTs of 512 length each, padding zeros for last execution. This is just the start so I am taking FFT and then IFFT and play the audio. The problem is that I am not able to get the sound back. The is rhythemic sound in the output. The noise is so high that I am seldom able to hear the original audio, but it is there. The example code is pasted below. The commented code shows the things tht I have tried to take the block exponent in consideration.
> block_exponentt512(SPORT0_Tx_Buffer_1, imag_in, real_output, imag_output);
>
> /*for(i=0;i<512;i++)
> {
> real_output[i]=real_output[i]>>(block_exponent);
> imag_output[i]=imag_output[i]>>(block_exponent);
> }
> block_exponent=ifft512(real_output, imag_output, SPORT0_Tx_Buffer_1, imag_out_i);
> for(i=0;i<512;i++)
> SPORT0_Tx_Buffer_1[i]=SPORT0_Tx_Buffer_1[i]>>(block_exponent);
>
> I want to know how can I get the real audio back. What is missing here?
> Thanks and Regards,
> Saba
>
Reply by steh...@hotmail.com August 5, 20092009-08-05
I am trying to take fft of an audio signal. The buffer length is 1432, so I take 3 FFTs of 512 length each, padding zeros for last execution. This is just the start so I am taking FFT and then IFFT and play the audio. The problem is that I am not able to get the sound back. The is rhythemic sound in the output. The noise is so high that I am seldom able to hear the original audio, but it is there. The example code is pasted below. The commented code shows the things tht I have tried to take the block exponent in consideration.
block_exponentt512(SPORT0_Tx_Buffer_1, imag_in, real_output, imag_output);

/*for(i=0;i<512;i++)
{
real_output[i]=real_output[i]>>(block_exponent);
imag_output[i]=imag_output[i]>>(block_exponent);
}
block_exponent=ifft512(real_output, imag_output, SPORT0_Tx_Buffer_1, imag_out_i);
for(i=0;i<512;i++)
SPORT0_Tx_Buffer_1[i]=SPORT0_Tx_Buffer_1[i]>>(block_exponent);

I want to know how can I get the real audio back. What is missing here?
Thanks and Regards,
Saba