# Polyphase filter outputs

Started by July 14, 2009
```>>nikolatesla20 wrote:
>>
>>>>When interpolating, you multiplex (interlace) the phase output
>>>>sequences to build the high-rate sequence. When decimating, a
>>>>polyphase FIR filter is pointless but you would indeed add the
>>>>phase outputs in the case of IIR filtering.
>>
>>> Could you answer one more question. By "multiplex" the outputs,
>>> do you mean that basically the outputs become the values that
>>> replace the zero filling in the new buffer?
>>
>>Yes, if I interpret your formulation right. Each input value is
>>turned into a block of successive result values that is just the list
>>of phase outputs.
>>
>>
>>Martin
>>
>>--
>>Quidquid latine scriptum est, altum videtur.
>>
>
>
>
>ACK! I do have to say though that the polyphase is extremely confusing.
I
>haven't found anything on the internet that explains them well.
>
>For example, I found the articles at dspguru where he shows an "example"
>polyphase that has 16 taps and interpolation ration of 3. Then he shows
a
>table of how the values are calculated. But the table is confusing! They
>way he shows it seems like the data is being "shifted" into the delay
>line..which I could understand, but then he shows each equation for each
>"poly" channel..
>
>Basically I trying to do this in code. I can just copy my entire buffer
>and step through it for now to avoid looping buffers until I get it
>working.
>
>My interpolation ratio is 5.
>
>But do I step ONE sample at a time or 5 samples at a time? And if I step
1
>sample at a time, then I'm assuming I will have 5 polyphase filters, so
>then do I add the result of all of them and put that in as the new
>calculated sample, or do the 5 outputs create the new values for
position
>1-5? Ugh. I just need a nice clear step by step explanation, not more
>equations...I get how the math makes it faster, but I want to understand
>how do I implement the darn thing!
>
>-niko
>

Ok I got 'er working. Here's my code for 35 taps, interpolation of 5.

// "polyphase filter"
int filtercount = 0;

for (int ii=30; ii < outsamples.length; ii++)
{
short tempval = 0;

// calc new value based on the 5 poly filters

tempval = (short)((coefs[filtercount] * outsamples[ii-filtercount]) +
(coefs[filtercount+5] * outsamples[ii-(filtercount+5)]) +
(coefs[filtercount+10] * outsamples[ii-(filtercount+10)]) +
(coefs[filtercount+15] * outsamples[ii-(filtercount+15)]) +
(coefs[filtercount+20] * outsamples[ii-(filtercount+20)]) +
(coefs[filtercount+25] * outsamples[ii-(filtercount+25)]) +
(coefs[filtercount+30] * outsamples[ii-(filtercount+30)]));

newdata[ii] = tempval;

filtercount++;
if (filtercount > 4) filtercount= 0;

}

```