diff options
Diffstat (limited to 'libs/ardour/interpolation.cc')
-rw-r--r-- | libs/ardour/interpolation.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/ardour/interpolation.cc b/libs/ardour/interpolation.cc index bccaa45553..79b43bc58e 100644 --- a/libs/ardour/interpolation.cc +++ b/libs/ardour/interpolation.cc @@ -21,6 +21,7 @@ #include <cstdio> #include "ardour/interpolation.h" +#include "ardour/midi_buffer.h" using namespace ARDOUR; @@ -150,3 +151,38 @@ CubicInterpolation::interpolate (int channel, framecnt_t nframes, Sample *input, return i; } + +framecnt_t +CubicMidiInterpolation::distance (framecnt_t nframes, bool roll) +{ + assert(phase.size() == 1); + + framecnt_t i = 0; + + double acceleration; + double distance = 0.0; + + if (nframes < 3) { + return nframes; + } + + if (_speed != _target_speed) { + acceleration = _target_speed - _speed; + } else { + acceleration = 0.0; + } + + distance = phase[0]; + + for (framecnt_t outsample = 0; outsample < nframes; ++outsample) { + distance += _speed + acceleration; + } + + if (roll) { + phase[0] = distance - floor(distance); + } + + i = floor(distance); + + return i; +} |