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

📄 fir_floatpt.c

📁 用dsp解压mp3程序的算法
💻 C
字号:
/*****************************************************************
*  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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#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;k<NL;k++)
  {
    xnbuf[k]=0.0;
  }

  
  while ((fscanf(xn_in,"%f",&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.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 */
}

⌨️ 快捷键说明

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