资源描述:
《翻译c语言写的fir滤波器》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、翻译c语言写的fir滤波器请会的帮我把没行的注释写上。。谢谢#include #include #define true 1#define false 0#define n 8#define bufsize 100 /* the buffer size is 100 *//* global declarations */int in_buffer[bufsize]; /* processing data buffers */int out_buffer[
2、bufsize];/* functions */static int processing(int *input, int *output);static void dataio(void);static long round(long a);void main(){ int *input = &in_buffer[0]; int *output = &out_buffer[0]; puts("the 1st experiment started"); /* loop fo
3、rever */ while(true) { /* * read input data using a probe-point connected to a host file. * write output data to a graph connected through a probe-point. */ // read the input signal. // if th
4、e input file is sine1.dat, the signal contains 300hz,400hz and 500hz. // if the input file is sine2.dat, the signal contains 100hz,400hz and 500hz. // the sampling frequency is 1200hz. dataio(); /* remove the frequency compom
5、ent of 400hz and 500hz*/ processing(input, output); // write the output signal. // the output file is result.dat. dataio(); }}/* * ======== processing ======== * * function: apply a low-pass fir filter to input signal and remove the
6、frequency higher than 350hz. * * parameters: address of input and output buffers. * * return value: true. */ static int processing(int *input, int *output){ int i,size = bufsize; short xx0,x,y; // short z[n]={0,0,0,0,0,0,0,0,0}; short z[
7、n]={0,0,0,0,0,0,0,0};//short w[2*n+1]={22,356,155,990,466,220,777,216,777,26,466,9,155,0,22};//short w[2*n+1]={6,457,56,1024,224,418,523,382,784,99,784,43,523};// short w[2*n+1]={330*2,3299*2,1982*2,6867*2,4955*2,1594*2,6607*2,1065*2,4955*2,109*2,1982*2
8、,17*2,330*2}; //short w[2*n+1]={661,6598,3964,13733,9910,3187,13214,2131,9910,217,3964,34,661}; // short w[2*n+1]={58,5628,526,8192,2105,5883,4913,3829,7369,1543,7369,504,4913,102,2105,14,526,1,58}; //short w[2*n+1]={28,4432,28