Sampling — Interpolation: Reading Between Samples

Our sampler can read its buffer at 0.5×, 0.944×, 1.5× or almost any other rate. But that creates a new problem: the read head often lands between stored samples.

From the previous page: changing playback rate changes pitch. If the read position advances by 0.944 samples each output step, positions such as 1000.944 and 1001.888 do not correspond to stored sample indices. We need to estimate what lies between them.

1. Samples exist at discrete positions

The dots below are stored sample values. Drag the dots vertically to reshape the tiny waveform, then drag the READ POSITION marker horizontally.

Left sample—
Right sample—
Fraction between—
Estimated output—

2. Three ways to answer “what is at 3.4?”

MethodIdeaBehaviour
Nearest neighbourUse whichever stored sample is closest.Very simple, but the output jumps abruptly from one value to the next.
Linear interpolationDraw a straight line between two neighbouring samples.Cheap, intuitive and much smoother.
Cubic interpolationUse neighbouring points to estimate a smoother curve.A practical local compromise: smooth, inexpensive and often visually convincing.
Sinc interpolationReconstruct from weighted sinc functions centred on the stored samples.The ideal band-limited reconstruction model; practical audio systems use finite/windowed approximations.
linear: y = y₀ + f(y₁ − y₀)

Here f is the fractional distance between the two stored samples. At position 3.4, we are 40% of the way from sample 3 to sample 4.

Why does Sinc look familiar? It is the practical link back to Whittaker–Shannon reconstruction. Ideal sinc interpolation uses contributions from all samples; real audio resamplers approximate this with finite/windowed sinc or related polyphase filters. Cubic interpolation is a simpler local method and is often perfectly adequate when computational simplicity matters.

3. Animate the read head

Now let the read position advance automatically. The rate controls how far the read head moves on each step.

Notice: at exactly 1×, an idealised read head can repeatedly land on integer positions. At most other rates it spends much of its time between samples, so an interpolation rule becomes important.

4. Interpolation is not time stretching

This distinction matters. Interpolation helps a sampler produce sensible values at fractional read positions. It improves the process of resampling, but pitch and duration are still coupled.

BUFFER → FRACTIONAL READ POSITION → INTERPOLATION → OUTPUT SAMPLE
So we still have the problem from our C2 sampler: play the buffer faster and it gets higher and shorter; play it slower and it gets lower and longer. Interpolation makes the reading smoother — it does not break that relationship.

5. Next: break the pitch–duration relationship

What if we want the pitch to move while the duration stays the same, or stretch a recording without lowering its pitch? That requires a different strategy: working with chunks, windows, overlap, spectral information or grains rather than simply moving one read head through the buffer faster or slower.

Next: Time Stretching & Pitch Shifting — from overlap/add and WSOLA to the phase vocoder and granular approaches.