Rename/rejig so as to have just a single Impl and then R2 and R3 stretcher classes
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
you must obtain a valid commercial licence before doing so.
|
||||
*/
|
||||
|
||||
#include "StretcherImpl.h"
|
||||
#include "R2Stretcher.h"
|
||||
|
||||
#include "PercussiveAudioCurve.h"
|
||||
#include "HighFrequencyAudioCurve.h"
|
||||
@@ -51,21 +51,21 @@ using std::min;
|
||||
namespace RubberBand {
|
||||
|
||||
const size_t
|
||||
RubberBandStretcher::Impl::m_defaultIncrement = 256;
|
||||
R2Stretcher::m_defaultIncrement = 256;
|
||||
|
||||
const size_t
|
||||
RubberBandStretcher::Impl::m_defaultFftSize = 2048;
|
||||
R2Stretcher::m_defaultFftSize = 2048;
|
||||
|
||||
int
|
||||
RubberBandStretcher::Impl::m_defaultDebugLevel = 0;
|
||||
R2Stretcher::m_defaultDebugLevel = 0;
|
||||
|
||||
static bool _initialised = false;
|
||||
|
||||
RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
size_t channels,
|
||||
Options options,
|
||||
double initialTimeRatio,
|
||||
double initialPitchScale) :
|
||||
R2Stretcher::R2Stretcher(size_t sampleRate,
|
||||
size_t channels,
|
||||
RubberBandStretcher::Options options,
|
||||
double initialTimeRatio,
|
||||
double initialPitchScale) :
|
||||
m_sampleRate(sampleRate),
|
||||
m_channels(channels),
|
||||
m_timeRatio(initialTimeRatio),
|
||||
@@ -111,7 +111,7 @@ RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
}
|
||||
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "RubberBandStretcher::Impl::Impl: rate = " << m_sampleRate << ", options = " << options << endl;
|
||||
cerr << "R2Stretcher::R2Stretcher: rate = " << m_sampleRate << ", options = " << options << endl;
|
||||
}
|
||||
|
||||
// Window size will vary according to the audio sample rate, but
|
||||
@@ -120,15 +120,17 @@ RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
// if (m_rateMultiple < 1.f) m_rateMultiple = 1.f;
|
||||
m_baseFftSize = roundUp(int(m_defaultFftSize * m_rateMultiple));
|
||||
|
||||
if ((options & OptionWindowShort) || (options & OptionWindowLong)) {
|
||||
if ((options & OptionWindowShort) && (options & OptionWindowLong)) {
|
||||
cerr << "RubberBandStretcher::Impl::Impl: Cannot specify OptionWindowLong and OptionWindowShort together; falling back to OptionWindowStandard" << endl;
|
||||
} else if (options & OptionWindowShort) {
|
||||
if ((options & RubberBandStretcher::OptionWindowShort) ||
|
||||
(options & RubberBandStretcher::OptionWindowLong)) {
|
||||
if ((options & RubberBandStretcher::OptionWindowShort) &&
|
||||
(options & RubberBandStretcher::OptionWindowLong)) {
|
||||
cerr << "R2Stretcher::R2Stretcher: Cannot specify OptionWindowLong and OptionWindowShort together; falling back to OptionWindowStandard" << endl;
|
||||
} else if (options & RubberBandStretcher::OptionWindowShort) {
|
||||
m_baseFftSize = m_baseFftSize / 2;
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "setting baseFftSize to " << m_baseFftSize << endl;
|
||||
}
|
||||
} else if (options & OptionWindowLong) {
|
||||
} else if (options & RubberBandStretcher::OptionWindowLong) {
|
||||
m_baseFftSize = m_baseFftSize * 2;
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "setting baseFftSize to " << m_baseFftSize << endl;
|
||||
@@ -141,7 +143,7 @@ RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
m_maxProcessSize = m_aWindowSize;
|
||||
}
|
||||
|
||||
if (m_options & OptionProcessRealTime) {
|
||||
if (m_options & RubberBandStretcher::OptionProcessRealTime) {
|
||||
m_realtime = true;
|
||||
}
|
||||
|
||||
@@ -152,9 +154,9 @@ RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
|
||||
if (m_realtime) {
|
||||
m_threaded = false;
|
||||
} else if (m_options & OptionThreadingNever) {
|
||||
} else if (m_options & RubberBandStretcher::OptionThreadingNever) {
|
||||
m_threaded = false;
|
||||
} else if (!(m_options & OptionThreadingAlways) &&
|
||||
} else if (!(m_options & RubberBandStretcher::OptionThreadingAlways) &&
|
||||
!system_is_multiprocessor()) {
|
||||
m_threaded = false;
|
||||
}
|
||||
@@ -168,7 +170,7 @@ RubberBandStretcher::Impl::Impl(size_t sampleRate,
|
||||
configure();
|
||||
}
|
||||
|
||||
RubberBandStretcher::Impl::~Impl()
|
||||
R2Stretcher::~R2Stretcher()
|
||||
{
|
||||
#ifndef NO_THREADING
|
||||
if (m_threaded) {
|
||||
@@ -205,7 +207,7 @@ RubberBandStretcher::Impl::~Impl()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::reset()
|
||||
R2Stretcher::reset()
|
||||
{
|
||||
#ifndef NO_THREADING
|
||||
if (m_threaded) {
|
||||
@@ -247,11 +249,11 @@ RubberBandStretcher::Impl::reset()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setTimeRatio(double ratio)
|
||||
R2Stretcher::setTimeRatio(double ratio)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
if (m_mode == Studying || m_mode == Processing) {
|
||||
cerr << "RubberBandStretcher::Impl::setTimeRatio: Cannot set ratio while studying or processing in non-RT mode" << endl;
|
||||
cerr << "R2Stretcher::setTimeRatio: Cannot set ratio while studying or processing in non-RT mode" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -263,11 +265,11 @@ RubberBandStretcher::Impl::setTimeRatio(double ratio)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setPitchScale(double fs)
|
||||
R2Stretcher::setPitchScale(double fs)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
if (m_mode == Studying || m_mode == Processing) {
|
||||
cerr << "RubberBandStretcher::Impl::setPitchScale: Cannot set ratio while studying or processing in non-RT mode" << endl;
|
||||
cerr << "R2Stretcher::setPitchScale: Cannot set ratio while studying or processing in non-RT mode" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -281,7 +283,7 @@ RubberBandStretcher::Impl::setPitchScale(double fs)
|
||||
|
||||
reconfigure();
|
||||
|
||||
if (!(m_options & OptionPitchHighConsistency) &&
|
||||
if (!(m_options & RubberBandStretcher::OptionPitchHighConsistency) &&
|
||||
(was1 || resampleBeforeStretching() != rbs) &&
|
||||
m_pitchScale != 1.f) {
|
||||
|
||||
@@ -295,19 +297,19 @@ RubberBandStretcher::Impl::setPitchScale(double fs)
|
||||
}
|
||||
|
||||
double
|
||||
RubberBandStretcher::Impl::getTimeRatio() const
|
||||
R2Stretcher::getTimeRatio() const
|
||||
{
|
||||
return m_timeRatio;
|
||||
}
|
||||
|
||||
double
|
||||
RubberBandStretcher::Impl::getPitchScale() const
|
||||
R2Stretcher::getPitchScale() const
|
||||
{
|
||||
return m_pitchScale;
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setExpectedInputDuration(size_t samples)
|
||||
R2Stretcher::setExpectedInputDuration(size_t samples)
|
||||
{
|
||||
if (samples == m_expectedInputDuration) return;
|
||||
m_expectedInputDuration = samples;
|
||||
@@ -316,7 +318,7 @@ RubberBandStretcher::Impl::setExpectedInputDuration(size_t samples)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setMaxProcessSize(size_t samples)
|
||||
R2Stretcher::setMaxProcessSize(size_t samples)
|
||||
{
|
||||
if (samples <= m_maxProcessSize) return;
|
||||
m_maxProcessSize = samples;
|
||||
@@ -325,15 +327,15 @@ RubberBandStretcher::Impl::setMaxProcessSize(size_t samples)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setKeyFrameMap(const std::map<size_t, size_t> &
|
||||
R2Stretcher::setKeyFrameMap(const std::map<size_t, size_t> &
|
||||
mapping)
|
||||
{
|
||||
if (m_realtime) {
|
||||
cerr << "RubberBandStretcher::Impl::setKeyFrameMap: Cannot specify key frame map in RT mode" << endl;
|
||||
cerr << "R2Stretcher::setKeyFrameMap: Cannot specify key frame map in RT mode" << endl;
|
||||
return;
|
||||
}
|
||||
if (m_mode == Processing) {
|
||||
cerr << "RubberBandStretcher::Impl::setKeyFrameMap: Cannot specify key frame map after process() has begun" << endl;
|
||||
cerr << "R2Stretcher::setKeyFrameMap: Cannot specify key frame map after process() has begun" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,7 +345,7 @@ RubberBandStretcher::Impl::setKeyFrameMap(const std::map<size_t, size_t> &
|
||||
}
|
||||
|
||||
float
|
||||
RubberBandStretcher::Impl::getFrequencyCutoff(int n) const
|
||||
R2Stretcher::getFrequencyCutoff(int n) const
|
||||
{
|
||||
switch (n) {
|
||||
case 0: return m_freq0;
|
||||
@@ -354,7 +356,7 @@ RubberBandStretcher::Impl::getFrequencyCutoff(int n) const
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setFrequencyCutoff(int n, float f)
|
||||
R2Stretcher::setFrequencyCutoff(int n, float f)
|
||||
{
|
||||
switch (n) {
|
||||
case 0: m_freq0 = f; break;
|
||||
@@ -364,7 +366,7 @@ RubberBandStretcher::Impl::setFrequencyCutoff(int n, float f)
|
||||
}
|
||||
|
||||
double
|
||||
RubberBandStretcher::Impl::getEffectiveRatio() const
|
||||
R2Stretcher::getEffectiveRatio() const
|
||||
{
|
||||
// Returns the ratio that the internal time stretcher needs to
|
||||
// achieve, not the resulting duration ratio of the output (which
|
||||
@@ -381,7 +383,7 @@ RubberBandStretcher::Impl::getEffectiveRatio() const
|
||||
}
|
||||
|
||||
size_t
|
||||
RubberBandStretcher::Impl::roundUp(size_t value)
|
||||
R2Stretcher::roundUp(size_t value)
|
||||
{
|
||||
if (!(value & (value - 1))) return value;
|
||||
int bits = 0;
|
||||
@@ -391,7 +393,7 @@ RubberBandStretcher::Impl::roundUp(size_t value)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::calculateSizes()
|
||||
R2Stretcher::calculateSizes()
|
||||
{
|
||||
size_t inputIncrement = m_defaultIncrement;
|
||||
size_t windowSize = m_baseFftSize;
|
||||
@@ -511,7 +513,7 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
|
||||
m_fftSize = windowSize;
|
||||
|
||||
if (m_options & OptionSmoothingOn) {
|
||||
if (m_options & RubberBandStretcher::OptionSmoothingOn) {
|
||||
m_aWindowSize = windowSize * 2;
|
||||
m_sWindowSize = windowSize * 2;
|
||||
} else {
|
||||
@@ -565,7 +567,7 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::configure()
|
||||
R2Stretcher::configure()
|
||||
{
|
||||
if (m_debugLevel > 0) {
|
||||
std::cerr << "configure[" << this << "]: realtime = " << m_realtime << ", pitch scale = "
|
||||
@@ -652,7 +654,7 @@ RubberBandStretcher::Impl::configure()
|
||||
}
|
||||
|
||||
if (m_pitchScale != 1.0 ||
|
||||
(m_options & OptionPitchHighConsistency) ||
|
||||
(m_options & RubberBandStretcher::OptionPitchHighConsistency) ||
|
||||
m_realtime) {
|
||||
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
@@ -698,7 +700,7 @@ RubberBandStretcher::Impl::configure()
|
||||
delete m_stretchCalculator;
|
||||
m_stretchCalculator = new StretchCalculator
|
||||
(m_sampleRate, m_increment,
|
||||
!(m_options & OptionTransientsSmooth));
|
||||
!(m_options & RubberBandStretcher::OptionTransientsSmooth));
|
||||
|
||||
m_stretchCalculator->setDebugLevel(m_debugLevel);
|
||||
m_inputDuration = 0;
|
||||
@@ -727,7 +729,7 @@ RubberBandStretcher::Impl::configure()
|
||||
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::reconfigure()
|
||||
R2Stretcher::reconfigure()
|
||||
{
|
||||
if (!m_realtime) {
|
||||
if (m_mode == Studying) {
|
||||
@@ -836,43 +838,50 @@ RubberBandStretcher::Impl::reconfigure()
|
||||
}
|
||||
|
||||
size_t
|
||||
RubberBandStretcher::Impl::getLatency() const
|
||||
R2Stretcher::getLatency() const
|
||||
{
|
||||
if (!m_realtime) return 0;
|
||||
return lrint((m_aWindowSize/2) / m_pitchScale);
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setTransientsOption(Options options)
|
||||
R2Stretcher::setTransientsOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
cerr << "RubberBandStretcher::Impl::setTransientsOption: Not permissible in non-realtime mode" << endl;
|
||||
cerr << "R2Stretcher::setTransientsOption: Not permissible in non-realtime mode" << endl;
|
||||
return;
|
||||
}
|
||||
int mask = (OptionTransientsMixed | OptionTransientsSmooth | OptionTransientsCrisp);
|
||||
int mask = (RubberBandStretcher::OptionTransientsMixed |
|
||||
RubberBandStretcher::OptionTransientsSmooth |
|
||||
RubberBandStretcher::OptionTransientsCrisp);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
|
||||
m_stretchCalculator->setUseHardPeaks
|
||||
(!(m_options & OptionTransientsSmooth));
|
||||
(!(m_options & RubberBandStretcher::OptionTransientsSmooth));
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setDetectorOption(Options options)
|
||||
R2Stretcher::setDetectorOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
cerr << "RubberBandStretcher::Impl::setDetectorOption: Not permissible in non-realtime mode" << endl;
|
||||
cerr << "R2Stretcher::setDetectorOption: Not permissible in non-realtime mode" << endl;
|
||||
return;
|
||||
}
|
||||
int mask = (OptionDetectorPercussive | OptionDetectorCompound | OptionDetectorSoft);
|
||||
int mask = (RubberBandStretcher::OptionDetectorPercussive |
|
||||
RubberBandStretcher::OptionDetectorCompound |
|
||||
RubberBandStretcher::OptionDetectorSoft);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
|
||||
CompoundAudioCurve::Type dt = CompoundAudioCurve::CompoundDetector;
|
||||
if (m_options & OptionDetectorPercussive) dt = CompoundAudioCurve::PercussiveDetector;
|
||||
else if (m_options & OptionDetectorSoft) dt = CompoundAudioCurve::SoftDetector;
|
||||
if (m_options & RubberBandStretcher::OptionDetectorPercussive) {
|
||||
dt = CompoundAudioCurve::PercussiveDetector;
|
||||
} else if (m_options & RubberBandStretcher::OptionDetectorSoft) {
|
||||
dt = CompoundAudioCurve::SoftDetector;
|
||||
}
|
||||
|
||||
if (dt == m_detectorType) return;
|
||||
m_detectorType = dt;
|
||||
@@ -883,36 +892,38 @@ RubberBandStretcher::Impl::setDetectorOption(Options options)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setPhaseOption(Options options)
|
||||
R2Stretcher::setPhaseOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
int mask = (OptionPhaseLaminar | OptionPhaseIndependent);
|
||||
int mask = (RubberBandStretcher::OptionPhaseLaminar |
|
||||
RubberBandStretcher::OptionPhaseIndependent);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setFormantOption(Options options)
|
||||
R2Stretcher::setFormantOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
int mask = (OptionFormantShifted | OptionFormantPreserved);
|
||||
int mask = (RubberBandStretcher::OptionFormantShifted |
|
||||
RubberBandStretcher::OptionFormantPreserved);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setPitchOption(Options options)
|
||||
R2Stretcher::setPitchOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
cerr << "RubberBandStretcher::Impl::setPitchOption: Pitch option is not used in non-RT mode" << endl;
|
||||
cerr << "R2Stretcher::setPitchOption: Pitch option is not used in non-RT mode" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Options prior = m_options;
|
||||
RubberBandStretcher::Options prior = m_options;
|
||||
|
||||
int mask = (OptionPitchHighQuality |
|
||||
OptionPitchHighSpeed |
|
||||
OptionPitchHighConsistency);
|
||||
int mask = (RubberBandStretcher::OptionPitchHighQuality |
|
||||
RubberBandStretcher::OptionPitchHighSpeed |
|
||||
RubberBandStretcher::OptionPitchHighConsistency);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
@@ -921,19 +932,19 @@ RubberBandStretcher::Impl::setPitchOption(Options options)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::study(const float *const *input, size_t samples, bool final)
|
||||
R2Stretcher::study(const float *const *input, size_t samples, bool final)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::study");
|
||||
Profiler profiler("R2Stretcher::study");
|
||||
|
||||
if (m_realtime) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "RubberBandStretcher::Impl::study: Not meaningful in realtime mode" << endl;
|
||||
cerr << "R2Stretcher::study: Not meaningful in realtime mode" << endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mode == Processing || m_mode == Finished) {
|
||||
cerr << "RubberBandStretcher::Impl::study: Cannot study after processing" << endl;
|
||||
cerr << "R2Stretcher::study: Cannot study after processing" << endl;
|
||||
return;
|
||||
}
|
||||
m_mode = Studying;
|
||||
@@ -1071,7 +1082,7 @@ RubberBandStretcher::Impl::study(const float *const *input, size_t samples, bool
|
||||
}
|
||||
|
||||
vector<int>
|
||||
RubberBandStretcher::Impl::getOutputIncrements() const
|
||||
R2Stretcher::getOutputIncrements() const
|
||||
{
|
||||
if (!m_realtime) {
|
||||
return m_outputIncrements;
|
||||
@@ -1085,7 +1096,7 @@ RubberBandStretcher::Impl::getOutputIncrements() const
|
||||
}
|
||||
|
||||
vector<float>
|
||||
RubberBandStretcher::Impl::getPhaseResetCurve() const
|
||||
R2Stretcher::getPhaseResetCurve() const
|
||||
{
|
||||
if (!m_realtime) {
|
||||
return m_phaseResetDf;
|
||||
@@ -1099,7 +1110,7 @@ RubberBandStretcher::Impl::getPhaseResetCurve() const
|
||||
}
|
||||
|
||||
vector<int>
|
||||
RubberBandStretcher::Impl::getExactTimePoints() const
|
||||
R2Stretcher::getExactTimePoints() const
|
||||
{
|
||||
std::vector<int> points;
|
||||
if (!m_realtime) {
|
||||
@@ -1113,9 +1124,9 @@ RubberBandStretcher::Impl::getExactTimePoints() const
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::calculateStretch()
|
||||
R2Stretcher::calculateStretch()
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::calculateStretch");
|
||||
Profiler profiler("R2Stretcher::calculateStretch");
|
||||
|
||||
size_t inputDuration = m_inputDuration;
|
||||
|
||||
@@ -1156,16 +1167,16 @@ RubberBandStretcher::Impl::calculateStretch()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::setDebugLevel(int level)
|
||||
R2Stretcher::setDebugLevel(int level)
|
||||
{
|
||||
m_debugLevel = level;
|
||||
if (m_stretchCalculator) m_stretchCalculator->setDebugLevel(level);
|
||||
}
|
||||
|
||||
size_t
|
||||
RubberBandStretcher::Impl::getSamplesRequired() const
|
||||
R2Stretcher::getSamplesRequired() const
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::getSamplesRequired");
|
||||
Profiler profiler("R2Stretcher::getSamplesRequired");
|
||||
|
||||
size_t reqd = 0;
|
||||
|
||||
@@ -1214,12 +1225,12 @@ RubberBandStretcher::Impl::getSamplesRequired() const
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bool final)
|
||||
R2Stretcher::process(const float *const *input, size_t samples, bool final)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::process");
|
||||
Profiler profiler("R2Stretcher::process");
|
||||
|
||||
if (m_mode == Finished) {
|
||||
cerr << "RubberBandStretcher::Impl::process: Cannot process again after final chunk" << endl;
|
||||
cerr << "R2Stretcher::process: Cannot process again after final chunk" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,21 +42,16 @@
|
||||
namespace RubberBand
|
||||
{
|
||||
|
||||
#ifdef PROCESS_SAMPLE_TYPE
|
||||
typedef PROCESS_SAMPLE_TYPE process_t;
|
||||
#else
|
||||
typedef double process_t;
|
||||
#endif
|
||||
|
||||
class AudioCurveCalculator;
|
||||
class StretchCalculator;
|
||||
|
||||
class RubberBandStretcher::Impl
|
||||
class R2Stretcher
|
||||
{
|
||||
public:
|
||||
Impl(size_t sampleRate, size_t channels, Options options,
|
||||
double initialTimeRatio, double initialPitchScale);
|
||||
~Impl();
|
||||
R2Stretcher(size_t sampleRate, size_t channels,
|
||||
RubberBandStretcher::Options options,
|
||||
double initialTimeRatio, double initialPitchScale);
|
||||
~R2Stretcher();
|
||||
|
||||
void reset();
|
||||
void setTimeRatio(double ratio);
|
||||
@@ -67,11 +62,11 @@ public:
|
||||
|
||||
size_t getLatency() const;
|
||||
|
||||
void setTransientsOption(Options);
|
||||
void setDetectorOption(Options);
|
||||
void setPhaseOption(Options);
|
||||
void setFormantOption(Options);
|
||||
void setPitchOption(Options);
|
||||
void setTransientsOption(RubberBandStretcher::Options);
|
||||
void setDetectorOption(RubberBandStretcher::Options);
|
||||
void setPhaseOption(RubberBandStretcher::Options);
|
||||
void setFormantOption(RubberBandStretcher::Options);
|
||||
void setPitchOption(RubberBandStretcher::Options);
|
||||
|
||||
void setExpectedInputDuration(size_t samples);
|
||||
void setMaxProcessSize(size_t samples);
|
||||
@@ -178,7 +173,7 @@ protected:
|
||||
#endif
|
||||
|
||||
bool m_realtime;
|
||||
Options m_options;
|
||||
RubberBandStretcher::Options m_options;
|
||||
int m_debugLevel;
|
||||
|
||||
enum ProcessMode {
|
||||
@@ -203,12 +198,12 @@ protected:
|
||||
class ProcessThread : public Thread
|
||||
{
|
||||
public:
|
||||
ProcessThread(Impl *s, size_t c);
|
||||
ProcessThread(R2Stretcher *s, size_t c);
|
||||
void run();
|
||||
void signalDataAvailable();
|
||||
void abandon();
|
||||
private:
|
||||
Impl *m_s;
|
||||
R2Stretcher *m_s;
|
||||
size_t m_channel;
|
||||
Condition m_dataAvailable;
|
||||
bool m_abandoning;
|
||||
@@ -31,27 +31,27 @@
|
||||
namespace RubberBand
|
||||
{
|
||||
|
||||
RubberBandStretcher::Impl::ChannelData::ChannelData(size_t windowSize,
|
||||
size_t fftSize,
|
||||
size_t outbufSize)
|
||||
R2Stretcher::ChannelData::ChannelData(size_t windowSize,
|
||||
size_t fftSize,
|
||||
size_t outbufSize)
|
||||
{
|
||||
std::set<size_t> s;
|
||||
construct(s, windowSize, fftSize, outbufSize);
|
||||
}
|
||||
|
||||
RubberBandStretcher::Impl::ChannelData::ChannelData(const std::set<size_t> &sizes,
|
||||
size_t initialWindowSize,
|
||||
size_t initialFftSize,
|
||||
size_t outbufSize)
|
||||
R2Stretcher::ChannelData::ChannelData(const std::set<size_t> &sizes,
|
||||
size_t initialWindowSize,
|
||||
size_t initialFftSize,
|
||||
size_t outbufSize)
|
||||
{
|
||||
construct(sizes, initialWindowSize, initialFftSize, outbufSize);
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ChannelData::construct(const std::set<size_t> &sizes,
|
||||
size_t initialWindowSize,
|
||||
size_t initialFftSize,
|
||||
size_t outbufSize)
|
||||
R2Stretcher::ChannelData::construct(const std::set<size_t> &sizes,
|
||||
size_t initialWindowSize,
|
||||
size_t initialFftSize,
|
||||
size_t outbufSize)
|
||||
{
|
||||
size_t maxSize = initialWindowSize * 2;
|
||||
if (initialFftSize > maxSize) maxSize = initialFftSize;
|
||||
@@ -114,7 +114,7 @@ RubberBandStretcher::Impl::ChannelData::construct(const std::set<size_t> &sizes,
|
||||
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ChannelData::setSizes(size_t windowSize,
|
||||
R2Stretcher::ChannelData::setSizes(size_t windowSize,
|
||||
size_t fftSize)
|
||||
{
|
||||
// std::cerr << "ChannelData::setSizes: windowSize = " << windowSize << ", fftSize = " << fftSize << std::endl;
|
||||
@@ -206,7 +206,7 @@ RubberBandStretcher::Impl::ChannelData::setSizes(size_t windowSize,
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ChannelData::setOutbufSize(size_t outbufSize)
|
||||
R2Stretcher::ChannelData::setOutbufSize(size_t outbufSize)
|
||||
{
|
||||
size_t oldSize = outbuf->getSize();
|
||||
|
||||
@@ -224,13 +224,13 @@ RubberBandStretcher::Impl::ChannelData::setOutbufSize(size_t outbufSize)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ChannelData::setResampleBufSize(size_t sz)
|
||||
R2Stretcher::ChannelData::setResampleBufSize(size_t sz)
|
||||
{
|
||||
resamplebuf = reallocate_and_zero<float>(resamplebuf, resamplebufSize, sz);
|
||||
resamplebufSize = sz;
|
||||
}
|
||||
|
||||
RubberBandStretcher::Impl::ChannelData::~ChannelData()
|
||||
R2Stretcher::ChannelData::~ChannelData()
|
||||
{
|
||||
delete resampler;
|
||||
|
||||
@@ -259,7 +259,7 @@ RubberBandStretcher::Impl::ChannelData::~ChannelData()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ChannelData::reset()
|
||||
R2Stretcher::ChannelData::reset()
|
||||
{
|
||||
inbuf->reset();
|
||||
outbuf->reset();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef RUBBERBAND_STRETCHERCHANNELDATA_H
|
||||
#define RUBBERBAND_STRETCHERCHANNELDATA_H
|
||||
|
||||
#include "StretcherImpl.h"
|
||||
#include "R2Stretcher.h"
|
||||
|
||||
#include <set>
|
||||
#include <atomic>
|
||||
@@ -34,7 +34,7 @@ namespace RubberBand
|
||||
|
||||
class Resampler;
|
||||
|
||||
class RubberBandStretcher::Impl::ChannelData
|
||||
class R2Stretcher::ChannelData
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
you must obtain a valid commercial licence before doing so.
|
||||
*/
|
||||
|
||||
#include "StretcherImpl.h"
|
||||
#include "R2Stretcher.h"
|
||||
#include "StretcherChannelData.h"
|
||||
|
||||
#include "../common/StretchCalculator.h"
|
||||
@@ -47,7 +47,7 @@ namespace RubberBand {
|
||||
|
||||
#ifndef NO_THREADING
|
||||
|
||||
RubberBandStretcher::Impl::ProcessThread::ProcessThread(Impl *s, size_t c) :
|
||||
R2Stretcher::ProcessThread::ProcessThread(R2Stretcher *s, size_t c) :
|
||||
m_s(s),
|
||||
m_channel(c),
|
||||
m_dataAvailable(std::string("data ") + char('A' + c)),
|
||||
@@ -55,7 +55,7 @@ RubberBandStretcher::Impl::ProcessThread::ProcessThread(Impl *s, size_t c) :
|
||||
{ }
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ProcessThread::run()
|
||||
R2Stretcher::ProcessThread::run()
|
||||
{
|
||||
if (m_s->m_debugLevel > 1) {
|
||||
cerr << "thread " << m_channel << " getting going" << endl;
|
||||
@@ -108,7 +108,7 @@ RubberBandStretcher::Impl::ProcessThread::run()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ProcessThread::signalDataAvailable()
|
||||
R2Stretcher::ProcessThread::signalDataAvailable()
|
||||
{
|
||||
m_dataAvailable.lock();
|
||||
m_dataAvailable.signal();
|
||||
@@ -116,7 +116,7 @@ RubberBandStretcher::Impl::ProcessThread::signalDataAvailable()
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::ProcessThread::abandon()
|
||||
R2Stretcher::ProcessThread::abandon()
|
||||
{
|
||||
m_abandoning = true;
|
||||
}
|
||||
@@ -124,16 +124,16 @@ RubberBandStretcher::Impl::ProcessThread::abandon()
|
||||
#endif
|
||||
|
||||
bool
|
||||
RubberBandStretcher::Impl::resampleBeforeStretching() const
|
||||
R2Stretcher::resampleBeforeStretching() const
|
||||
{
|
||||
// We can't resample before stretching in offline mode, because
|
||||
// the stretch calculation is based on doing it the other way
|
||||
// around. It would take more work (and testing) to enable this.
|
||||
if (!m_realtime) return false;
|
||||
|
||||
if (m_options & OptionPitchHighQuality) {
|
||||
if (m_options & RubberBandStretcher::OptionPitchHighQuality) {
|
||||
return (m_pitchScale < 1.0); // better sound
|
||||
} else if (m_options & OptionPitchHighConsistency) {
|
||||
} else if (m_options & RubberBandStretcher::OptionPitchHighConsistency) {
|
||||
return false;
|
||||
} else {
|
||||
return (m_pitchScale > 1.0); // better performance
|
||||
@@ -141,7 +141,7 @@ RubberBandStretcher::Impl::resampleBeforeStretching() const
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::prepareChannelMS(size_t c,
|
||||
R2Stretcher::prepareChannelMS(size_t c,
|
||||
const float *const *inputs,
|
||||
size_t offset,
|
||||
size_t samples,
|
||||
@@ -161,13 +161,13 @@ RubberBandStretcher::Impl::prepareChannelMS(size_t c,
|
||||
}
|
||||
|
||||
size_t
|
||||
RubberBandStretcher::Impl::consumeChannel(size_t c,
|
||||
R2Stretcher::consumeChannel(size_t c,
|
||||
const float *const *inputs,
|
||||
size_t offset,
|
||||
size_t samples,
|
||||
bool final)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::consumeChannel");
|
||||
Profiler profiler("R2Stretcher::consumeChannel");
|
||||
|
||||
ChannelData &cd = *m_channelData[c];
|
||||
RingBuffer<float> &inbuf = *cd.inbuf;
|
||||
@@ -179,13 +179,14 @@ RubberBandStretcher::Impl::consumeChannel(size_t c,
|
||||
|
||||
const float *input = 0;
|
||||
|
||||
bool useMidSide = ((m_options & OptionChannelsTogether) &&
|
||||
(m_channels >= 2) &&
|
||||
(c < 2));
|
||||
bool useMidSide =
|
||||
((m_options & RubberBandStretcher::OptionChannelsTogether) &&
|
||||
(m_channels >= 2) &&
|
||||
(c < 2));
|
||||
|
||||
if (resampling) {
|
||||
|
||||
Profiler profiler2("RubberBandStretcher::Impl::resample");
|
||||
Profiler profiler2("R2Stretcher::resample");
|
||||
|
||||
toWrite = int(ceil(samples / m_pitchScale));
|
||||
if (writable < toWrite) {
|
||||
@@ -204,7 +205,7 @@ RubberBandStretcher::Impl::consumeChannel(size_t c,
|
||||
|
||||
size_t reqSize = int(ceil(samples / m_pitchScale));
|
||||
if (reqSize > cd.resamplebufSize) {
|
||||
cerr << "WARNING: RubberBandStretcher::Impl::consumeChannel: resizing resampler buffer from "
|
||||
cerr << "WARNING: R2Stretcher::consumeChannel: resizing resampler buffer from "
|
||||
<< cd.resamplebufSize << " to " << reqSize << endl;
|
||||
cd.setResampleBufSize(reqSize);
|
||||
}
|
||||
@@ -265,9 +266,9 @@ RubberBandStretcher::Impl::consumeChannel(size_t c,
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::processChunks(size_t c, bool &any, bool &last)
|
||||
R2Stretcher::processChunks(size_t c, bool &any, bool &last)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::processChunks");
|
||||
Profiler profiler("R2Stretcher::processChunks");
|
||||
|
||||
// Process as many chunks as there are available on the input
|
||||
// buffer for channel c. This requires that the increments have
|
||||
@@ -338,9 +339,9 @@ RubberBandStretcher::Impl::processChunks(size_t c, bool &any, bool &last)
|
||||
}
|
||||
|
||||
bool
|
||||
RubberBandStretcher::Impl::processOneChunk()
|
||||
R2Stretcher::processOneChunk()
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::processOneChunk");
|
||||
Profiler profiler("R2Stretcher::processOneChunk");
|
||||
|
||||
// Process a single chunk for all channels, provided there is
|
||||
// enough data on each channel for at least one chunk. This is
|
||||
@@ -381,9 +382,9 @@ RubberBandStretcher::Impl::processOneChunk()
|
||||
}
|
||||
|
||||
bool
|
||||
RubberBandStretcher::Impl::testInbufReadSpace(size_t c)
|
||||
R2Stretcher::testInbufReadSpace(size_t c)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::testInbufReadSpace");
|
||||
Profiler profiler("R2Stretcher::testInbufReadSpace");
|
||||
|
||||
ChannelData &cd = *m_channelData[c];
|
||||
RingBuffer<float> &inbuf = *cd.inbuf;
|
||||
@@ -437,12 +438,12 @@ RubberBandStretcher::Impl::testInbufReadSpace(size_t c)
|
||||
}
|
||||
|
||||
bool
|
||||
RubberBandStretcher::Impl::processChunkForChannel(size_t c,
|
||||
R2Stretcher::processChunkForChannel(size_t c,
|
||||
size_t phaseIncrement,
|
||||
size_t shiftIncrement,
|
||||
bool phaseReset)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::processChunkForChannel");
|
||||
Profiler profiler("R2Stretcher::processChunkForChannel");
|
||||
|
||||
// Process a single chunk on a single channel. This assumes
|
||||
// enough input data is available; caller must have tested this
|
||||
@@ -541,11 +542,11 @@ RubberBandStretcher::Impl::processChunkForChannel(size_t c,
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn,
|
||||
R2Stretcher::calculateIncrements(size_t &phaseIncrementRtn,
|
||||
size_t &shiftIncrementRtn,
|
||||
bool &phaseReset)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::calculateIncrements");
|
||||
Profiler profiler("R2Stretcher::calculateIncrements");
|
||||
|
||||
// cerr << "calculateIncrements" << endl;
|
||||
|
||||
@@ -571,7 +572,7 @@ RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn,
|
||||
size_t bc = cd.chunkCount;
|
||||
for (size_t c = 1; c < m_channels; ++c) {
|
||||
if (m_channelData[c]->chunkCount != bc) {
|
||||
cerr << "ERROR: RubberBandStretcher::Impl::calculateIncrements: Channels are not in sync" << endl;
|
||||
cerr << "ERROR: R2Stretcher::calculateIncrements: Channels are not in sync" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -676,12 +677,12 @@ RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn,
|
||||
}
|
||||
|
||||
bool
|
||||
RubberBandStretcher::Impl::getIncrements(size_t channel,
|
||||
R2Stretcher::getIncrements(size_t channel,
|
||||
size_t &phaseIncrementRtn,
|
||||
size_t &shiftIncrementRtn,
|
||||
bool &phaseReset)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::getIncrements");
|
||||
Profiler profiler("R2Stretcher::getIncrements");
|
||||
|
||||
if (channel >= m_channels) {
|
||||
phaseIncrementRtn = m_increment;
|
||||
@@ -710,7 +711,7 @@ RubberBandStretcher::Impl::getIncrements(size_t channel,
|
||||
bool gotData = true;
|
||||
|
||||
if (cd.chunkCount >= m_outputIncrements.size()) {
|
||||
// cerr << "WARNING: RubberBandStretcher::Impl::getIncrements:"
|
||||
// cerr << "WARNING: R2Stretcher::getIncrements:"
|
||||
// << " chunk count " << cd.chunkCount << " >= "
|
||||
// << m_outputIncrements.size() << endl;
|
||||
if (m_outputIncrements.size() == 0) {
|
||||
@@ -741,7 +742,7 @@ RubberBandStretcher::Impl::getIncrements(size_t channel,
|
||||
}
|
||||
/*
|
||||
if (shiftIncrement >= int(m_windowSize)) {
|
||||
cerr << "*** ERROR: RubberBandStretcher::Impl::processChunks: shiftIncrement " << shiftIncrement << " >= windowSize " << m_windowSize << " at " << cd.chunkCount << " (of " << m_outputIncrements.size() << ")" << endl;
|
||||
cerr << "*** ERROR: R2Stretcher::processChunks: shiftIncrement " << shiftIncrement << " >= windowSize " << m_windowSize << " at " << cd.chunkCount << " (of " << m_outputIncrements.size() << ")" << endl;
|
||||
shiftIncrement = m_windowSize;
|
||||
}
|
||||
*/
|
||||
@@ -752,9 +753,9 @@ RubberBandStretcher::Impl::getIncrements(size_t channel,
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::analyseChunk(size_t channel)
|
||||
R2Stretcher::analyseChunk(size_t channel)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::analyseChunk");
|
||||
Profiler profiler("R2Stretcher::analyseChunk");
|
||||
|
||||
ChannelData &cd = *m_channelData[channel];
|
||||
|
||||
@@ -773,11 +774,11 @@ RubberBandStretcher::Impl::analyseChunk(size_t channel)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::modifyChunk(size_t channel,
|
||||
R2Stretcher::modifyChunk(size_t channel,
|
||||
size_t outputIncrement,
|
||||
bool phaseReset)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::modifyChunk");
|
||||
Profiler profiler("R2Stretcher::modifyChunk");
|
||||
|
||||
ChannelData &cd = *m_channelData[channel];
|
||||
|
||||
@@ -790,8 +791,8 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel,
|
||||
|
||||
bool unchanged = cd.unchanged && (outputIncrement == m_increment);
|
||||
bool fullReset = phaseReset;
|
||||
bool laminar = !(m_options & OptionPhaseIndependent);
|
||||
bool bandlimited = (m_options & OptionTransientsMixed);
|
||||
bool laminar = !(m_options & RubberBandStretcher::OptionPhaseIndependent);
|
||||
bool bandlimited = (m_options & RubberBandStretcher::OptionTransientsMixed);
|
||||
int bandlow = lrint((150 * m_fftSize) / rate);
|
||||
int bandhigh = lrint((1000 * m_fftSize) / rate);
|
||||
|
||||
@@ -917,9 +918,9 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel,
|
||||
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::formantShiftChunk(size_t channel)
|
||||
R2Stretcher::formantShiftChunk(size_t channel)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::formantShiftChunk");
|
||||
Profiler profiler("R2Stretcher::formantShiftChunk");
|
||||
|
||||
ChannelData &cd = *m_channelData[channel];
|
||||
|
||||
@@ -977,13 +978,12 @@ RubberBandStretcher::Impl::formantShiftChunk(size_t channel)
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::synthesiseChunk(size_t channel,
|
||||
R2Stretcher::synthesiseChunk(size_t channel,
|
||||
size_t shiftIncrement)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::synthesiseChunk");
|
||||
Profiler profiler("R2Stretcher::synthesiseChunk");
|
||||
|
||||
|
||||
if ((m_options & OptionFormantPreserved) &&
|
||||
if ((m_options & RubberBandStretcher::OptionFormantPreserved) &&
|
||||
(m_pitchScale != 1.0)) {
|
||||
formantShiftChunk(channel);
|
||||
}
|
||||
@@ -1049,9 +1049,9 @@ RubberBandStretcher::Impl::synthesiseChunk(size_t channel,
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, bool last)
|
||||
R2Stretcher::writeChunk(size_t channel, size_t shiftIncrement, bool last)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::writeChunk");
|
||||
Profiler profiler("R2Stretcher::writeChunk");
|
||||
|
||||
ChannelData &cd = *m_channelData[channel];
|
||||
|
||||
@@ -1077,10 +1077,11 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
bool resampledAlready = resampleBeforeStretching();
|
||||
|
||||
if (!resampledAlready &&
|
||||
(m_pitchScale != 1.0 || m_options & OptionPitchHighConsistency) &&
|
||||
(m_pitchScale != 1.0 ||
|
||||
(m_options & RubberBandStretcher::OptionPitchHighConsistency)) &&
|
||||
cd.resampler) {
|
||||
|
||||
Profiler profiler2("RubberBandStretcher::Impl::resample");
|
||||
Profiler profiler2("R2Stretcher::resample");
|
||||
|
||||
size_t reqSize = int(ceil(si / m_pitchScale));
|
||||
if (reqSize > cd.resamplebufSize) {
|
||||
@@ -1089,7 +1090,7 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
// first place. But we retain this check in case the
|
||||
// pitch scale has changed since then, or the stretch
|
||||
// calculator has gone mad, or something.
|
||||
cerr << "WARNING: RubberBandStretcher::Impl::writeChunk: resizing resampler buffer from "
|
||||
cerr << "WARNING: R2Stretcher::writeChunk: resizing resampler buffer from "
|
||||
<< cd.resamplebufSize << " to " << reqSize << endl;
|
||||
cd.setResampleBufSize(reqSize);
|
||||
}
|
||||
@@ -1134,7 +1135,7 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
cd.accumulatorFill = 0;
|
||||
if (cd.draining) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "RubberBandStretcher::Impl::processChunks: setting outputComplete to true" << endl;
|
||||
cerr << "R2Stretcher::processChunks: setting outputComplete to true" << endl;
|
||||
}
|
||||
cd.outputComplete = true;
|
||||
}
|
||||
@@ -1142,9 +1143,9 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::writeOutput(RingBuffer<float> &to, float *from, size_t qty, size_t &outCount, size_t theoreticalOut)
|
||||
R2Stretcher::writeOutput(RingBuffer<float> &to, float *from, size_t qty, size_t &outCount, size_t theoreticalOut)
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::writeOutput");
|
||||
Profiler profiler("R2Stretcher::writeOutput");
|
||||
|
||||
// In non-RT mode, we don't want to write the first startSkip
|
||||
// samples, because the first chunk is centred on the start of the
|
||||
@@ -1183,7 +1184,7 @@ RubberBandStretcher::Impl::writeOutput(RingBuffer<float> &to, float *from, size_
|
||||
size_t written = to.write(from, qty);
|
||||
|
||||
if (written < qty) {
|
||||
cerr << "WARNING: RubberBandStretcher::Impl::writeOutput: "
|
||||
cerr << "WARNING: R2Stretcher::writeOutput: "
|
||||
<< "Buffer overrun on output: wrote " << written
|
||||
<< " of " << qty << " samples" << endl;
|
||||
}
|
||||
@@ -1216,9 +1217,9 @@ RubberBandStretcher::Impl::writeOutput(RingBuffer<float> &to, float *from, size_
|
||||
}
|
||||
|
||||
int
|
||||
RubberBandStretcher::Impl::available() const
|
||||
R2Stretcher::available() const
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::available");
|
||||
Profiler profiler("R2Stretcher::available");
|
||||
|
||||
#ifndef NO_THREADING
|
||||
if (m_threaded) {
|
||||
@@ -1242,7 +1243,7 @@ RubberBandStretcher::Impl::available() const
|
||||
//!!! do we ever actually do this? if so, this method should not be const
|
||||
// ^^^ yes, we do sometimes -- e.g. when fed a very short file
|
||||
bool any = false, last = false;
|
||||
((RubberBandStretcher::Impl *)this)->processChunks(c, any, last);
|
||||
((R2Stretcher *)this)->processChunks(c, any, last);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1273,9 +1274,9 @@ RubberBandStretcher::Impl::available() const
|
||||
}
|
||||
|
||||
size_t
|
||||
RubberBandStretcher::Impl::retrieve(float *const *output, size_t samples) const
|
||||
R2Stretcher::retrieve(float *const *output, size_t samples) const
|
||||
{
|
||||
Profiler profiler("RubberBandStretcher::Impl::retrieve");
|
||||
Profiler profiler("R2Stretcher::retrieve");
|
||||
|
||||
size_t got = samples;
|
||||
|
||||
@@ -1284,14 +1285,15 @@ RubberBandStretcher::Impl::retrieve(float *const *output, size_t samples) const
|
||||
if (gotHere < got) {
|
||||
if (c > 0) {
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "RubberBandStretcher::Impl::retrieve: WARNING: channel imbalance detected" << endl;
|
||||
cerr << "R2Stretcher::retrieve: WARNING: channel imbalance detected" << endl;
|
||||
}
|
||||
}
|
||||
got = gotHere;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_options & OptionChannelsTogether) && (m_channels >= 2)) {
|
||||
if ((m_options & RubberBandStretcher::OptionChannelsTogether) &&
|
||||
(m_channels >= 2)) {
|
||||
for (size_t i = 0; i < got; ++i) {
|
||||
float mid = output[0][i];
|
||||
float side = output[1][i];
|
||||
|
||||
Reference in New Issue
Block a user