Author: wmb Date: 2009-08-01 22:30:45 +0200 (Sat, 01 Aug 2009) New Revision: 1269
Modified: cpu/x86/iirfilter.fth Log: iirfilter.fth - this version seems to work.
Modified: cpu/x86/iirfilter.fth =================================================================== --- cpu/x86/iirfilter.fth 2009-08-01 18:16:45 UTC (rev 1268) +++ cpu/x86/iirfilter.fth 2009-08-01 20:30:45 UTC (rev 1269) @@ -18,25 +18,30 @@ begin ax bx mov \ Save last value 4 [bp] ax sub \ last - M[i+1] - 0 [si] ax imul \ alpha[i] * (last - M[i+1]) (kills DX) + 0 [si] imul \ alpha[i] * (last - M[i+1]) (kills DX) 4 [si] si lea \ Increment alpha pointer - d# 14 # ax shr \ Scale down by multiplier scale factor + d# 16 # ax sar \ Scale down by multiplier scale factor 0 [bp] ax add \ M[i] + alpha[i] * (last - M[i+1]) bx 0 [bp] mov \ Update M[i] 4 [bp] bp lea \ Point to next M[i] loopa - bp pop \ Restore BP si pop \ Restore SI ax push \ Return value c;
+: mul16: ( "coef" -- ) + safe-parse-word push-decimal $number drop pop-base ( n ) + d# 65536 d# 1,000,000,000 */ ( n' ) + , +; + \ upsample by 4
2 constant #coefs
-create weights0 mul14: .101467517 mul14: .612422841 -create weights1 mul14: .342095596 mul14: .867647439 +create weights0 mul16: .101467517 mul16: .612422841 +create weights1 mul16: .342095596 mul16: .867647439
#coefs 1+ /n* constant buflen buflen buffer: z0 @@ -53,11 +58,40 @@
0 [if] for each input sample - sample weights0 z0 #coefs iir-cascade dup to int0 ( out0 ) int1 + +sample weights0 z0 #coefs iir-cascade + dup weights0 z2 #coefs iir-cascade ,next-output + weights1 z3 #coefs iir-cascade ,next-output + +sample weights1 z1 #coefs iir-cascade + dup weights0 z2 #coefs iir-cascade ,next-output + weights1 z3 #coefs iir-cascade ,next-output +[then] +0 [if] +for each input sample +sample weights0 z0 #coefs iir-cascade dup to int0 ( out0 ) int1 + dup weights0 z2 #coefs iir-cascade dup to out0 out1 + ,next-output weights1 z3 #coefs iir-cascade dup to out1 out0 + ,next-output
- sample weights0 z1 #coefs iir-cascade dup to int1 ( out1 ) int0 + +sample weights1 z1 #coefs iir-cascade dup to int1 ( out1 ) int0 + dup weights0 z2 #coefs iir-cascade dup to out0 out1 + ,next-output weights1 z3 #coefs iir-cascade dup to out1 out0 + ,next-output [then] +init-upsample +: up2 ( sample -- out1 out0 ) + dup weights0 z0 #coefs iir-cascade >r + weights1 z1 #coefs iir-cascade r> +; +: up4 ( in -- out3 out2 out1 out0 ) + dup weights0 z0 #coefs iir-cascade ( in intermed0 ) + + dup weights0 z2 #coefs iir-cascade >r ( in intermed0 r: out0 ) + weights1 z3 #coefs iir-cascade >r ( in r: out0 out1 ) + + weights1 z1 #coefs iir-cascade ( intermed1 r: out0 out1 ) + + dup weights0 z2 #coefs iir-cascade >r ( intermed1 r: out0 out1 out2 ) + weights1 z3 #coefs iir-cascade ( out3 r: out0 out1 out2 ) + + r> r> r> +; +
openfirmware@openfirmware.info