📄 fir_filter.c
字号:
/******************************************************************************/
/* Copyright 2006 by SEED Electronic Technology LTD. */
/* All rights reserved. SEED Electronic Technology LTD. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/******************************************************************************/
/******************************************************************************/
/* Tiltle:FIR_filter.c */
/* Platform:TMS320C5416 */
/* Author:Marine@seeddsp.com */
/* Purpose:FIR filter procedure for processing a group of data */
/* Prototype in C:void fir_filter(const short x[],const short h[],\ */
/* short y[],int n,int m,int s); */
/* const short x[]:输入信号的缓冲数组,short类型,在滤波中不可修改 */
/* const short h[]:滤波器的系数数组,short类型,在滤波中不可修改 */
/* short y[]:输出信号的缓冲数组,short类型 */
/* n:滤波器长度,本例中为ORDER_FIR */
/* m:输入信号的长度,即数组x[]的长度 */
/* s:生成整型的滤波器系数时使用的移位数目,本例中为ROUND_FIR */
/* Note:-o3 compile option recommended. */
/* x[] and y[] not permitted to have relative addresses. */
/* filter length supposed to be larger than 16. */
/* input length supposed to be larger than 16 */
/* only first m-n point output legal */
/* Version:1.0 Dec25,2006 Marine@seeddsp.com */
/* Rivision: */
/******************************************************************************/
void fir_filter(const short x[],const short h[],short y[],int n,int m,int s)
{
int i,j;
long y0;
long acc;
_nassert(m>=16);
_nassert(n>=16);
for(j=0;j<m;j++)
{
acc=0;
for(i=0;i<n;i++)
{
if(i+j>=m)
break;
else
{
y0=(long)x[i+j]*(long)h[i];
acc=acc+y0;
}
}
*y++=(short)(acc>>s);
}
}
/*********************************************************************************
//End of file
*********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -