/***************************************************************** ** ** file: fir_filter.h ** Description: Subroutines to implement a (real) FIR Filter in real-time. ** Multiple subroutine calls are used to calculate the output ** of an FIR filter ** y(n) = x(n) * h(n) ** where x(n) is the nth input sample, and the values of h(n) ** obtained from an array of fixed values, and "*" denotes ** discrete-time convolution. ** ** Implementation: ** Filters are implemented using three function calls: ** init_fir() is called once, and is used to initialize the array ** of filter coefficients h(n), allocate any required memory, ** and perform any other required initialization. ** calc_fir() is called multiple times -- once for every input sample. ** It returns the filter output sample y(n). ** destroy_fir() is called once at the end of the program, and is used ** to de-allocate any memory. ** ** Function Prototypes and parameters: ** ** #include "fir_filter.h" ** FIR_PARMS *init_fir(double *filter_coefs, int n_coef); ** ** Inputs: ** filter_coefs pointer to the array of values for h(n) ** filter_coefs[i] should contain the impulse ** response of the filter at time "i", for ** i=0, 1, 2, ..., n_coef-1 ** The filter_coefs array is NOT modified by ** init_fir(), calc_fir(), or destroy_fir(). ** n_coef Number of samples in the array ** Returned: ** The function returns a pointer to a "FIR_PARMS" data type ** (which is defined in "fir_filter.h") ** ** double calc_fir( FIR_PARMS *s, double x ); ** ** Inputs: ** s pointer to FIR_PARMS, as provided by init_fir() ** x Input sample value ** Returned: ** The function returns the FIR filter output sample y(n). ** ** i=n_coef-1 ** y(n) = sum ( h[i] x(n-i) ) ** i=0 ** ** where x(n) is the value of "x" for the current call, x(n-1) ** is the value of "x" from the previous call, x(n-2) is the ** value of "x" from call before that, and so on. ** ** void destroy_fir(FIR_PARMS *s); ** Inputs: ** s pointer to FIR_PARMS, as provided by init_fir() ** No value is returned. ** *******************************************************************/ #ifndef ECE486_FIR_FILTER #define ECE486_FIR_FILTER /******* ECE486 STUDENTS MODIFY THIS *******/ #endif