Solved! Go to Solution.
#define SUCCESSIVE 10static intisqrt(int x){ int i; int n; if (! x) { return 0; } n = 128; // initial guess for sqrt(mean 0..32767) for (i = 0; i < SUCCESSIVE; i++) { if (n == x/n) { break; } n = (n + x/n + 1)/2; } return n;}
// our low pass filter coefficientsstatic shortcoef[] = { 67, 449, 874, 1261, 1531, 1628, 1531, 1261, 874, 449, 67,};// our low pass filter order#define ORDER (sizeof(coef)/sizeof(coef[0]))intlowpass(int x){ int i; static int s; static int xs[ORDER]; // low pass filter xs[s] = x; x = 0; for (i = 0; i < ORDER; i++) { x += coef[i]*xs[(s+i)%ORDER]; } x /= 9992; // sum of coef's s = (s+1)%ORDER; return x;}
#define SUCCESSIVE 10static intisqrt(int x){ int i; int n; if (! x) { return 0; } n = 128; // initial guess for sqrt(mean 0..32767) for (i = 0; i < SUCCESSIVE; i++) { if (n == x/n) { break; } n = (n + x/n + 1)/2; } return n;}
// our low pass filter coefficientsstatic shortcoef[] = { 67, 449, 874, 1261, 1531, 1628, 1531, 1261, 874, 449, 67,};// our low pass filter order#define ORDER (sizeof(coef)/sizeof(coef[0]))intlowpass(int x){ int i; static int s; static int xs[ORDER]; // low pass filter xs[s] = x; x = 0; for (i = 0; i < ORDER; i++) { x += coef[i]*xs[(s+i)%ORDER]; } x /= 9992; // sum of coef's s = (s+1)%ORDER; return x;}
Hi, Rich T
I want to know if this algorithm can be used to filter high-pass and band-pass? Replacing only the coefficient of the filter.
Thanks advance
Everton Danilo
There are lots of sites on the web for computing the coefficients and getting guidance in digital filter design...
You might try something like: http://www.dsptutor.freeuk.com/FIRFilterDesign/FIRFilterDesign.html
Or just search for "fir digital filter design" or "iir digital filter design".
Good luck.
-- Rich