⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fir_fixpt.c

📁 用dsp解压mp3程序的算法
💻 C
字号:
/*****************************************************************
*  fir_fixpt.c - C program for NL-tap FIR filtering in 
*                Section 6.6.3
******************************************************************
*  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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "coeff_16int.h"

void main()
{

/*****************************************************************
*    Define variable arrays, define and clear variables
*****************************************************************/

  long yn = 0;               /* y(n), output from IIR filter    */
  int xn;
  int xnbuf[96];
  int i,j,k;
  long scale = 32768;
 
/*****************************************************************
*    Declare file pointers
*****************************************************************/

  FILE *xn_in;			  /* file pointer of x(n)       */
  FILE *yn_out;			  /* file pointer of y(n)       */
  xn_in = fopen("in_int.dat","r");/* open file for input x(n)   */
  /*Note that the data cannot be expressed in exp format for %d */
  yn_out = fopen("out_int.dat","w");/* open file for output y(n)*/

/*****************************************************************
*    Start of main program
*****************************************************************/
 for(k=0;k<NL;k++)
  {
	  xnbuf[k]=0;
  }

  while ((fscanf(xn_in,"%d",&xn)) != EOF)
  {           /* read in x(n) from data file and processing it  */
    for (i=NL-1;i>0;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; 
    
    for (j=0; j< NL; j++)	
    {
		
    	yn += (long)(xnbuf[j] * (int16_T)NUM[j]);
		
    } 
    
    fprintf(yn_out,"%d\n",(int)(yn/scale));
	
  }
  printf("Finish");	      /* Complete filtering */  
  fcloseall();                /* close all opened files */
}

⌨️ 快捷键说明

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