One pole filter code - does this look right?

Software questions and issues with the FV-1

Moderator: frank

Post Reply
seancostello
Posts: 74
Joined: Mon Sep 11, 2006 10:04 pm

One pole filter code - does this look right?

Post by seancostello »

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:

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
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

Code: Select all

1.f-exp(-2.f*PI*cutoff/samplingRate);
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
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Hmmm, since you want to calculate the cut-off coefficient on the fly I think that is about the best that can be done. If the coefficient was fixed then RDFX would knock the instruction count down.

Generally what I do to use a pot as a coefficient is to determine the extrema values I want as coefficients, read the pot and maybe adjust the curve of it if linear is not what I want (i.e. square the pot value to make it more exponential) then use something like SOF to scale and offset the result to range between the min and max value. Avoids any exponential or power calculations in the code.
Frank Thomson
Experimental Noize
Post Reply