//fastconvosim.c Overlap-add fast convolution demonstration program //Uses FFT function from C31 DSK book. Not real-time, and therefore //does not need McBSP I/O. Run with breakpoints inserted as indicated //in source file and view graphs of // start acquisition display index DSP // address buffer size data size increment data type // h 512 256 2 32-bit float // samples 512 256 2 32-bit float // iobuffer 128 128 1 32-bit float // overlap 128 128 1 32-bit float #include #include #include #include "coeffs.h" //time domain FIR filter coefficients #define PTS 256 //number of points used in FFT struct cmpx //complex data structure used by FFT { float real; float imag; }; typedef struct cmpx COMPLEX; #define PI 3.14159265358979 short poweroftwo[] = {1,2,4,8,16,32,64,128,256,512,1024}; short buffercount = 0; //number of new input samples in iobuffer float iobuffer[PTS/2]; //primary input/output buffer COMPLEX samples[PTS]; //primary working buffer used by FFT float overlap[PTS/2]; //intermediate result buffer COMPLEX w[PTS]; //twiddle factors stored in w COMPLEX h[PTS]; //freq domain filter coeffs stored in h short i; //general purpose index variable float a,b; //variables used in complex multiply short NUMCOEFFS = sizeof(coeffs)/sizeof(float); void FFT(COMPLEX *Y, int N) //input sample array, # of points { COMPLEX temp1,temp2; //temporary storage variables int i,j,k; //loop counter variables int upper_leg, lower_leg; //index of upper/lower butterfly leg int leg_diff; //difference between upper/lower leg int num_stages=0; //number of FFT stages, or iterations int index, step; //index and step between twiddle factor i=1; //log(base 2) of # of points = # of stages do { num_stages+=1; i=i*2; } while (i!=N); leg_diff=N/2; //starting difference between upper & lower legs step=512/N; //step between values in twiddle.h for (i=0;i