Digital Signal Processing Reference
In-Depth Information
// GraphicEQ.c Graphic Equalizer using TI floating-point FFT functions
#include "DSK6713_AIC23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;//set sampling rate
#include <math.h>
#include "GraphicEQcoeff.h" //time-domain FIR coefficients
#define PI 3.14159265358979
#define PTS 256 //number of points for FFT
#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[PTS/2] ;
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((short)(iobuffer[buffercount]));
iobuffer[buffercount++] = (float)((short)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<PTS ; i++)
{
bass[i].real = 0.0;
bass[i].imag = 0.0;
FIGURE 6.24. Equalizer program using TI's floating-point FFT support functions
( graphicEQ.c ).
Search WWH ::




Custom Search