blob: d4970b6b357e1a96b58be9ff68d8c220f60df298 [file] [log] [blame]
*X - real data
*X - complex data
*X - complex data
*...
*X[fftLen/2-1] - complex data
*X[fftLen/2] - real data
*X[fftLen/2+1] - conjugate of X[fftLen/2-1]
*X[fftLen/2+2] - conjugate of X[fftLen/2-2]
*...
*X[fftLen-1] - conjugate of X
*
* Looking at the data, we see that we can uniquely represent the FFT using only *
*N/2+1 samples:
*X - real data
*X - complex data
*X - complex data
*...
*X[fftLen/2-1] - complex data
*X[fftLen/2] - real data
*
* Looking more closely we see that the first and last samples are real valued. * They can be packed together and we can thus represent the FFT of an N-point * real sequence by N/2 complex values: *
*X,X[N/2] - packed real data: X + jX[N/2]
*X - complex data
*X - complex data
*...
*X[fftLen/2-1] - complex data
*
* The real FFT functions pack the frequency domain data in this fashion. The * forward transform outputs the data in this form and the inverse transform * expects input data in this form. The function always performs the needed * bitreversal so that the input and output data is always in normal order. The * functions support lengths of [32, 64, 128, ..., 4096] samples. * \par * The forward and inverse real FFT functions apply the standard FFT scaling; no * scaling on the forward transform and 1/fftLen scaling on the inverse * transform. * \par Q15 and Q31 * The real algorithms are defined in a similar manner and utilize N/2 complex * transforms behind the scenes. * \par * The complex transforms used internally include scaling to prevent fixed-point * overflows. The overall scaling equals 1/(fftLen/2). * \par * A separate instance structure must be defined for each transform used but * twiddle factor and bit reversal tables can be reused. * \par * There is also an associated initialization function for each data type. * The initialization function performs the following operations: * - Sets the values of the internal structure fields. * - Initializes twiddle factor table and bit reversal table pointers. * - Initializes the internal complex FFT data structure. * \par * Use of the initialization function is optional. * However, if the initialization function is used, then the instance structure * cannot be placed into a const data section. To place an instance structure * into a const data section, the instance structure should be manually * initialized as follows: *
*arm_rfft_instance_q31 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
*arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
*
* where fftLenReal is the length of the real transform; * fftLenBy2 length of the internal complex transform. * ifftFlagR Selects forward (=0) or inverse (=1) transform. * bitReverseFlagR Selects bit reversed output (=0) or normal order * output (=1). * twidCoefRModifier stride modifier for the twiddle factor table. * The value is based on the FFT length; * pTwiddleARealpoints to the A array of twiddle coefficients; * pTwiddleBRealpoints to the B array of twiddle coefficients; * pCfft points to the CFFT Instance structure. The CFFT structure * must also be initialized. Refer to arm_cfft_radix4_f32() for details regarding * static initialization of the complex FFT instance structure. */ /** * @addtogroup RealFFT * @{ */ /** * @brief Processing function for the floating-point real FFT. * @param[in] *S points to an arm_rfft_fast_instance_f32 structure. * @param[in] *p points to the input buffer. * @param[in] *pOut points to the output buffer. * @param[in] ifftFlag RFFT if flag is 0, RIFFT if flag is 1 * @return none. */ void arm_rfft_fast_f32( arm_rfft_fast_instance_f32 * S, float32_t * p, float32_t * pOut, uint8_t ifftFlag) { arm_cfft_instance_f32 * Sint = &(S->Sint); Sint->fftLen = S->fftLenRFFT / 2; /* Calculation of Real FFT */ if(ifftFlag) { /* Real FFT compression */ merge_rfft_f32(S, p, pOut); /* Complex radix-4 IFFT process */ arm_cfft_f32( Sint, pOut, ifftFlag, 1); } else { /* Calculation of RFFT of input */ arm_cfft_f32( Sint, p, ifftFlag, 1); /* Real FFT extraction */ stage_rfft_f32(S, p, pOut); } } /** * @} end of RealFFT group */