CMSIS-DSP  Verison 1.1.0
CMSIS DSP Software Library
Real FFT Functions

Variables

static const float32_t realCoefA [8192]
static const float32_t realCoefB [8192]
static const q15_t ALIGN4 realCoefAQ15 [8192]
static const q15_t ALIGN4 realCoefBQ15 [8192]
static const q31_t realCoefAQ31 [8192]
static const q31_t realCoefBQ31 [8192]

Functions

void arm_rfft_f32 (const arm_rfft_instance_f32 *S, float32_t *pSrc, float32_t *pDst)
 Processing function for the floating-point RFFT/RIFFT.
arm_status arm_rfft_init_f32 (arm_rfft_instance_f32 *S, arm_cfft_radix4_instance_f32 *S_CFFT, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag)
 Initialization function for the floating-point RFFT/RIFFT.
arm_status arm_rfft_init_q15 (arm_rfft_instance_q15 *S, arm_cfft_radix4_instance_q15 *S_CFFT, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag)
 Initialization function for the Q15 RFFT/RIFFT.
arm_status arm_rfft_init_q31 (arm_rfft_instance_q31 *S, arm_cfft_radix4_instance_q31 *S_CFFT, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag)
 Initialization function for the Q31 RFFT/RIFFT.
void arm_rfft_q15 (const arm_rfft_instance_q15 *S, q15_t *pSrc, q15_t *pDst)
 Processing function for the Q15 RFFT/RIFFT.
void arm_rfft_q31 (const arm_rfft_instance_q31 *S, q31_t *pSrc, q31_t *pDst)
 Processing function for the Q31 RFFT/RIFFT.

Description

Complex FFT/IFFT typically assumes complex input and output. However many applications use real valued data in time domain. Real FFT/IFFT efficiently process real valued sequences with the advantage of requirement of low memory and with less complexity.
This set of functions implements Real Fast Fourier Transforms(RFFT) and Real Inverse Fast Fourier Transform(RIFFT) for Q15, Q31, and floating-point data types.
Algorithm:

Real Fast Fourier Transform:

Real FFT of N-point is calculated using CFFT of N/2-point and Split RFFT process as shown below figure.
RFFT.gif
Real Fast Fourier Transform
The RFFT functions operate on blocks of input and output data and each call to the function processes fftLenR samples through the transform. pSrc points to input array containing fftLenR values. pDst points to output array containing 2*fftLenR values.
Input for real FFT is in the order of
{real[0], real[1], real[2], real[3], ..}
Output for real FFT is complex and are in the order of
{real(0), imag(0), real(1), imag(1), ...}

Real Inverse Fast Fourier Transform:

Real IFFT of N-point is calculated using Split RIFFT process and CFFT of N/2-point as shown below figure.
RIFFT.gif
Real Inverse Fast Fourier Transform
The RIFFT functions operate on blocks of input and output data and each call to the function processes 2*fftLenR samples through the transform. pSrc points to input array containing 2*fftLenR values. pDst points to output array containing fftLenR values.
Input for real IFFT is complex and are in the order of
{real(0), imag(0), real(1), imag(1), ...}
Output for real IFFT is real and in the order of
{real[0], real[1], real[2], real[3], ..}
Lengths supported by the transform:
Real FFT/IFFT supports the lengths [128, 512, 2048], as it internally uses CFFT/CIFFT.
Instance Structure
A separate instance structure must be defined for each Instance but the twiddle factors can be reused. There are separate instance structure declarations for each of the 3 supported data types.
Initialization Functions
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 tables.
  • Initializes CFFT data structure fields.
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 must be manually initialized. Manually initialize the instance structure as follows:
    
arm_rfft_instance_f32 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};    
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 length of RFFT/RIFFT; fftLenBy2 length of CFFT/CIFFT. ifftFlagR Flag for selection of RFFT or RIFFT(Set ifftFlagR to calculate RIFFT otherwise calculates RFFT); bitReverseFlagR Flag for selection of output order(Set bitReverseFlagR to output in normal order otherwise output in bit reversed order); twidCoefRModifier modifier for twiddle factor table which supports 128, 512, 2048 RFFT lengths with same table; pTwiddleARealpoints to A array of twiddle coefficients; pTwiddleBRealpoints to B array of twiddle coefficients; pCfft points to the CFFT Instance structure. The CFFT structure also needs to be initialized, refer to arm_cfft_radix4_f32() for details regarding static initialization of cfft structure.
Fixed-Point Behavior
Care must be taken when using the fixed-point versions of the RFFT/RIFFT function. Refer to the function specific documentation below for usage guidelines.

