# Designing a 2x interpolation filter for audio

I want to perform 2x interpolation on an audio signal sampled at 44.1KHz by upsampling the signal by adding a zero after each original sample and then using a lowpass filter to interpolate the results.

Assuming an analogue elliptical filter (of order 10 or lower) as the basis for the design. What design specification would constitute a high quality audio interpolator that minimises aliasing?

For instance a passband and stopband at 0.45 * Nyquist and 0.55 * Nyquist respectively (Nyquist = 22.05KHz) with a stopband attenuation of -50dB and passband ripple of -0.1dB would be common for a low cost commercial DAC (I appreciate that digital to analogue conversion is a slightly different scenario). Would there be better values for doing high quality audio interpolation that minimises aliasing and doesn't truncate too many of the high frequencies before 22.05KHz.

For instance, is it a good idea to have the stop band above 22.05KHz for interpolation or does it not matter if the lowpass rolls off a little after 22.05KHz and what is acceptable?

• What kind of audio, and why do you need to oversample 2x? – Olli Niemitalo Oct 23 '15 at 22:02
• A lot of high grade digital mastering gear uses double sampling (2x oversampling). So the audio would be music. – keith Oct 24 '15 at 9:37

@Keith: Here's the situation as I see it. Your original signal's spectrum is shown in panel (a) below. The solid lines are spectral energy and the dotted lines are spectral replications. After the zero-stuffing (upsampling by two), the stuffed sequence's spectrum is shown in panel (b). Notice the spectral image centered at 44.1 kHz that needs to be removed (attenuated). So after zero-stuffing you need to implement a digital filter whose passband cutoff freq is 0.45*22.05 kHz and whose stopband begins at 0.55*22.05 kHz. (I show that filter as the dashed line in panel (b).) But keep in mind, the filter’s Nyquist rate is 44.1 kHz (88.2/2 kHz) and not 22.05 kHz. The final spectrum you want is shown in panel (c).

• Thanks Richard, I think you've answered the question I originally asked, and you've made me realized my question is wrong as the passband/stopband in my question should be $0.45 f_s$ and $0.55 f_s$ where $f_s = 44.1$ kHz. Stupid me :-( – keith Oct 27 '15 at 13:40

I don' think there is easy "one size fits all" answer. You need to make a trade off between

1. What is the highest frequency where you still want to be "flat"
2. How much aliasing are you willing to tolerate (which is actually a function content, to make it even more complicated)
3. How much and what type of time smearing and/or phase distortion to can allow
4. How much computation do you want to spend on it.
5. Latency constraints

Most high grade digital mastering would probably require a linear phase FIR filter that's really flat in the pass band. I don't think an elliptic filter would qualify. Something like the following filter may work

b = firls(63,[0 18000*2/44100 20000*2/44100 1],[1 1 0 0],[1 10000])';

• An elliptic filter can be made flat in the pass band (as it is a generalisation of the Chebyshev filters). I am not so much interested in the pros/cons of different digital realisations, but more the design considerations for an analogue filter than I can then convert to a digital filter (FIR or otherwise). The position of the stopband/passband is of interest. Why did you choose 18000/20000 over say 19000/21000? – keith Oct 24 '15 at 21:33

Interpolation by way of zero-stuffing cannot generate aliased spectral components. What that upsampling process generates is spectral images. And those images must be eliminated (i.e., greatly attenuated) by lowpass filtering. If I understand your situation, after your zero-stuffing your new data sample rate will be 88.2 kHz, and your stuffed time sequence will have an unwanted spectral image centered at 44.1 kHz. So you need to implement a digital filter whose passband cutoff freq is 0.45*22.05 kHz and whose stopband begins at 0.55*22.05 kHz. But keep in mind now, the filter’s Nyquist rate is 44.1 kHz (88.2/2 kHz) and not 22.05 kHz.

• Thank you for clarifying those points Richard (your book is awesome by the way!). I'm still not clear on why the transition band is 0.45*22.05 kHz to 0.55*22.05 kHz. There must be some rationale that means it's better to have some spectral images around 0.50*22.05 kHz to 0.55*22.05 kHz in practice than to use an alternative transition band such as 0.40*22.05 kHz to 0.50*22.05 kHz or 0.50*22.05 kHz to 0.60*22.05 kHz. – keith Oct 25 '15 at 16:18
• Half-band filters can be made more efficient than filters with arbitrary cutoff frequencies. For IIR see two-path polyphase allpass filters (ldesoras.free.fr/prod.html#src_hiir) and for FIR note that half of samples of sinc(i/2) at integer i are zero. People may feel robbed if you remove too much from between 20 kHz and 22.05 kHz. With half-band filters you can preserve signal power, so if someone claims >20 kHz contributes to their listening experience, at least they have as much ultrasound in terms of power as they would if the signal was resampled ideally. – Olli Niemitalo Oct 27 '15 at 8:51
• I've rephrased my question: dsp.stackexchange.com/questions/26691/… – keith Oct 27 '15 at 14:02