floatpoint_directiir.c

来自「CHP 5 - Real-Time Digital Signal Process」· C语言 代码 · 共 47 行

C
47
字号
// 
//  Project: Experiment 5.7.1: implementation of floating-point IIR filter in direct form I - Chapter 5
//  File name: floatPoint_directIIR.c   
//
//  Description: This is the floating-point direct form I IIR filter realization
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//

#include "floatPointIIR.h"

void floatPoint_IIR(double in, double *x, double *y, 
                    double *b, short nb, double *a, short na)
{
  double z1,z2;
  short i;

  for(i=nb-1; i>0; i--)         // Update the delay line x[]
  {
    x[i] = x[i-1];
  }
  x[0] = in;                    // Insert new data to delay line x[0]

  for(z1=0, i=0; i<nb; i++)     // Filter the x[] with coefficient b[]
  {
    z1 += x[i] * b[i];
  }
	
  for(i=na-1; i>0; i--)         // Update the y delay line
  {
    y[i] = y[i-1];
  }

  for(z2=0, i=1; i<na; i++)     // Filter the y[] with coefficient a[]
  {
    z2 += y[i] * a[i];
  }
  y[0] = z1 - z2;               // Place the result into y[0]

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?