DSPRelated.com
Forums

URGENT FFT-qeustion !!!

Started by Marko Babic May 30, 2003
hello together,
 
I have a 4096-points function, containing 11 different  freqeunces and sampled with 8 kHz (CODEC on c6711dsk) ...
=>have to do FFT to find out this freqeunces...
 
I use the TI-cfftr2_dit.sa (with bitrev.sa and digitrev_index.sa)...
 
For test-purposes I created my own function like (64 times sin-wave):
    count=0;
    while(count<4096)
     {
       for(i=1; i<d; i++)  
        {
          kurvenwerte_array[count]= 1.0*sin(2.0*pi*(i-1)/64);
          count++;
        }
     }
 
So, my expected sin-Freq is 125 Hz !!!!!!!!!!!!
AND my problem is to find out the Index of this frequency in calculated fft-Magnitude-array (mag=sqrt(.re*.re + .im*.im) ),
as there are a lot of peaks in this array .....
 
Can anybody help me ??? what is wrong in my FFT-calling / calculating ???
 
Thank you all,
markan
 
********************************************************************
short i=0;   // Laufvariable
 short index_for_twiddl[SQRT_ANZAHL_SAMPLES];      //N/2 + 1 > sqrt(N)
 short index_for_fftData[anzahl_samples];   //index for bitrev X
 
 
 COMPLEX twiddl_coeff_array[anzahl_samples/RADIX];     //array for twiddle constants
 #pragma DATA_ALIGN(twiddl_coeff_array,sizeof(COMPLEX))   //align boundary size complex
 
//=============================================
 void FFT(float *fft_array_ptr)
  { 
    
   //********** calculate the twiddle coefficients ************************
    for( i = 0 ; i < anzahl_samples/RADIX ; i++ )
    {
     twiddl_coeff_array[i].re = cos(DELTA*i);   //real component of twiddl_coeff_array
     twiddl_coeff_array[i].im = sin(DELTA*i);   //neg imag component
    } 
  
   //********** create fft_array -> set Im=0 ******************************
    for( i = 0 ; i < anzahl_samples ; i++ )
    { 
     fft_array[i].re= *fft_array_ptr;   //wrap when i=TAB_PTS  
     fft_array[i].im = 0 ;       //zero imaginary part
     fft_array_ptr++;
    }
    //********** Windowing before FFT ************************
    for( i = 0 ; i < anzahl_samples ; i++ )
      fft_array[i].ret_array[i].re *( 0.21557895-0.41663158*cos(2*i/anzahl_samples)+0.277263158*cos(4*i/anzahl_samples)-0.83578947*cos(6*i/anzahl_samples)+0.006947368*cos(8*i/anzahl_samples) ); // Flat-Top-Window
     
      // fft_array[i].re= fft_array[i].re *(0.54-0.46*cos(2*pi*i/anzahl_samples) ); // Hamming-Window
     
  
   //********** create first index then bitrevers-order for twiddle coefficients
    digitrev_index(index_for_twiddl, anzahl_samples/RADIX, RADIX);  //produces index for bitrev() W
    bitrev(twiddl_coeff_array, index_for_twiddl, anzahl_samples/RADIX);//bit reverse W
   
   //********** call cfftr2_dit() ******************************************
    cfftr2_dit(fft_array, twiddl_coeff_array, anzahl_samples);
  
   //********** bit-reverse the resulting scrambled output
    digitrev_index(index_for_fftData, anzahl_samples, RADIX);  //produces index for bitrev() fft_array
    bitrev(fft_array, index_for_fftData, anzahl_samples);     //freq scrambled->bit-reverse fft_array     
  
   fft_array_ptr= NULL;
  } //******************** END of FFT() ***************************
 
 



Gesendet von http://mail.yahoo.de.
UNGLAUBLICH! Bis zu 1.200 Warenproben und Gutscheine koennen Sie mit diesen Service abstauben. Anmelden! www.probenking.de.