3 #include "ardour/interpolation.h"
5 using namespace ARDOUR;
7 Interpolation::Interpolation() : _speed (1.0L), state (0)
11 Interpolation::~Interpolation()
13 state = src_delete (state);
17 Interpolation::set_speed (double new_speed)
20 src_set_ratio (state, 1.0/_speed);
24 Interpolation::reset_state ()
29 state = src_new (SRC_LINEAR, 1, &error);
34 Interpolation::add_channel_to (int input_buffer_size, int output_buffer_size)
38 /* Set up sample rate converter info. */
39 newdata.end_of_input = 0 ;
41 newdata.input_frames = input_buffer_size;
42 newdata.output_frames = output_buffer_size;
44 newdata.input_frames_used = 0 ;
45 newdata.output_frames_gen = 0 ;
47 newdata.src_ratio = 1.0/_speed;
49 data.push_back (newdata);
55 Interpolation::remove_channel_from ()
62 Interpolation::interpolate (int channel, nframes_t nframes, Sample *input, Sample *output)
64 data[channel].data_in = input;
65 data[channel].data_out = output;
67 data[channel].output_frames = nframes;
68 data[channel].src_ratio = 1.0/_speed;
70 if ((error = src_process (state, &data[channel]))) {
71 printf ("\nError : %s\n\n", src_strerror (error));
75 return data[channel].input_frames_used;