# 8 Interpolation

## Explanation of the Concepts

When working with magnetic tape, it is easy to change to pitch of a sound by speeding up or slowing down the rate at which the tape passes by the play-head. In fact, most professional tape machines have various controls that allow the user to adjust the speed of the motor that feeds the tape for exactly this purpose. The same effect is not as easy to accomplish in the digital domain. Speeding up the tape would be analogous to changing the sample rate of a digital audio stream. Each case involves changing the duration that it takes to play a discrete segment to music. The sample-rate, however, is usually determined by the hardware, and we are not at liberty to change it ad libitum. If magnetic tape were flexible, we could achieve the same thing by stretching or contracting the tape, and leaving the speed constant. This is possible in the digital domain, but there is a caveat. Consider a mono audio buffer of 100 samples. If we want to stretch it out to twice its length, then obviously we will need to put it into a buffer of 200 samples. The original samples will be put into the odd-numbered time slots in the new buffer. The caveat is that we need to fill the even-numbered samples with something, and there is no way to know exactly what those samples should be. The best we can do is draw some sort of line or curve that connects the known samples to each other, and fill in the unknown samples with points that lie along that curve. This process is known as "Interpolation". There are a wide variety of mathematical curves that can be used to connect the dots, but here I will focus on two of the most common: Linear Interpolation, which is fast and easy to implement, and Cubic Spline, which is somewhat higher fidelity, marginally slower, and may cause clipping under certain circumstances.