# Resampling: how many samples to zero-stuff or down sample?

I am a little confused about how resampling works with one filter. I get why you choose the lower nyquist cutoff when you combine both interpolation and decimation for resampling by a rational fraction (you don't want to alias and you only get one shot to take care of it when you combine interpolation+decimation).

I will use a practical example: $44.1 \, \textrm{kHz}$ to $48\, \textrm{kHz}$.

$(44100 / 48000) = (441 / 480) = (147 / 160)$

Combining $147$ decimation factor by $160$ interpolation, you can use one anti-alias: at $44.1/2= 22050\,\textrm{Hz}$ cutoff for a lowpass FIR. However, you still need to zero stuff, right? But how much? 160 zeroes?

Going the other way around $48 \, \textrm{kHz}$ to $44.1\, \textrm{kHz}$, how many samples do you downsample? Certainly not 147 zeroes?

Is $160 - 147 = 13$ zeroes the answer?

In the multi-stage solution, here's how this would work (I think): Stuff $160$ zeroes, anti-alias lowpass at $24\, \textrm{kHz}$. Downsample the output by $147$, antialias lowpass at $22050 \, \textrm{Hz}$. But wait, you're not computing outputs for a lot of those zeroes, so why not just combine the two? Does this leave me with $13$ zeroes for resampling up and $13$ samples to skip over when resampling down before applying the lower of the two cutoffs?

Next thing to wrap my head around: polyphase filterbanks.

EDIT: source of confusion is in last comment to answer, interpolate is upsampling followed by anti-image filter while decimation is anti-alias followed by downsampling. cascading these two obviates the need for two separate filters. if this is the case then would this mean that resampling by a rational factor < 1 entails 2 filters always by the nature of the decimation/interpolation process, while a resample factor > 1 entails that 1 filter may be used instead?

DOUBLE EDIT: thinking about it, you can still use 1 filter, but you must interpolate first, then anti-alias, then decimate.

sorry (definitely not sorry) this is how my brain debugs its malformed thoughts on DSP (:

• The alternative to up/down sampling by two large factors is to interpolate the just the few samples you need at the destination sample rate, and no others. If you interpolate using a high-quality low-pass/anti-alias FIR filter kernel, there will be little qualitative difference. A polyphase table is a way to efficiently implement the FIR filter(s) needed. Nov 4 '15 at 5:52