0
$\begingroup$

I want to apply some nonlinear processing to a signal, namely: I want to implement a tube emulation which adds warmth/harmonic distortion to a digital audio signal. I am worried about aliasing, so I figured out the following processing sequence:

  • Upsampling of the sample rate from $f_s$ to $2 \cdot f_s$
  • Applying an interpolation lowpass filter with $f_g = 0.5 f_s$ and a passband gain of $2$
  • Applying the nonlinear processing to the upsampled signal
  • Again applying a filter with with $f_g = 0.5 f_s$
  • Decimation back to $fs$.

My question arises at point 2, the interpolation filter. If I google this topic, it results in fascinating concepts like Lagrange interpolation, spline interpolation and polynominal interpolation and the math behind those seem far from trivial. Moreover, I don't understand why this is even needed - what is the reason why one would utilize one of those concepts rather than just running the signal through a run-off-the-mill IIR with sufficient stopband attenuation? The only thing I can understand is why the passband gain needs to be non-unity.

Also, although not main point of my question, feel free to point out any logical flaws that might be in my processing sequence. Thank you!

$\endgroup$
2
$\begingroup$

In step 1 you insert a zero-valued sample between each pair of successive original samples. This is a gain 0.5 operation. For example consider 0 Hz. You can calculate the signed 0 Hz amplitude or direct current (DC) offset simply as the mean of the sample values. Inserting the zero samples halves the mean, so the gain is 0.5, which you need to compensate for by a gain of 2.

Your 2x-oversampled samples represent values of the continuous band-limited signal exactly at the times of the original samples or exactly half-way between them. As you suggest, in step 2 you can use a discrete-time filter, which can be a finite-impulse-response (FIR) or an infinite-impulse-response (IIR) filter. If you would have an arbitrary real oversampling ratio such as 3.12897684124, you couldn't use a discrete-time filter, but would have to resort to continuous-time interpolation, which can be done using piece-wise polynomial splines.

$\endgroup$
  • $\begingroup$ Thanks for the answer. So just to be clear: Since I'm upsampling by an integer factor, the only purpose this interpolation filter does have is to reject any artifacts above 0.5 of original sample rate that apperar after upsampling, plus correction of the passband gain. To do so, I can utilize any type of lowpass filter that fits my overall system requirements best (in my specific case: real-time, no delay, no filter ringing -> high-order Butterworth IIR). Is this a correct summary? $\endgroup$ – UnbescholtenerBuerger Jun 5 '17 at 12:19
  • $\begingroup$ That sounds correct. Zero stuffing leaves spectral images which you filter out, and non-linear processing will also spread the spectrum, so you filter again. (I'd also consider minimum-phase FIR). $\endgroup$ – Olli Niemitalo Jun 5 '17 at 16:54
1
$\begingroup$

Short answer: you need interpolation to get rid of mirror spectra in the frequency domain.

Long answer: Let's assume $f_s = 48kHz$ to make the discussion easier.

Initially your frequency range goes from from -24kHz to +24kHz. After up-sampling your frequency range goes up to 48kHz. The key question is what happens to the new frequencies?

If you up-sample by inserting zeros, you get a periodic repetition of the spectrum. So the spectrum you have from -24kHz to 0kHz simply gets repeated from +24kHz to +48kHz. That's sort inverse aliasing.

However the spectrum that you want, is that of the original signal where the range from 24 kHz to 48kHz should be zero. So you need to cut that off with a low-pass filter. That's what an interpolation filter does: any time invariant interpolation is essentially a low pass filter.

An ideal filter would be a sinc function in the time domain, which is non-causal and of infinite length. That's not practical so a more realistic filter needs to be designed. In most cases, that's best done by formulating the requirements in the frequency domain: who much attenuation at what frequencies, how much ripple can you tolerate, do you care about phase etc.

$\endgroup$
  • $\begingroup$ non-causal ain't such a problem if a little delay is allowed. symmetric and infinite length is a problem. the easiest way i go about designing FIR interpolation filters is to assume finite length, even symmetry, and not worry about causality until the implementation. $\endgroup$ – robert bristow-johnson Jun 3 '17 at 11:45
0
$\begingroup$

You can actually use an IIR with appropriate attenuation. However, if you don't need realtime processing, it would be typical to run your signal through the IIR twice: once in forward, and once in backward direction, in order to get a net phase delay of zero. For realtime processing, reverse-time IIR is not feasible, so instead one tends to pitch for some compromise between linear phase and minimal phase.

Lagrange, spline, polynomial interpolation as such are not really lowpass filters. At best they can be mathematical tools useful for designing such lowpass filters under the constraints of realtime processing.

$\endgroup$
  • 1
    $\begingroup$ Lagrange, spline (do you mean Hermite polynomials), and such are low-pass filters. they are LTI and they display a low-pass function in the frequency domain. $\endgroup$ – robert bristow-johnson Jun 3 '17 at 10:42
  • $\begingroup$ actually Powell and Chau long ago suggested a way of doing filtfilt() (the reverse-time IIR) in real time using blocks of samples. it has a lotta delay but it's feasible. $\endgroup$ – robert bristow-johnson Jun 3 '17 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.