2 #include "ardour/interpolation.h"
4 using namespace ARDOUR;
7 LinearInterpolation::interpolate (nframes_t nframes, Sample *input, Sample *output)
9 // the idea is that when the speed is not 1.0, we have to
10 // interpolate between samples and then we have to store where we thought we were.
11 // rather than being at sample N or N+1, we were at N+0.8792922
13 // index in the input buffers
17 double distance = 0.0;
19 if (_speed != _target_speed) {
20 acceleration = _target_speed - _speed;
25 for (nframes_t outsample = 0; outsample < nframes; ++outsample) {
27 Sample fractional_phase_part = distance - i;
29 if (input && output) {
30 // Linearly interpolate into the output buffer
32 input[i] * (1.0f - fractional_phase_part) +
33 input[i+1] * fractional_phase_part;
35 distance += _speed + acceleration;
38 i = (distance + 0.5L);