[sdiy] Digital interpolation filtering

Tom Wiltshire tom at electricdruid.net
Sat May 30 19:00:17 CEST 2009


Hi Eric, and thanks.

>> I've never done digital filtering before though, and I've got some  
>> questions;
>> Am I better off with an odd or even number of taps? Odd seems more  
>> logical somehow, since there is a "middle" sample, but I'm really  
>> just going on a gut feeling.
>
> Generally it doesn't matter. The critical issues in digital  
> filtering are frequency response and processing bandwidth. Use  
> whatever gets the job done. There are some situations where it  
> makes a difference, but those are pretty unusual.

Ok, that's good. In this application a filter with an even number of  
taps would help because it always uses the same number of MACs. With  
the 31-tap example I had in the last mail, mostly it needs 5 MACs,  
but for one of the six samples it needs 6. This is because 31>5x6.

> That said, a bit more detail about your filtering requirements  
> would help tailor a solution. How much are you interpolating? What  
> are the out-of-band rejection requirements?

Well, I've got a good selection of non-bandlimited modulations  
sources (*no-one* anti-aliases their LFO square wave, right?!) which  
are generated at 10.4KHz (62.5KHz / 6). I want to interpolate these  
up to the audio rate of 62.5KHz. The highest fundamental frequency  
from the mod sources is 440Hz, and I'd thought to roll off the  
modulation frequency response above a few KHz when I was going to  
send this into the analogue world.

The idea is to take the modulation signal when it arrives at the  
audio sources uP and treat it like it has five zero samples in  
between each true sample. I then filter that to get an interpolated  
signal. Have I at least got that part right? Hope so, 'cos I based  
the rest of what I've done on that idea...

> sin(x)/x @ x=0 is 1.0. The rationale comes from a calculus concept  
> called L'Hopital's rule: since the rate of change of sin(x) near 0  
> = 1 and the rate of change of x near 0 = 1 also, they're both going  
> towards 0 at exactly the same rate, so the ratio is 1.0.

Ok, sinc(0)=1 makes sense, but I couldn't see how the maths justified  
it. And the poor computer was screaming "DIVISION BY ZERO! ARG!!  
DIVISION BY ZERO!!" at me...

> There are a lot of ways to design a filter - what method are you  
> using? What lead you to choose this particular solution? Where did  
> you get the algorithm?

Errrm...I'm pretty much making it up as I go along. I realise that's  
probably not the best way! I've been reading as much as I can, but I  
feel like unless I understand digital filtering, I don't understand  
most of the pages about it - catch 22.
I usually find something by bumbling about in the dark for a bit though.

The algorithm I'm using is to take a group of input samples and then  
process them six times with different sets of coefficients to  
generate the six interpolated samples, rather than actually ever put  
zeros inbetween input samples. For the first interpolation, the  
actual input samples line up with taps 5, 11, 17, 23 and 29, so you  
have to calculate those MACs. For the second interpolation, the  
actual samples line up with taps 4, 10, 16, 22 and 28, so you  
calculate those. I've got six sets for the six samples I want, and I  
just use the appropriate subset of coefficients depending where I've  
got to between input samples. Hope that's intelligible.


> http://www.dsprelated.com/
>
> http://www.dspguide.com/
>
> http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
>
> http://ccrma.stanford.edu/~jos/filters/

Thanks!

Tom





More information about the Synth-diy mailing list