One pole filter code - does this look right?
Posted: Mon Mar 19, 2012 12:02 pm
Hi all:
I'm working on a simple one pole filter, where the frequency is variable from a pot or other code. This is what I have right now:
Does this look about right? Any suggestions to make this more efficient? 4 instructions isn't that bad, but I like to shave cycles wherever possible.
Also, the coefficient is computed (in C code) as
Any hints for calculating this on the FV-1? I don't need a precise cutoff, as this would vary with clock speed. Just wondering if there are any fixed point tricks I can keep in mind. I figure the EXP instruction is the goto one for this calculation, but any hints of taking a knob input, and transforming it into a usable range for a tone control or variable LPF, are most welcome.
Thanks,
Sean Costello
I'm working on a simple one pole filter, where the frequency is variable from a pot or other code. This is what I have right now:
Code: Select all
equ lpcoef reg10 ; frequency coefficient
equ lpstate reg11 ; filter state
rdax lpstate, -1.0 ; subtract lpstate from current value in accum
mulx lpcoef ; multiply by lpcoef
rdax lpstate, 1.0 ; add lpstate back to (input-lpstate)*lpcoef
wrax lpstate, 1.0 ; write filter output back to lpstate,
; while keeping value in the accumulator
Also, the coefficient is computed (in C code) as
Code: Select all
1.f-exp(-2.f*PI*cutoff/samplingRate);Thanks,
Sean Costello