Digital Signal Processing Reference
In-Depth Information
Appendix D
C Code for Normalized Approximation
Functions
In the main file of the FILTER program on the CD, we called
Calc_Filter_Coefs (as shown in Listing D.1) in order to calculate the
necessary filter coefficients for the user-specified design. That function in turn
called one of three other functions named Calc_Analog_Coefs,
Calc_DigFIR_Coefs, or Calc_DigIIR_Coefs .
/*====================================================
Calc_Filter_Coefs() - determines implementation and
calls appropriate calculation function
Prototype: int Calc_Filter_Coefs(Filt_Params *FP);
Return: error value
Arguments: FP - ptr to struct holding filter params
====================================================*/
int Calc_Filter_Coefs(Filt_Params *FP)
{ int Error; /* error value */
/* Call correct calc function for analog,
digital FIR or IIR filters. */
switch(FP->implem)
{ case 'A':
Error = Calc_Analog_Coefs(FP);
if(Error) { return 10*Error+1;}
break;
case 'F':
Error = Calc_DigFIR_Coefs(FP);
if(Error) { return 10*Error+2;}
break;
case 'I':
Error = Calc_DigIIR_Coefs(FP);
if(Error) { return 10*Error+3;}
break;
default:
return ERR_FILTER;
}
return ERR_NONE;
}
Listing D.1 Calc_Filter_Coefs function.
233
Search WWH ::




Custom Search