📄 floatingpointblockfirtest.c
字号:
//
// Project: Example 4.19: floating-point implementation of block FIR filter - Chapter 4
// File name: floatingPointFirTest.c
//
// Description: This is the test file for the example of floating-point block 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];
float x[NUM_DATA], // input data
y[NUM_DATA]; // output data
void main()
{
FILE *fpIn,*fpOut;
short i,temp[NUM_DATA],
index; // delay line index
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;
}
index = 0;
// Begin filtering the data
while (fread(temp, sizeof(short), NUM_DATA, fpIn) == NUM_DATA)
{
for (i=0; i<NUM_DATA; i++)
{
x[i] = (float)temp[i];
}
// Filter the data x and save output y
floatPointBlockFir(x, NUM_DATA,
firCoefFloatingPoint, NUM_TAPS,
y,
w, &index);
for (i=0; i<NUM_DATA; i++)
{
temp[i] = (short)y[i];
}
fwrite(temp, sizeof(short), NUM_DATA, fpOut);
}
fclose(fpIn);
fclose(fpOut);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -