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);
How to do FFT and IFFT to get original signal?? Topic is solved

 Member++
 Posts: 26
 Joined: Tue Jul 02, 2019 8:38 am

 Respected Member
 Posts: 365
 Joined: Wed May 31, 2017 6:55 pm
See the example project app_fft in the xCORE200 DSP Elements Library [AN00209] which does that.
I can't see any code for dsp_fft_bit_reverse_and_forward_real.
I can't see any code for dsp_fft_bit_reverse_and_forward_real.

 Member++
 Posts: 26
 Joined: Tue Jul 02, 2019 8:38 am
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);
}

 Respected Member
 Posts: 365
 Joined: Wed May 31, 2017 6:55 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?
Look at the descriptions of the functions in dsp_fft.h. Are your sine parameters in the right order?

 Member++
 Posts: 26
 Joined: Tue Jul 02, 2019 8:38 am
Yes. My version is 4.2 from github. And the Sine parameter is provided by official in dsp_tables.cCousinItt 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?

 Respected Member
 Posts: 365
 Joined: Wed May 31, 2017 6:55 pm
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:
You're passing dsp_sine_128 first.
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.

 Member++
 Posts: 26
 Joined: Tue Jul 02, 2019 8:38 am
Yes. I can confirm it is right.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:
You're passing dsp_sine_128 first.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.
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);