10

Every now and then I come across mention of sinc interpolation. Trying to read up on it, I have yet to get what it's about. I have done basic DSP work, have programmed stuff using FFT (using just a rectangular window on the data which i know is not so great), and have also done a lot of work with Bezier (and related) curves and polynomial interpolation.

Can anyone explain plainly how to do sinc interpolation, and why it's useful?

Thank you!!

Alan Wolfe
  • 1,259
  • I suspect you mean sinc interpolation? (You can search for "interpolation" in that article to get a first idea.) – joriki Jul 24 '15 at 16:18
  • updated, thanks :P haven't had coffee yet hehe – Alan Wolfe Jul 24 '15 at 16:19
  • 2
    Sinc interpolation is basically just supersampling by padding your spectrum and transforming back (with higher frequencies, the sample rate is now shorter and you get intermediate values). It's what you naturally get this way. – orion Jul 24 '15 at 16:30

2 Answers2

6

The Sinc function is a way to represent the waveform that each discrete sample is responsible for. In particular, it represents the waveform by adding no higher frequency content. Using the Sinc function to interpolate ensures no higher harmonics are added. The FFT of the interpolated waveform will have a sharp drop to zero frequency content above the original Nyquist frequency.

I repeat, each discrete sample is responsible for a sinc waveform. If your signal has $10$ samples, you need to sum all $10$ waveforms together.

A waveform with $N$ samples $x_i$, an interpolation evaluated at $j=0.5$.

$$\sum_{i=0}^{N-1} x_i \operatorname {sinc}(j-i)$$

where $$\operatorname {sinc}(i) = \begin{cases} \dfrac{\sin(\pi i)}{\pi i}, & \text{if $i \ne 0$} \\ 1, & \text{if $i = 0$} \end{cases}$$

That's right, a whole summation expression for each interpolation point. $N$ point waveform interpolated to $M$ new points takes $N \times M$ operations

Michael
  • 196
  • You say it doesn't add any higher frequencies, does it add any lower ones? – Alan Wolfe Apr 01 '16 at 21:18
  • No, it does not add lower frequencies. At first glance it might look like frequencies are being added, and I guess they kind of look like the Nyquist frequency (the obvious oscillations of a sinc function). But really this is the artifact of NOT having the higher frequencies added. – Michael Apr 02 '16 at 21:13
  • 1
    years later... I think I answered that comment incorrectly: Yes, lower frequencies are added that represent that one sample at the bandwidth you want (sinc frequency determines the bandwidth) – Michael Sep 04 '21 at 03:26
  • @Michael how can i prevent sinc interpolation from generating outliers at the end of the dataset? it seems to yield some strange values at the last data point, as depicted on this slide; the thick red line is what is being interpolated, arrows point at the anomalous points – ivan866 Aug 26 '22 at 15:58
  • 1
    @ivan866 You would need to pad your data. Either repeat the same last value or generate values that persist that final slope. At the end of your data set you run out of values, thus truncating the Sinc filter. It is the same as if your data were followed with zero values. That is why your data starts to 'ring' like there's a transition coming. – Michael Aug 29 '22 at 19:06
0

Interpolation = discrete-to-continuous conversion

Interpolation is used to reconstruct a continuous signal from a few discrete samples, a technique known as digital to analog conversion. While a discrete signal is undefined except at a few points in time (samples), the reconstructed signal is known at any time point. Thus some form of interpolation is required to fill the undefined values between samples.

Sinc function = spectrum of a rectangular function

Interpolation can be done in many ways. The particularity of the sinc interpolation is it's the only one mathematically perfect.

A function can be reformulated as a spectrum using a Fourier transform. For the rectangular function (boxcar function) the spectrum is a sinc pulse. This sinc spectrum contains an infinity of harmonics, though their amplitude rapidly decays.

Convolution with sinc pulses

What we want to do to reconstruct the signal is a convolution between the samples and scaled and shifted versions of sinc.

This technique is known as Whittaker–Shannon interpolation: "This is equivalent to filtering the impulse train with an ideal (brick-wall) low-pass filter with gain of 1 (or 0 dB) in the passband. If the sample rate is sufficiently high, this means that the baseband image (the original signal before sampling) is passed unchanged and the other images are removed by the brick-wall filter."


Method

Can anyone explain plainly how to do sinc interpolation?

Three steps are required to perform a sinc interpolation on discrete samples:

  • Create sinc pulses, one per sample, centered on the sample. As said sinc pulses have an infinite width, but the practical width will be limited to the signal duration. A sinc pulse is a continuous function, defined at any time, with a maximum amplitude of 1.

  • Multiply each pulse by the value of the sample. While the value of an isolated sinc pulse is accurate at only one instant, it contributes to the values at other instants.

  • Add all delayed and scaled sinc pulses.

*Example

enter image description here

Top-left: The continuous-time (unknown) signal and the known discrete samples.

Top-right: The sinc pulse created for sample 7 (8th sample). The pulse has its peak amplitude equal to the sample value (7.5). Other values are not correct but contribute to the final sum.

Bottom-left: 18 sinc pulses, each one delayed to match a given sample time, and scaled to match the sample value.

Bottom-right: All sinc pulses summed. Since pulses are continuous, the sum is defined at any time, not only at sampling times. The dotted curve is the original continuous-time signal, the dots are the samples, and the plain curve is the interpolation.

The sample signal shown above is a sum of two sinusoids: f(t) = 5 cos(2π f t + 3π/7) + sin(2π f/2 t + 9π/7) with f=2Hz. It would work the same for any number of sinusoids in the signal, as long as the greatest frequency doesn't exceed half the sampling rate (7.6Hz/2)

Actual use of sinc interpolation

Why it's useful?

It is useful when you are provided these samples:

enter image description here

and asked to reconstructed the original continuous signal between samples.

Any periodic signal, even very complex, can be broken down into sinusoids (using the Fourier transform or any other equivalent transform). According to Shannon sampling theorem, it's possible to perfectly reconstruct the details of any waveform if there are at least two samples per period for the sinusoid with the greatest frequency in the signal. This perfect reconstruction requires sinc pulse interpolation.

The tiny difference in the picture above is because the number of samples used is finite. Pulses before the first sample, and after the last sample are not created, thus are ignored in the sum.

Reconstruction is needed to convert a digital signal to an analog version. For example this is required to play a CD track which is only a collection of discrete amplitudes at given times, while the loudspeakers need to be driven by a continuous waveform.

While this perfect reconstruction is nice, still most conversions, including for a CD player, is done with other interpolating pulses, often staircase steps. This is easier (less expensive) and the difference is practically not perceived by the audience.

mins
  • 395