/*1 */  // io_stream.c - include header files, function prototypes, and W[N2]
/*2 */  // Uses FFT_func.c and IFFT_func.c
/*3 */  // N-point FFT, where N is defined in FFT_header.h
/*4 */  
/*5 */  #include <math.h>
/*6 */  #include <stdio.h>
/*7 */  #include "FFT_header.h"
/*8 */  #include "dsk6713_aic23.h"
/*9 */  Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
/*10*/  
/*11*/  void FFT_func(COMPLEX *X, COMPLEX *W);  // FFT function prototype
/*12*/  void IFFT_func(COMPLEX *X, COMPLEX *W); // IFFT function prototype
/*13*/  
/*14*/  COMPLEX process[N];
/*15*/  COMPLEX W[N2];
/*16*/  
/*17*/  float tmp;
/*18*/  float io_buffer[N];
/*19*/  short ctr=0;
/*20*/  short flag=0;              // used to create filter latency delay
/*21*/  
/*22*/  interrupt void c_int11()   // interrupt service routine
/*23*/  {
/*24*/   output_left_sample((short)io_buffer[ctr]);
/*25*/   io_buffer[ctr++]=(float)input_left_sample();
/*26*/   
/*27*/   if(ctr >= N)
/*28*/   {
/*29*/     ctr=0;
/*30*/     flag = 1;
/*31*/   }
/*32*/  
/*33*/   return;                   //return from interrupt
/*34*/  }
/*35*/  
/*36*/  
/*37*/  void main()
/*38*/  {
/*39*/    short i;                 // local counter
/*40*/  
/*41*/    ctr=0;
/*42*/    flag=0;
/*43*/    
/*44*/    // Calculate twiddle factors for (I)FFT
/*45*/    for(i=0; i<N2; i++)
/*46*/    {
/*47*/      W[i].real = cos(2*PI*i/N);
/*48*/      W[i].imag = sin(2*PI*i/N);
/*49*/    }
/*50*/    
/*51*/    comm_intr();
/*52*/    while(1)
/*53*/    {
/*54*/      while(flag==0);
/*55*/      
/*56*/      flag = 0;
/*57*/        
/*58*/      for(i=0; i<N; i++)
/*59*/          {
/*60*/            tmp = process[i].real;
/*61*/            process[i].real = io_buffer[i];
/*62*/        io_buffer[i] = tmp;
/*63*/      } 
/*64*/        
/*65*/      FFT_func(process, W);  // perform in-place FFT
/*66*/  
/*67*/      IFFT_func(process, W);
/*68*/    }
/*69*/  }
