3 #include "ardour/interpolation.h"
5 using namespace ARDOUR;
7 LibSamplerateInterpolation::LibSamplerateInterpolation() : _speed (1.0L), state (0)
11 LibSamplerateInterpolation::~LibSamplerateInterpolation()
13 for (int i = 0; i < state.size(); i++) {
14 state[i] = src_delete (state[i]);
19 LibSamplerateInterpolation::set_speed (double new_speed)
22 for (int i = 0; i < state.size(); i++) {
23 src_set_ratio (state[i], 1.0/_speed);
28 LibSamplerateInterpolation::reset_state ()
30 printf("INTERPOLATION: reset_state()\n");
31 for (int i = 0; i < state.size(); i++) {
35 state[i] = src_new (SRC_SINC_FASTEST, 1, &error);
41 LibSamplerateInterpolation::add_channel_to (int input_buffer_size, int output_buffer_size)
43 SRC_DATA* newdata = new SRC_DATA;
45 /* Set up sample rate converter info. */
46 newdata->end_of_input = 0 ;
48 newdata->input_frames = input_buffer_size;
49 newdata->output_frames = output_buffer_size;
51 newdata->input_frames_used = 0 ;
52 newdata->output_frames_gen = 0 ;
54 newdata->src_ratio = 1.0/_speed;
56 data.push_back (newdata);
63 LibSamplerateInterpolation::remove_channel_from ()
73 LibSamplerateInterpolation::interpolate (int channel, nframes_t nframes, Sample *input, Sample *output)
76 printf ("ERROR: trying to interpolate with no channels\n");
80 data[channel]->data_in = input;
81 data[channel]->data_out = output;
83 data[channel]->input_frames = nframes * _speed;
84 data[channel]->output_frames = nframes;
85 data[channel]->src_ratio = 1.0/_speed;
87 if ((error = src_process (state[channel], data[channel]))) {
88 printf ("\nError : %s\n\n", src_strerror (error));
92 //printf("INTERPOLATION: channel %d input_frames_used: %d\n", channel, data[channel]->input_frames_used);
94 return data[channel]->input_frames_used;