Add faster/finer option

This commit is contained in:
Chris Cannam
2022-05-26 15:07:43 +01:00
parent c3309f56c1
commit b07f74e5b9
2 changed files with 20 additions and 10 deletions

View File

@@ -317,7 +317,10 @@ public:
OptionPitchHighConsistency = 0x04000000, OptionPitchHighConsistency = 0x04000000,
OptionChannelsApart = 0x00000000, OptionChannelsApart = 0x00000000,
OptionChannelsTogether = 0x10000000 OptionChannelsTogether = 0x10000000,
OptionEngineFaster = 0x00000000,
OptionEngineFiner = 0x20000000
// n.b. Options is int, so we must stop before 0x80000000 // n.b. Options is int, so we must stop before 0x80000000
}; };

View File

@@ -27,21 +27,23 @@
namespace RubberBand { namespace RubberBand {
//#define FASTER 1
RubberBandStretcher::RubberBandStretcher(size_t sampleRate, RubberBandStretcher::RubberBandStretcher(size_t sampleRate,
size_t channels, size_t channels,
Options options, Options options,
double initialTimeRatio, double initialTimeRatio,
double initialPitchScale) : double initialPitchScale) :
/*!!! m_d
m_d(new Impl(sampleRate, channels, options, (!(options & OptionEngineFiner) ?
initialTimeRatio, initialPitchScale)) new Impl(sampleRate, channels, options,
*/ initialTimeRatio, initialPitchScale)
m_d(nullptr), : nullptr),
//!!! +logger m_r3d
m_r3d(new R3StretcherImpl(R3StretcherImpl::Parameters(sampleRate, channels), ((options & OptionEngineFiner) ?
initialTimeRatio, new R3StretcherImpl(R3StretcherImpl::Parameters(sampleRate, channels),
initialPitchScale)) initialTimeRatio, initialPitchScale)
: nullptr)
{ {
} }
@@ -183,6 +185,7 @@ float
RubberBandStretcher::getFrequencyCutoff(int n) const RubberBandStretcher::getFrequencyCutoff(int n) const
{ {
if (m_d) return m_d->getFrequencyCutoff(n); if (m_d) return m_d->getFrequencyCutoff(n);
else return {};
} }
void void
@@ -195,24 +198,28 @@ size_t
RubberBandStretcher::getInputIncrement() const RubberBandStretcher::getInputIncrement() const
{ {
if (m_d) return m_d->getInputIncrement(); if (m_d) return m_d->getInputIncrement();
else return {};
} }
std::vector<int> std::vector<int>
RubberBandStretcher::getOutputIncrements() const RubberBandStretcher::getOutputIncrements() const
{ {
if (m_d) return m_d->getOutputIncrements(); if (m_d) return m_d->getOutputIncrements();
else return {};
} }
std::vector<float> std::vector<float>
RubberBandStretcher::getPhaseResetCurve() const RubberBandStretcher::getPhaseResetCurve() const
{ {
if (m_d) return m_d->getPhaseResetCurve(); if (m_d) return m_d->getPhaseResetCurve();
else return {};
} }
std::vector<int> std::vector<int>
RubberBandStretcher::getExactTimePoints() const RubberBandStretcher::getExactTimePoints() const
{ {
if (m_d) return m_d->getExactTimePoints(); if (m_d) return m_d->getExactTimePoints();
else return {};
} }
size_t size_t