# Multiple questions about how to implement practical resampling

I am learning resampling theory, and for the time being I am specifically interested in downsampling. I have a textbook that is not a dsp textbook but has a section on resampling. The way they put it, resampling has three steps: Rebuild the analog signal, LPF it, then resample at the new rate. So the equivalent of: DAC, LPF, ADC. All of this happens in a single calculation. To reconstruct the signal, we multiply the sampled signal by a LPF with frequency response H(w), with the cutoff at ws/2. The filter h(t) is called the "interpolation filter."

$$x(t)=x_s(t) \ast h(t)=\sum_{n=-\infty}^{\infty}x_nh(t-t_n)$$

We can obtain new samples with:

$$\DeclareMathOperator{\sinc}{sinc} x_m=\sum_{n=-\infty}^{\infty}x_nh(t_m-t_n)$$

If we are downsampling, we want to filter at the bandwidth of our new sampling rate. $$\omega_s$$ is the new sampling rate.

For an ideal LPF, $$h(t)=\sinc(\frac{\omega_st}{2})$$ and $$x_m=\sum_{n=-\infty}^{\infty}x_n\sinc(\frac{\omega_s(t_m-t_n)}{2})$$ therefore we are doing sinc interpolation. My book points out that this is impractical for two reasons:

1. All of the above assumes we have an infinite number of samples.
2. It is based on an ideal LPF which is not realizable.

The book then goes on to analyze truncated sinc filters with a hann window applied. Now I have a few questions:

1. The FT of a pulse train is itself a pulse train. Therefore our sampled signal we treat as an infinite number of copies of the original frequency spectrum. However, if we have a limited number of samples, $$h(t)=\sum_{n=0}^{N-1}\delta(t-nT_s)$$ and $$H(\omega)=\sum_{n=0}^{N-1}e^{-j\omega(t-nT_s)}$$. If the limits of summation were infinite, this would be an infinite pulse train. When they are finite, I'm not so sure. I'm having trouble visualizing what this would look like. Is this just a pulse train from n=0 to n=N-1? If not, what does it look like and how does it affect $$X_s(\omega)$$? Is it a reasonable approximation for a large number of samples to estimate $$X_s(\omega)$$ as an infinite number of copies of $$X(\omega)$$? And if so, why does my book list this as being an issue with the above resampling theory?
2. For digital filters in general (such as a FIR low pass filter used as an interpolation filter), do they only operate in the range of $$\frac{-\omega_s}{2}$$ to $$\frac{\omega_s}{2}$$? Surely a "true" LPF (analog) would cut out the copies of the spectrum and leave us with a scaled version of $$X(\omega)$$. I'm imagining digital filters as operating in the above range, and therefore affecting all copies of the original spectrum as well.
3. Very similar to the question above, couldn't an analog LPF be used as a DAC? Simply output the samples as high voltage impulse "spikes" through an analog LPF to filter out the copies and you are left with the original spectrum.
4. The main reason I understand LPFs to be nonrealizable is that they are noncausal. I don't really understand why noncausal filters are not possible. For a real-time filter such as an RC low-pass this makes sense, but when the filter is applied in software after collecting all the samples, I see no reason a "previous" sample cannot be used to determine the weighting for a "future" sample. Isn't this a noncausal filter?

We assume here that "down-sampling" means reducing the sample rate by an integer factor Q and that "up-sampling" is increasing the sample rate by an integer factor P. Changing the sample rate by a rational factor $$r = P/Q$$ is called sample rate conversion and typically implemented by up-sampling by P followed by down-sampling by Q.

Down-sampling is quite simple. Assuming your original sample rate was $$f_0$$ your new sample rate after down-sampling by Q will be $$f_q = f_0/Q$$. To avoid aliasing, you need a low-pass filter with a cutoff frequency below the new Nyquist frequency i.e. $$f_c < f_q/2$$ Since a real-world low-pass filter will need a non-trivial transition band, the cutoff frequency is typically a good chunk (maybe 10%-20%) below the Nyquist frequency. For example standard audio sample rates are 44.1kHz or 48 kHz, but anti-aliasing filters start cutting of at 20 kHz.

So the process is simple

1. Apply lowpass filter
2. Throw away the samples you don't need

Step 2 is why FIR filters are popular for this task. Instead of throwing samples away, you simply don't calculate them in the first place.

The way they put it, resampling has three steps: Rebuild the analog signal, LPF it, then resample at the new rate

I think that's incorrect or at least misleading. You are not rebuilding an analog signal, you just apply an anti-aliasing filter and discard samples.

Question 1

Sampling in time creates periodically repeated signal in frequency (and vice versa). It doesn't matter if you have a finite or infinite number of input samples. The main consequence of a finite number of samples is aliasing. A finite signal has unlimited bandwidth so there is always some aliasing happening.

For digital filters in general (such as a FIR low pass filter used as an interpolation filter), do they only operate in the range of −ωs2 to ωs2 ?

No. They operate on the entire frequency range but since the filter is time discrete the entire frequency range is periodic. What happens in the interval $$[-f_0/2,f_0/2]$$ is exactly the same as in for example $$[16.5f_0,17.5 f_0]$$ Typically you only look at one period of the spectrum since that already tells you everything about the entire spectrum.

Surely a "true" LPF (analog) would cut out the copies of the spectrum and leave us with a scaled version of X(ω)

Not sure what you mean by "true" LPF. You can't build an LPF with an arbitrary narrow transition range. Not in digital and sure as heck not in analog.

Very similar to the question above, couldn't an analog LPF be used as a DAC? Of course not. A DAC is DAC, an LPF is an LPF: they do completely different things.

Simply output the samples as high voltage impulse "spikes" through an analog LPF to filter out the copies and you are left with the original spectrum.

That's impractical since voltage peaks would have to be infinitely high and narrow. Instead a real DAC will output a step curve which is low-pass filtered version of the ideal "spike" curve and apply a small spectral correction in the pass-band. You can certainly follow this with an analog LPF to reduce the mirror spectra but that depends on the application.

The main reason I understand LPFs to be nonrealizable is that they are noncausal.

Let's be clear about the terminology. LPF means low pass filter and they are used all over the place. What is NOT realizable is a "perfect" LPF, i.e. that's exactly 1 in the passband, exactly 0 in the stop band and has a infinitely small transition band. This can't be done in practice because the impulse response of such a filter is a $$\sin(x)/x$$ function which extends infinitely in time in both directions. It's not just non-causal, it's infinitely non-causal. Even if it were causal you can't implement a filter with an infinite number of coefficients.

I see no reason a "previous" sample cannot be used to determine the weighting for a "future" sample.

Correct, but this only works if the number of previous samples required is finite. It also adds to the latency. The more samples you need, the longer you need to delay the output. That's show stopper in many applications