When using the assembly-optimized dsplib library on the OMAP-L138 LCDK, I encounter a quirk with subsequent calls to DSPF_sp_cfftr2_dit and DSPF_sp_icfftr2_dif. The API states that the twiddle factors should be bit-reversed; however upon performing this action to both the transform and inverse twiddle factors, there is distortion present in an N=32 sized transform. If the twiddle factors are passed non-bit-reversed in back-to-back transform/inverse calls, this distortion is not present. Why might this be the case? Code snippet is as follows, for context:
FFT operations within ISR:
// Extract data (complex) from input framebuffer for (i=0; i < BUFFER_COUNT; i++) { // Populate input sample arrays inpLcpx[2*i] = Left[i]; inpLcpx[2*i+1] = 0.0; inpRcpx[2*i] = Right[i]; inpRcpx[2*i+1] = 0.0; } // Calculate FFT using call to optimized-assembly DSPF_sp_cffrt2_dit DSPF_sp_cfftr2_dit(inpLcpx, twiddle, BUFFER_COUNT); DSPF_sp_cfftr2_dit(inpRcpx, twiddle, BUFFER_COUNT); // Calculate IFFT using call to optimized-assembly DSPF_sp_icfftr2_dif DSPF_sp_icfftr2_dif(inpLcpx, twiddleInv, BUFFER_COUNT); DSPF_sp_icfftr2_dif(inpRcpx, twiddleInv, BUFFER_COUNT); // Then pack real data into output framebuffer
Twiddle factors are generated as follows. Call is to method defined within ISR, from main:
void twidInit() { int i=0; float a = 2.0f*PI/BUFFER_COUNT; for (i=0; i < BUFFER_COUNT; i+=2) { // Populate twiddle factors twiddle[i] = cosf(-(i/2)*a); twiddle[i+1] = -sinf(-(i/2)*a); twiddleInv[i] = cosf((i/2)*a); twiddleInv[i+1] = -sinf(-(i/2)*a); } }