[sdiy] Shift-based IIR filters
Scott Gravenhorst
music.maker at gte.net
Wed Mar 9 23:15:53 CET 2016
Tom Wiltshire <tom at electricdruid.net> wrote:
>This topic has been discussed here before, but I wanted to draw
>people's attention to the following discussion on StackExchange:
>
>
>http://electronics.stackexchange.com/questions/30370/fast-and-memory-efficient-moving-average-calculation
>
>There's a very good explanation of how to do a single pole
>RC-style IIR filter on a basic processor using downshifts for the
>multiplication (one shift right is "x0.5", so you can get any
>coefficient like 1/2^n without doing hard sums).
>
>Realising that a byte-shift is even more efficient than a bit
>shift, I did a 8-bit input, 16-bit filter variable IIR filter
>which provides a slow filter (since the coefficient is 1/256) and
>only requires five instructions and two bytes of memory to
>calculate. Cascade it if you need more rolloff.
>
>Enjoy,
>Tom
Ah, yes, I've used this form. Eric Brombaugh showed me this one some
years ago for an FPGA synth project.
It's works fine as long as the cutoff you need is close enough using one
of the shifted values, but if you need a variable cut-off, it loses
resolution at one end... 0.5 0.25 0.125 0.0625 are rather large
jumps. After rewriting the synth code to share multipliers, I replaced
this form with the standard in*a0+z*b1 form because I needed a smooth
linear change from low cutoff to high cutoff (such as is needed for
portamento).
Useful nonetheless in many cases.
-- ScottG
More information about the Synth-diy
mailing list