1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rubber Band Library
5     An audio time-stretching and pitch-shifting library.
6     Copyright 2007-2021 Particular Programs Ltd.
7 
8     This program is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License as
10     published by the Free Software Foundation; either version 2 of the
11     License, or (at your option) any later version.  See the file
12     COPYING included with this distribution for more information.
13 
14     Alternatively, if you have a valid commercial licence for the
15     Rubber Band Library obtained by agreement with the copyright
16     holders, you may redistribute and/or modify it under the terms
17     described in that licence.
18 
19     If you wish to distribute code using the Rubber Band Library
20     under terms other than those of the GNU General Public License,
21     you must obtain a valid commercial licence before doing so.
22 */
23 
24 #include "StretcherImpl.h"
25 
26 
27 namespace RubberBand {
28 
29 
RubberBandStretcher(size_t sampleRate,size_t channels,Options options,double initialTimeRatio,double initialPitchScale)30 RubberBandStretcher::RubberBandStretcher(size_t sampleRate,
31                                          size_t channels,
32                                          Options options,
33                                          double initialTimeRatio,
34                                          double initialPitchScale) :
35     m_d(new Impl(sampleRate, channels, options,
36                  initialTimeRatio, initialPitchScale))
37 {
38 }
39 
~RubberBandStretcher()40 RubberBandStretcher::~RubberBandStretcher()
41 {
42     delete m_d;
43 }
44 
45 void
reset()46 RubberBandStretcher::reset()
47 {
48     m_d->reset();
49 }
50 
51 void
setTimeRatio(double ratio)52 RubberBandStretcher::setTimeRatio(double ratio)
53 {
54     m_d->setTimeRatio(ratio);
55 }
56 
57 void
setPitchScale(double scale)58 RubberBandStretcher::setPitchScale(double scale)
59 {
60     m_d->setPitchScale(scale);
61 }
62 
63 double
getTimeRatio() const64 RubberBandStretcher::getTimeRatio() const
65 {
66     return m_d->getTimeRatio();
67 }
68 
69 double
getPitchScale() const70 RubberBandStretcher::getPitchScale() const
71 {
72     return m_d->getPitchScale();
73 }
74 
75 size_t
getLatency() const76 RubberBandStretcher::getLatency() const
77 {
78     return m_d->getLatency();
79 }
80 
81 void
setTransientsOption(Options options)82 RubberBandStretcher::setTransientsOption(Options options)
83 {
84     m_d->setTransientsOption(options);
85 }
86 
87 void
setDetectorOption(Options options)88 RubberBandStretcher::setDetectorOption(Options options)
89 {
90     m_d->setDetectorOption(options);
91 }
92 
93 void
setPhaseOption(Options options)94 RubberBandStretcher::setPhaseOption(Options options)
95 {
96     m_d->setPhaseOption(options);
97 }
98 
99 void
setFormantOption(Options options)100 RubberBandStretcher::setFormantOption(Options options)
101 {
102     m_d->setFormantOption(options);
103 }
104 
105 void
setPitchOption(Options options)106 RubberBandStretcher::setPitchOption(Options options)
107 {
108     m_d->setPitchOption(options);
109 }
110 
111 void
setExpectedInputDuration(size_t samples)112 RubberBandStretcher::setExpectedInputDuration(size_t samples)
113 {
114     m_d->setExpectedInputDuration(samples);
115 }
116 
117 void
setMaxProcessSize(size_t samples)118 RubberBandStretcher::setMaxProcessSize(size_t samples)
119 {
120     m_d->setMaxProcessSize(samples);
121 }
122 
123 void
setKeyFrameMap(const std::map<size_t,size_t> & mapping)124 RubberBandStretcher::setKeyFrameMap(const std::map<size_t, size_t> &mapping)
125 {
126     m_d->setKeyFrameMap(mapping);
127 }
128 
129 size_t
getSamplesRequired() const130 RubberBandStretcher::getSamplesRequired() const
131 {
132     return m_d->getSamplesRequired();
133 }
134 
135 void
study(const float * const * input,size_t samples,bool final)136 RubberBandStretcher::study(const float *const *input, size_t samples,
137                            bool final)
138 {
139     m_d->study(input, samples, final);
140 }
141 
142 void
process(const float * const * input,size_t samples,bool final)143 RubberBandStretcher::process(const float *const *input, size_t samples,
144                              bool final)
145 {
146     m_d->process(input, samples, final);
147 }
148 
149 int
available() const150 RubberBandStretcher::available() const
151 {
152     return m_d->available();
153 }
154 
155 size_t
retrieve(float * const * output,size_t samples) const156 RubberBandStretcher::retrieve(float *const *output, size_t samples) const
157 {
158     return m_d->retrieve(output, samples);
159 }
160 
161 float
getFrequencyCutoff(int n) const162 RubberBandStretcher::getFrequencyCutoff(int n) const
163 {
164     return m_d->getFrequencyCutoff(n);
165 }
166 
167 void
setFrequencyCutoff(int n,float f)168 RubberBandStretcher::setFrequencyCutoff(int n, float f)
169 {
170     m_d->setFrequencyCutoff(n, f);
171 }
172 
173 size_t
getInputIncrement() const174 RubberBandStretcher::getInputIncrement() const
175 {
176     return m_d->getInputIncrement();
177 }
178 
179 std::vector<int>
getOutputIncrements() const180 RubberBandStretcher::getOutputIncrements() const
181 {
182     return m_d->getOutputIncrements();
183 }
184 
185 std::vector<float>
getPhaseResetCurve() const186 RubberBandStretcher::getPhaseResetCurve() const
187 {
188     return m_d->getPhaseResetCurve();
189 }
190 
191 std::vector<int>
getExactTimePoints() const192 RubberBandStretcher::getExactTimePoints() const
193 {
194     return m_d->getExactTimePoints();
195 }
196 
197 size_t
getChannelCount() const198 RubberBandStretcher::getChannelCount() const
199 {
200     return m_d->getChannelCount();
201 }
202 
203 void
calculateStretch()204 RubberBandStretcher::calculateStretch()
205 {
206     m_d->calculateStretch();
207 }
208 
209 void
setDebugLevel(int level)210 RubberBandStretcher::setDebugLevel(int level)
211 {
212     m_d->setDebugLevel(level);
213 }
214 
215 void
setDefaultDebugLevel(int level)216 RubberBandStretcher::setDefaultDebugLevel(int level)
217 {
218     Impl::setDefaultDebugLevel(level);
219 }
220 
221 }
222 
223