Variable Documentation

const float32_t realCoefA[8192] [static]
Generation of realCoefA array:
n = 4096
for (i = 0; i < n; i++)    
  {    
    pATable[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) (2 * n) * (double) i));    
    pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
  } 

Referenced by arm_rfft_init_f32().

const q15_t ALIGN4 realCoefAQ15[8192] [static]
Generation floating point real_CoefA array:
n = 4096
for (i = 0; i < n; i++)    
  {    
    pATable[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) (2 * n) * (double) i));    
    pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
  } 
Convert to fixed point Q15 format round(pATable[i] * pow(2, 15))

Referenced by arm_rfft_init_q15().

const q31_t realCoefAQ31[8192] [static]
Generation floating point realCoefAQ31 array:
n = 4096
for (i = 0; i < n; i++)    
 {    
    pATable[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) (2 * n) * (double) i));    
    pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
 }
Convert to fixed point Q31 format round(pATable[i] * pow(2, 31))

Referenced by arm_rfft_init_q31().

const float32_t realCoefB[8192] [static]
Generation of realCoefB array:
n = 4096
for (i = 0; i < n; i++)    
 {    
    pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));    
    pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
  } 

Referenced by arm_rfft_init_f32().

const q15_t ALIGN4 realCoefBQ15[8192] [static]
Generation of real_CoefB array:
n = 4096
for (i = 0; i < n; i++)    
  {    
    pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));    
    pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
  } 
Convert to fixed point Q15 format round(pBTable[i] * pow(2, 15))

Referenced by arm_rfft_init_q15().

const q31_t realCoefBQ31[8192] [static]
Generation of realCoefBQ31 array:
n = 4096
for (i = 0; i < n; i++)    
 {    
    pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));    
    pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));    
 } 
Convert to fixed point Q31 format round(pBTable[i] * pow(2, 31))

Referenced by arm_rfft_init_q31().


Function Documentation

arm_status arm_rfft_init_f32 ( arm_rfft_instance_f32 S,
arm_cfft_radix4_instance_f32 S_CFFT,
uint32_t  fftLenReal,
uint32_t  ifftFlagR,
uint32_t  bitReverseFlag 
)
Parameters:
[in,out]*Spoints to an instance of the floating-point RFFT/RIFFT structure.
[in,out]*S_CFFTpoints to an instance of the floating-point CFFT/CIFFT structure.
[in]fftLenReallength of the FFT.
[in]ifftFlagRflag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
[in]bitReverseFlagflag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
Returns:
The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if fftLenReal is not a supported value.
Description:
The parameter fftLenReal Specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048.
The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated.
The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
This function also initializes Twiddle factor table.

References arm_cfft_radix4_init_f32(), ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, arm_rfft_instance_f32::bitReverseFlagR, arm_rfft_instance_f32::fftLenBy2, arm_rfft_instance_f32::fftLenReal, arm_rfft_instance_f32::ifftFlagR, arm_rfft_instance_f32::pCfft, arm_rfft_instance_f32::pTwiddleAReal, arm_rfft_instance_f32::pTwiddleBReal, realCoefA, realCoefB, status, and arm_rfft_instance_f32::twidCoefRModifier.

Referenced by arm_dct4_init_f32().

arm_status arm_rfft_init_q15 ( arm_rfft_instance_q15 S,
arm_cfft_radix4_instance_q15 S_CFFT,
uint32_t  fftLenReal,
uint32_t  ifftFlagR,
uint32_t  bitReverseFlag 
)
Parameters:
[in,out]*Spoints to an instance of the Q15 RFFT/RIFFT structure.
[in]*S_CFFTpoints to an instance of the Q15 CFFT/CIFFT structure.
[in]fftLenReallength of the FFT.
[in]ifftFlagRflag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
[in]bitReverseFlagflag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
Returns:
The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if fftLenReal is not a supported value.
Description:
The parameter fftLenReal Specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048.
The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated.
The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
This function also initializes Twiddle factor table.

References arm_cfft_radix4_init_q15(), ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, arm_rfft_instance_q15::bitReverseFlagR, arm_rfft_instance_q15::fftLenBy2, arm_rfft_instance_q15::fftLenReal, arm_rfft_instance_q15::ifftFlagR, arm_rfft_instance_q15::pCfft, arm_rfft_instance_q15::pTwiddleAReal, arm_rfft_instance_q15::pTwiddleBReal, realCoefAQ15, realCoefBQ15, status, and arm_rfft_instance_q15::twidCoefRModifier.

