ardour
interpolation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 1999-2010 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include <math.h>
21 #include <samplerate.h>
22 
24 #include "ardour/types.h"
25 
26 #ifndef __interpolation_h__
27 #define __interpolation_h__
28 
29 namespace ARDOUR {
30 
32 protected:
33  double _speed;
34  double _target_speed;
35 
36  // the idea is that when the speed is not 1.0, we have to
37  // interpolate between samples and then we have to store where we thought we were.
38  // rather than being at sample N or N+1, we were at N+0.8792922
39  std::vector<double> phase;
40 
41 public:
42  Interpolation () { _speed = 1.0; _target_speed = 1.0; }
43  ~Interpolation () { phase.clear(); }
44 
45  void set_speed (double new_speed) { _speed = new_speed; _target_speed = new_speed; }
46  void set_target_speed (double new_speed) { _target_speed = new_speed; }
47 
48  double target_speed() const { return _target_speed; }
49  double speed() const { return _speed; }
50 
51  void add_channel_to (int /*input_buffer_size*/, int /*output_buffer_size*/) { phase.push_back (0.0); }
52  void remove_channel_from () { phase.pop_back (); }
53 
54  void reset () {
55  for (size_t i = 0; i < phase.size(); i++) {
56  phase[i] = 0.0;
57  }
58  }
59 };
60 
62 public:
63  framecnt_t interpolate (int channel, framecnt_t nframes, Sample* input, Sample* output);
64 };
65 
67 public:
68  framecnt_t interpolate (int channel, framecnt_t nframes, Sample* input, Sample* output);
69 };
70 
71 class BufferSet;
72 
74 public:
75  framecnt_t distance (framecnt_t nframes, bool roll = true);
76 };
77 
78 } // namespace ARDOUR
79 
80 #endif
double target_speed() const
Definition: interpolation.h:48
std::vector< double > phase
Definition: interpolation.h:39
void set_speed(double new_speed)
Definition: interpolation.h:45
void add_channel_to(int, int)
Definition: interpolation.h:51
int64_t framecnt_t
Definition: types.h:76
float Sample
Definition: types.h:54
Definition: amp.h:29
#define LIBARDOUR_API
void set_target_speed(double new_speed)
Definition: interpolation.h:46
double speed() const
Definition: interpolation.h:49