Т.Достоевский (07.09.2011 19:24 - 19:26, просмотров: 1618)
Камрады! А чем можно расчитать IIR фильтр? А то винфильтр неверно считает. /**************************************************************
WinFilter version 0.8
http://www.winfilter.20m.com
akundert@hotmail.com
Filter type: Low Pass
Filter model: Butterworth
Filter order: 1
Sampling Frequency: 500 Hz
Cut Frequency: 1.000000 Hz
Coefficents Quantization: 16-bit
Z domain Zeros
z = -1.000000 + j 0.000000
Z domain Poles
z = 0.987488 + j -0.000000
***************************************************************/
#define NCoef 1
#define DCgain 128
__int16 iir(__int16 NewSample) {
__int16 ACoef[NCoef+1] = {
26231,
26231
};
__int16 BCoef[NCoef+1] = {
32768, <<<<<--------???????????????????? Странный int
-32358
};
static __int32 y[NCoef+1]; //output samples
//Warning!!!!!! This variable should be signed (input sample width + Coefs width + 1 )-bit width to avoid saturation.
static __int16 x[NCoef+1]; //input samples
int n;
//shift the old samples
for(n=NCoef; n>0; n--) {
x[n] = x[n-1];
y[n] = y[n-1];
}
//Calculate the new output
x[0] = NewSample;
y[0] = ACoef[0] * x[0];
for(n=1; n<=NCoef; n++)
y[0] += ACoef[n] * x[n] - BCoef[n] * y[n];
y[0] /= BCoef[0];
return y[0] / DCgain;
}