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

📄 floatingpointfirtest.c

📁 CHP 4 - Real-Time Digital Signal Processing: Implementations and Applications, Second Edition by Sen
💻 C
字号:
// 
//  Project: Example 4.18: floating-point implementation of FIR filter - Chapter 4
//  File name: floatingPointFirTest.c   
//
//  Description: This is the test file for the example of floating-point FIR filter
//               The input data is a white noise.
//               The output data is the filtered white noise.
//               The spectrum of the output data shows the filter response.
//               The spectrum shows it is a bandpass filter.
//
//  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
//

#include <stdlib.h>
#include <stdio.h>

#include "floatingPointFir.h"

float firCoefFloatingPoint[NUM_TAPS]={
  #include "firCoef.h"
};

float w[NUM_TAPS];

void main()
{
  FILE  *fpIn,*fpOut;
  short i,temp;
  float x,  // input data
        y;  // output data
  
  fpIn = fopen("..\\data\\input.pcm", "rb"); 
  fpOut = fopen("..\\data\\output.pcm", "wb");

  if (fpIn == NULL)
  {
    printf("Can't open input file\n");
    exit(0);
  }
	
  // Initialize for filtering process
  for (i=0; i<NUM_TAPS; i++)
  {
    w[i] = 0.0;
  }

  // Begin filtering the data
  while (fread(&temp, sizeof(short), 1, fpIn) == 1)
  {
    x = (float)temp;
    // Filter the data x and save output y
    floatPointFir(&x, firCoefFloatingPoint, NUM_TAPS, &y, w);

    temp = (short)y;
    fwrite(&temp, sizeof(short), 1, fpOut);
  }

  fclose(fpIn);
  fclose(fpOut);
}

⌨️ 快捷键说明

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