using namespace ARDOUR;
-nframes_t
-LinearInterpolation::interpolate (int channel, nframes_t nframes, Sample *input, Sample *output)
+framecnt_t
+LinearInterpolation::interpolate (int channel, framecnt_t nframes, Sample *input, Sample *output)
{
// index in the input buffers
- nframes_t i = 0;
+ framecnt_t i = 0;
double acceleration;
double distance = 0.0;
}
distance = phase[channel];
- for (nframes_t outsample = 0; outsample < nframes; ++outsample) {
+ for (framecnt_t outsample = 0; outsample < nframes; ++outsample) {
i = floor(distance);
Sample fractional_phase_part = distance - i;
if (fractional_phase_part >= 1.0) {
return i;
}
-nframes_t
-CubicInterpolation::interpolate (int channel, nframes_t nframes, Sample *input, Sample *output)
+framecnt_t
+CubicInterpolation::interpolate (int channel, framecnt_t nframes, Sample *input, Sample *output)
{
// index in the input buffers
- nframes_t i = 0;
+ framecnt_t i = 0;
double acceleration;
double distance = 0.0;
if (_speed != _target_speed) {
acceleration = _target_speed - _speed;
} else {
- acceleration = 0.0;
+ acceleration = 0.0;
}
distance = phase[channel];
}
/* keep this condition out of the inner loop */
-
+
if (input && output) {
Sample inm1;
-
+
if (floor (distance) == 0.0) {
- /* best guess for the fake point we have to add to be able to interpolate at i == 0:
+ /* best guess for the fake point we have to add to be able to interpolate at i == 0:
.... maintain slope of first actual segment ...
*/
inm1 = input[i] - (input[i+1] - input[i]);
inm1 = input[i-1];
}
- for (nframes_t outsample = 0; outsample < nframes; ++outsample) {
+ for (framecnt_t outsample = 0; outsample < nframes; ++outsample) {
float f = floor (distance);
float fractional_phase_part = distance - f;
if (fractional_phase_part >= 1.0) {
fractional_phase_part -= 1.0;
++i;
- }
+ }
// Cubically interpolate into the output buffer: keep this inlined for speed and rely on compiler
// optimization to take care of the rest
fractional_phase_part * (3.0f * (input[i] - input[i+1]) - inm1 + input[i+2])));
distance += _speed + acceleration;
+ inm1 = input[i];
}
} else {
/* not sure that this is ever utilized - it implies that one of the input/output buffers is missing */
- for (nframes_t outsample = 0; outsample < nframes; ++outsample) {
+ for (framecnt_t outsample = 0; outsample < nframes; ++outsample) {
distance += _speed + acceleration;
}
}