home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_05
/
9n05053a
< prev
next >
Wrap
Text File
|
1991-03-22
|
692b
|
35 lines
#include <math.h>
/* apply a filter */
double filter( double s[], double y[],double A[]
double a[],int n, int N)
{
double sum=0.; int k;
for(k=0;k<n;k++) sum += a[k]*s[n-k];
for(k=1;k<N;k++) sum += A[k]*y[N-k];
return (y[n]=sum);
}
/* Set coefficients for two typical low-pass
windowing filters */
/* window size 2n-1 */
hamming(double a[],int n)
{
int k,m=(n<<1)-1;double c;
c=3.14159265358979323/n;
for(k=0;k<m;k++) a[k]=.54+.46*cos( c*k );
}
/* the Hanning window is another possible
winder choice*/
hanning(double a[],int n)
{
int k,m=(n<<1)-1;double c;
c=3.14159265358979323/n;
for(k=0;k<m;k++) a[k]=.5+.5*cos( c*k );
}