Referenced by arm_dct4_init_q15().

arm_status arm_rfft_init_q31 ( arm_rfft_instance_q31 S,
arm_cfft_radix4_instance_q31 S_CFFT,
uint32_t  fftLenReal,
uint32_t  ifftFlagR,
uint32_t  bitReverseFlag 
)
Parameters:
[in,out]*Spoints to an instance of the Q31 RFFT/RIFFT structure.
[in,out]*S_CFFTpoints to an instance of the Q31 CFFT/CIFFT structure.
[in]fftLenReallength of the FFT.
[in]ifftFlagRflag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform.
[in]bitReverseFlagflag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
Returns:
The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if fftLenReal is not a supported value.
Description:
The parameter fftLenReal Specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048.
The parameter ifftFlagR controls whether a forward or inverse transform is computed. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated.
The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
This function also initializes Twiddle factor table.

References arm_cfft_radix4_init_q31(), ARM_MATH_ARGUMENT_ERROR, ARM_MATH_SUCCESS, arm_rfft_instance_q31::bitReverseFlagR, arm_rfft_instance_q31::fftLenBy2, arm_rfft_instance_q31::fftLenReal, arm_rfft_instance_q31::ifftFlagR, arm_rfft_instance_q31::pCfft, arm_rfft_instance_q31::pTwiddleAReal, arm_rfft_instance_q31::pTwiddleBReal, realCoefAQ31, realCoefBQ31, status, and arm_rfft_instance_q31::twidCoefRModifier.

Referenced by arm_dct4_init_q31().

void arm_rfft_q15 ( const arm_rfft_instance_q15 S,
q15_t pSrc,
q15_t pDst 
)
Parameters:
[in]*Spoints to an instance of the Q15 RFFT/RIFFT structure.
[in]*pSrcpoints to the input buffer.
[out]*pDstpoints to the output buffer.
Returns:
none.
Input an output formats:
Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. Hence the output format is different for different RFFT sizes. The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT:
RFFTQ15.gif
Input and Output Formats for Q15 RFFT
RIFFTQ15.gif
Input and Output Formats for Q15 RIFFT

References arm_bitreversal_q15(), arm_radix4_butterfly_inverse_q15(), arm_radix4_butterfly_q15(), arm_split_rfft_q15(), arm_split_rifft_q15(), arm_rfft_instance_q15::bitReverseFlagR, arm_cfft_radix4_instance_q15::bitRevFactor, arm_cfft_radix4_instance_q15::fftLen, arm_rfft_instance_q15::fftLenBy2, arm_rfft_instance_q15::ifftFlagR, arm_cfft_radix4_instance_q15::pBitRevTable, arm_rfft_instance_q15::pCfft, arm_cfft_radix4_instance_q15::pTwiddle, arm_rfft_instance_q15::pTwiddleAReal, arm_rfft_instance_q15::pTwiddleBReal, arm_cfft_radix4_instance_q15::twidCoefModifier, and arm_rfft_instance_q15::twidCoefRModifier.

void arm_rfft_q31 ( const arm_rfft_instance_q31 S,
q31_t pSrc,
q31_t pDst 
)
Parameters:
[in]*Spoints to an instance of the Q31 RFFT/RIFFT structure.
[in]*pSrcpoints to the input buffer.
[out]*pDstpoints to the output buffer.
Returns:
none.
Input an output formats:
Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. Hence the output format is different for different RFFT sizes. The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT:
RFFTQ31.gif
Input and Output Formats for Q31 RFFT
RIFFTQ31.gif
Input and Output Formats for Q31 RIFFT

References arm_bitreversal_q31(), arm_radix4_butterfly_inverse_q31(), arm_radix4_butterfly_q31(), arm_split_rfft_q31(), arm_split_rifft_q31(), arm_rfft_instance_q31::bitReverseFlagR, arm_cfft_radix4_instance_q31::bitRevFactor, arm_cfft_radix4_instance_q31::fftLen, arm_rfft_instance_q31::fftLenBy2, arm_rfft_instance_q31::ifftFlagR, arm_cfft_radix4_instance_q31::pBitRevTable, arm_rfft_instance_q31::pCfft, arm_cfft_radix4_instance_q31::pTwiddle, arm_rfft_instance_q31::pTwiddleAReal, arm_rfft_instance_q31::pTwiddleBReal, arm_cfft_radix4_instance_q31::twidCoefModifier, and arm_rfft_instance_q31::twidCoefRModifier.

Referenced by arm_dct4_q31().