interpolation

Audio amplitude control

As explained in MSP Tutorial 2, in order to avoid creating clicks in audio when you change the amplitude, you need to interpolate smoothly from one gain value to another. Example A in this patch shows how to use the line~ object to do that. The gain value from the number box is combined with a transition time in the pack object (10 ms in this case) and the two numbers are sent as a list to line~.

Linear interpolation to a new value

The rampsmooth~ object is useful for smoothing MSP signals, a sort of lowpass filter, especially appropriate for smoothing out overly sudden changes in control signals. The left part of this patch demonstrates the fact that internally rampsmooth~ is just doing linear interpolation. Whenever the input signal changes, rampsmooth~ heads toward that value from wherever it currently is, using the specified number of samples (depending on whether it has to increase or decrease) to get there.

Interpolation with line or line~

The line~ object outputs a signal and interpolates sample-by-sample from wherever it currently is to wherever you tell it to go, in the amount of time you specify. So, if it is currently sending out a signal value of 0.5 and you tell it to go to 0.8 in 10 ms, it will start going to 0.8 and get there in 441 samples (assuming a sample rate of 44,100), sending out signal values like 0.50068, 0.50136, etc. till it arrives at 0.8, then it will stay there till it gets a new message.