/***************************************************************** * fir_floatpt.c - C program for FIR filter in floating-point * in Section 6.6.2 ****************************************************************** * System configuration: * * * in(n) |----------------| out(n) * ---->| Bandpass filter|-----> * |----------------| * ****************************************************************** * System simulation configuration: * * in(n) is the input data from data file "in.dat" * out(n) is the output data to data file "out.dat" * *****************************************************************/ #include #include #include #include "coeff_c_sp.h" void main() { /***************************************************************** * Define variable arrays, define and clear variables *****************************************************************/ float yn = 0.0; /* y(n), output from IIR filter */ float xn; float xnbuf[96]; int i,j,k; /***************************************************************** * Declare file pointers *****************************************************************/ FILE *xn_in; /* file pointer of x(n) */ FILE *yn_out; /* file pointer of y(n) */ xn_in = fopen("in.dat","r"); /* open file for input x(n) */ yn_out = fopen("out.dat","w"); /* open file for output y(n) */ /***************************************************************** * Start of main program *****************************************************************/ for(k=0;k0;i--) { xnbuf[i]=xnbuf[i-1]; } xnbuf[0]=xn; /************************************************************* * FIR filtering: * y(n) = Sum[x(n-i)*coeff(i)] for i = 0 to NL-1 *************************************************************/ yn = 0.0; for (j=0; j< NL; j++) { yn += xnbuf[j] * (real32_T)NUM[j]; } fprintf(yn_out,"%f\n",yn); } printf("Finish"); /* Complete filtering */ fcloseall(); /* close all opened files */ }