|
просто вот так (на DSP точно тот-же цикл):
long iir(short inp, short *buf, short *coeff, int np)
{
int i; long acc; short dly;
acc = inp*(2^15); // inp in Q.15 - scale to Q.30
for (i=0; iacc = ((short)(acc>>16))(*coeff++); // Q.14*Q.14 => Q.28
acc -= buf[0]*(*coeff++);
acc -= buf[1]*(*coeff++);
dly = ((short)(acc>>16))<<2; // Q.28 => Q.14 format
acc += buf[0]*(*coeff++);
acc += buf[1]*(*coeff++);
acc *= 2; // Q.28 => Q.30
buf[1] = buf[0];
buf[0] = dly*4;
buf += 2;
}return acc;
}
E-mail: info@telesys.ru