How to do FFT and IFFT to get original signal?? Topic is solved

Voice related projects and technical discussions
Post Reply
link0513
Member++
Posts: 26
Joined: Tue Jul 02, 2019 8:38 am

How to do FFT and IFFT to get original signal??

Post by link0513 »

Hi, There is a problem about FFT and IFFT.
Using dsp_fft_bit_reverse_and_forward_real() function can get the frequency spectrum but using its result for dsp_fft_bit_reverse_and_inverse_real() function can't get the original signal. It seem is lack of the signal phase message. So where I can get the information of the phase and to recover the original signal?

Below is the code:
dsp_fft_bit_reverse_and_forward_real(sample,128,dsp_sine_128,dsp_sine_64);
dsp_fft_bit_reverse_and_inverse_real(sample,128,dsp_sine_128,dsp_sine_64);


View Solution
User avatar
CousinItt
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

See the example project app_fft in the xCORE-200 DSP Elements Library [AN00209] which does that.

I can't see any code for dsp_fft_bit_reverse_and_forward_real.
link0513
Member++
Posts: 26
Joined: Tue Jul 02, 2019 8:38 am

Post by link0513 »

CousinItt wrote: Fri Jul 05, 2019 12:01 pm See the example project app_fft in the xCORE-200 DSP Elements Library [AN00209] which does that.

I can't see any code for dsp_fft_bit_reverse_and_forward_real.
the code is in the official file dsp_fft_real.xc, and compare the main code to the example is the same operation.

void dsp_fft_bit_reverse_and_forward_real (
int32_t pts[],
const uint32_t N,
const int32_t sine[],
const int32_t sin2[] ) {

dsp_fft_bit_reverse((pts, dsp_complex_t[]), N>>1);
dsp_fft_forward((pts, dsp_complex_t[]), N>>1, sine);
dsp_fft_real_fix_forward_xs2((pts, dsp_complex_t[]), N>>1, sin2);

}


void dsp_fft_bit_reverse_and_inverse_real (
int32_t pts[],
const uint32_t N,
const int32_t sine[],
const int32_t sin2[] ) {
dsp_fft_real_fix_inverse_xs2((pts, dsp_complex_t[]), N>>1, sin2);
dsp_fft_bit_reverse((pts, dsp_complex_t[]), N>>1);
dsp_fft_inverse((pts, dsp_complex_t[]), N>>1, sine);

}
User avatar
CousinItt
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Right, I think you're using a version of dsp_lib from github. The official version is 3.1.0 according to the xmos site; that's the newest version my installation of xtimecomposer can see.

Look at the descriptions of the functions in dsp_fft.h. Are your sine parameters in the right order?
link0513
Member++
Posts: 26
Joined: Tue Jul 02, 2019 8:38 am

Post by link0513 »

CousinItt wrote: Mon Jul 08, 2019 6:26 pm Right, I think you're using a version of dsp_lib from github. The official version is 3.1.0 according to the xmos site; that's the newest version my installation of xtimecomposer can see.

Look at the descriptions of the functions in dsp_fft.h. Are your sine parameters in the right order?
Yes. My version is 4.2 from github. And the Sine parameter is provided by official in dsp_tables.c
User avatar
CousinItt
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

I meant are you passing the sine and sin2 parameters in the right order. The comments in dsp_fft.h for dsp_fft_bit_reverse_and_forward_real says:

Code: Select all

 * \param[in,out] pts   Array of N integers (in) array of N/2 dsp_complex_t
 *                      elements (out)
 * \param[in]     N     Number of points. Must be a power of two.
 * \param[in]     sine  Array of N/8+1 sine values, each represented as a 
 *                      sign bit and a 31 bit fraction. 1.0 is represented
 *                      by 0x7fffffff.
 *                      Arrays are provided in dsp_tables.c.
 *                      For example, for a 1024 point FFT use dsp_sine_512.
 * \param[in]     sin2  Array of N/4+1 sine values, represented as above.
 *                      For example, for a 1024 point FFT use dsp_sine_1024.
You're passing dsp_sine_128 first.
link0513
Member++
Posts: 26
Joined: Tue Jul 02, 2019 8:38 am

Post by link0513 »

CousinItt wrote: Tue Jul 09, 2019 11:20 am I meant are you passing the sine and sin2 parameters in the right order. The comments in dsp_fft.h for dsp_fft_bit_reverse_and_forward_real says:

Code: Select all

 * \param[in,out] pts   Array of N integers (in) array of N/2 dsp_complex_t
 *                      elements (out)
 * \param[in]     N     Number of points. Must be a power of two.
 * \param[in]     sine  Array of N/8+1 sine values, each represented as a 
 *                      sign bit and a 31 bit fraction. 1.0 is represented
 *                      by 0x7fffffff.
 *                      Arrays are provided in dsp_tables.c.
 *                      For example, for a 1024 point FFT use dsp_sine_512.
 * \param[in]     sin2  Array of N/4+1 sine values, represented as above.
 *                      For example, for a 1024 point FFT use dsp_sine_1024.
You're passing dsp_sine_128 first.
Yes. I can confirm it is right.

Below is the code:
dsp_fft_bit_reverse_and_forward_real(sample,128,dsp_sine_128,dsp_sine_64);
dsp_fft_bit_reverse_and_inverse_real(sample,128,dsp_sine_128,dsp_sine_64);
Post Reply