//GraphicEQ.c Graphic Equalizer using TI floating-point FFT functions #include #include "GraphicEQcoeff.h" //time-domain FIR coefficients #define PI 3.14159265358979 #define PTS 256 //number of points for FFT #define SQRT_PTS 16 #define RADIX 2 #define DELTA (2*PI)/PTS typedef struct Complex_tag {float real,imag;} COMPLEX; #pragma DATA_ALIGN(W,sizeof(COMPLEX)) #pragma DATA_ALIGN(samples,sizeof(COMPLEX)) #pragma DATA_ALIGN(h,sizeof(COMPLEX)) COMPLEX W[PTS/RADIX] ; //twiddle array COMPLEX samples[PTS]; COMPLEX h[PTS]; COMPLEX bass[PTS], mid[PTS], treble[PTS]; short buffercount = 0; //buffer count for iobuffer samples float iobuffer[PTS/2]; //primary input/output buffer float overlap[PTS/2]; //intermediate result buffer short i; //index variable short flag = 0; //set to indicate iobuffer full float a, b; //variables for complex multiply short NUMCOEFFS = sizeof(lpcoeff)/sizeof(float); short iTwid[SQRT_PTS] ; //PTS/2+1 > sqrt(PTS) float bass_gain = 1.0; //initial gain values float mid_gain = 0.0; //change with GraphicEQ.gel float treble_gain = 1.0; interrupt void c_int11(void) //ISR { output_sample((int)(iobuffer[buffercount])); iobuffer[buffercount++] = (float)(input_sample()); if (buffercount >= PTS/2) //for overlap-add method iobuffer { //is half size of FFT used buffercount = 0; flag = 1; } } main() { digitrev_index(iTwid, PTS/RADIX, RADIX); for( i = 0; i < PTS/RADIX; i++ ) { W[i].real = cos(DELTA*i); W[i].imag = sin(DELTA*i); } bitrev(W, iTwid, PTS/RADIX); //bit reverse W for (i=0 ; i