These can just be overloads for log, which at least avoids us using log2 as a method name here
This commit is contained in:
@@ -333,9 +333,9 @@ public:
|
||||
};
|
||||
|
||||
struct Logger {
|
||||
virtual void log0(const char *) = 0;
|
||||
virtual void log1(const char *, double) = 0;
|
||||
virtual void log2(const char *, double, double) = 0;
|
||||
virtual void log(const char *) = 0;
|
||||
virtual void log(const char *, double) = 0;
|
||||
virtual void log(const char *, double, double) = 0;
|
||||
virtual ~Logger() { }
|
||||
};
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ class RubberBandStretcher::Impl
|
||||
if (logger) {
|
||||
return Log(
|
||||
[=](const char *message) {
|
||||
logger->log0(message);
|
||||
logger->log(message);
|
||||
},
|
||||
[=](const char *message, double arg0) {
|
||||
logger->log1(message, arg0);
|
||||
logger->log(message, arg0);
|
||||
},
|
||||
[=](const char *message, double arg0, double arg1) {
|
||||
logger->log2(message, arg0, arg1);
|
||||
logger->log(message, arg0, arg1);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
namespace RubberBand {
|
||||
namespace RubberBand
|
||||
{
|
||||
|
||||
int Log::m_defaultDebugLevel = 0;
|
||||
|
||||
|
||||
@@ -58,15 +58,13 @@ public:
|
||||
|
||||
static void setDefaultDebugLevel(int level) { m_defaultDebugLevel = level; }
|
||||
|
||||
void log0(int level, const char *message) const {
|
||||
void log(int level, const char *message) const {
|
||||
if (level <= m_debugLevel) m_log0(message);
|
||||
}
|
||||
void log1(int level, const char *message, double arg0) const {
|
||||
void log(int level, const char *message, double arg0) const {
|
||||
if (level <= m_debugLevel) m_log1(message, arg0);
|
||||
}
|
||||
|
||||
//!!! On reflection, log2 is a dumb choice of name
|
||||
void log2(int level, const char *message, double arg0, double arg1) const {
|
||||
void log(int level, const char *message, double arg0, double arg1) const {
|
||||
if (level <= m_debugLevel) m_log2(message, arg0, arg1);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,13 +126,13 @@ R2Stretcher::R2Stretcher(size_t sampleRate,
|
||||
(options & RubberBandStretcher::OptionWindowLong)) {
|
||||
if ((options & RubberBandStretcher::OptionWindowShort) &&
|
||||
(options & RubberBandStretcher::OptionWindowLong)) {
|
||||
m_log.log0(0, "R2Stretcher::R2Stretcher: Cannot specify OptionWindowLong and OptionWindowShort together; falling back to OptionWindowStandard");
|
||||
m_log.log(0, "R2Stretcher::R2Stretcher: Cannot specify OptionWindowLong and OptionWindowShort together; falling back to OptionWindowStandard");
|
||||
} else if (options & RubberBandStretcher::OptionWindowShort) {
|
||||
m_baseFftSize = m_baseFftSize / 2;
|
||||
m_log.log1(1, "setting baseFftSize", m_baseFftSize);
|
||||
m_log.log(1, "setting baseFftSize", m_baseFftSize);
|
||||
} else if (options & RubberBandStretcher::OptionWindowLong) {
|
||||
m_baseFftSize = m_baseFftSize * 2;
|
||||
m_log.log1(1, "setting baseFftSize", m_baseFftSize);
|
||||
m_log.log(1, "setting baseFftSize", m_baseFftSize);
|
||||
}
|
||||
m_fftSize = m_baseFftSize;
|
||||
m_aWindowSize = m_baseFftSize;
|
||||
@@ -160,7 +160,7 @@ R2Stretcher::R2Stretcher(size_t sampleRate,
|
||||
}
|
||||
|
||||
if (m_threaded) {
|
||||
m_log.log0(1, "Going multithreaded...");
|
||||
m_log.log(1, "Going multithreaded...");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -175,7 +175,7 @@ R2Stretcher::~R2Stretcher()
|
||||
MutexLocker locker(&m_threadSetMutex);
|
||||
for (set<ProcessThread *>::iterator i = m_threadSet.begin();
|
||||
i != m_threadSet.end(); ++i) {
|
||||
m_log.log1(1, "RubberBandStretcher::~RubberBandStretcher: joining for channel", (*i)->channel());
|
||||
m_log.log(1, "RubberBandStretcher::~RubberBandStretcher: joining for channel", (*i)->channel());
|
||||
(*i)->abandon();
|
||||
(*i)->wait();
|
||||
delete *i;
|
||||
@@ -210,7 +210,7 @@ R2Stretcher::reset()
|
||||
m_threadSetMutex.lock();
|
||||
for (set<ProcessThread *>::iterator i = m_threadSet.begin();
|
||||
i != m_threadSet.end(); ++i) {
|
||||
m_log.log1(1, "RubberBandStretcher::~RubberBandStretcher: joining for channel", (*i)->channel());
|
||||
m_log.log(1, "RubberBandStretcher::~RubberBandStretcher: joining for channel", (*i)->channel());
|
||||
(*i)->abandon();
|
||||
(*i)->wait();
|
||||
delete *i;
|
||||
@@ -247,7 +247,7 @@ R2Stretcher::setTimeRatio(double ratio)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
if (m_mode == Studying || m_mode == Processing) {
|
||||
m_log.log0(0, "R2Stretcher::setTimeRatio: Cannot set ratio while studying or processing in non-RT mode");
|
||||
m_log.log(0, "R2Stretcher::setTimeRatio: Cannot set ratio while studying or processing in non-RT mode");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ R2Stretcher::setPitchScale(double fs)
|
||||
{
|
||||
if (!m_realtime) {
|
||||
if (m_mode == Studying || m_mode == Processing) {
|
||||
m_log.log0(0, "R2Stretcher::setPitchScale: Cannot set ratio while studying or processing in non-RT mode");
|
||||
m_log.log(0, "R2Stretcher::setPitchScale: Cannot set ratio while studying or processing in non-RT mode");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -325,11 +325,11 @@ R2Stretcher::setKeyFrameMap(const std::map<size_t, size_t> &
|
||||
mapping)
|
||||
{
|
||||
if (m_realtime) {
|
||||
m_log.log0(0, "R2Stretcher::setKeyFrameMap: Cannot specify key frame map in RT mode");
|
||||
m_log.log(0, "R2Stretcher::setKeyFrameMap: Cannot specify key frame map in RT mode");
|
||||
return;
|
||||
}
|
||||
if (m_mode == Processing) {
|
||||
m_log.log0(0, "R2Stretcher::setKeyFrameMap: Cannot specify key frame map after process() has begun");
|
||||
m_log.log(0, "R2Stretcher::setKeyFrameMap: Cannot specify key frame map after process() has begun");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,12 +397,12 @@ R2Stretcher::calculateSizes()
|
||||
// This special case is likelier than one might hope, because
|
||||
// of naive initialisations in programs that set it from a
|
||||
// variable
|
||||
m_log.log1(0, "WARNING: Pitch scale must be greater than zero! Resetting it to default, no pitch shift will happen", m_pitchScale);
|
||||
m_log.log(0, "WARNING: Pitch scale must be greater than zero! Resetting it to default, no pitch shift will happen", m_pitchScale);
|
||||
m_pitchScale = 1.0;
|
||||
}
|
||||
if (m_timeRatio <= 0.0) {
|
||||
// Likewise
|
||||
m_log.log1(0, "WARNING: Time ratio must be greater than zero! Resetting it to default, no time stretch will happen", m_timeRatio);
|
||||
m_log.log(0, "WARNING: Time ratio must be greater than zero! Resetting it to default, no time stretch will happen", m_timeRatio);
|
||||
m_timeRatio = 1.0;
|
||||
}
|
||||
|
||||
@@ -524,11 +524,11 @@ R2Stretcher::calculateSizes()
|
||||
// twice the basic output increment (i.e. input increment times
|
||||
// ratio) for any chunk.
|
||||
|
||||
m_log.log2(1, "calculateSizes: time ratio and pitch scale", m_timeRatio, m_pitchScale);
|
||||
m_log.log1(1, "effective ratio", getEffectiveRatio());
|
||||
m_log.log2(1, "analysis and synthesis window sizes", m_aWindowSize, m_sWindowSize);
|
||||
m_log.log1(1, "fft size", m_fftSize);
|
||||
m_log.log2(1, "input increment and mean output increment", m_increment, m_increment * getEffectiveRatio());
|
||||
m_log.log(1, "calculateSizes: time ratio and pitch scale", m_timeRatio, m_pitchScale);
|
||||
m_log.log(1, "effective ratio", getEffectiveRatio());
|
||||
m_log.log(1, "analysis and synthesis window sizes", m_aWindowSize, m_sWindowSize);
|
||||
m_log.log(1, "fft size", m_fftSize);
|
||||
m_log.log(1, "input increment and mean output increment", m_increment, m_increment * getEffectiveRatio());
|
||||
|
||||
if (std::max(m_aWindowSize, m_sWindowSize) > m_maxProcessSize) {
|
||||
m_maxProcessSize = std::max(m_aWindowSize, m_sWindowSize);
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
<< "Hz), highest = " << highest
|
||||
<< " (" << configuration.fftBandLimits[myFftBand].f1max
|
||||
<< "Hz)" << std::endl;
|
||||
m_log.log0(1, ostr.str().c_str());
|
||||
m_log.log(1, ostr.str().c_str());
|
||||
m_reported = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,10 +122,10 @@ R3Stretcher::R3Stretcher(Parameters parameters,
|
||||
m_prevOuthop = int(round(m_inhop * getEffectiveRatio()));
|
||||
|
||||
if (!m_inhop.is_lock_free()) {
|
||||
m_log.log0(0, "WARNING: std::atomic<int> is not lock-free");
|
||||
m_log.log(0, "WARNING: std::atomic<int> is not lock-free");
|
||||
}
|
||||
if (!m_timeRatio.is_lock_free()) {
|
||||
m_log.log0(0, "WARNING: std::atomic<double> is not lock-free");
|
||||
m_log.log(0, "WARNING: std::atomic<double> is not lock-free");
|
||||
}
|
||||
|
||||
// Pad to half of the longest frame. As with R2, in real-time mode
|
||||
@@ -134,7 +134,7 @@ R3Stretcher::R3Stretcher(Parameters parameters,
|
||||
// changes.
|
||||
|
||||
if (!isRealTime()) {
|
||||
m_log.log0(1, "Offline mode: pre-padding");
|
||||
m_log.log(1, "Offline mode: pre-padding");
|
||||
int pad = m_guideConfiguration.longestFftSize / 2;
|
||||
for (int c = 0; c < m_parameters.channels; ++c) {
|
||||
m_channelData[c]->inbuf->zero(pad);
|
||||
@@ -142,7 +142,7 @@ R3Stretcher::R3Stretcher(Parameters parameters,
|
||||
// By the time we skip this later we will have resampled
|
||||
m_startSkip = int(round(pad / m_pitchScale));
|
||||
} else {
|
||||
m_log.log0(1, "RT mode: no internal pre-pad");
|
||||
m_log.log(1, "RT mode: no internal pre-pad");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ R3Stretcher::setTimeRatio(double ratio)
|
||||
if (!isRealTime()) {
|
||||
if (m_mode == ProcessMode::Studying ||
|
||||
m_mode == ProcessMode::Processing) {
|
||||
m_log.log0(0, "R3Stretcher::setTimeRatio: Cannot set time ratio while studying or processing in non-RT mode");
|
||||
m_log.log(0, "R3Stretcher::setTimeRatio: Cannot set time ratio while studying or processing in non-RT mode");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ R3Stretcher::setPitchScale(double scale)
|
||||
if (!isRealTime()) {
|
||||
if (m_mode == ProcessMode::Studying ||
|
||||
m_mode == ProcessMode::Processing) {
|
||||
m_log.log0(0, "R3Stretcher::setTimeRatio: Cannot set pitch scale while studying or processing in non-RT mode");
|
||||
m_log.log(0, "R3Stretcher::setTimeRatio: Cannot set pitch scale while studying or processing in non-RT mode");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ R3Stretcher::setFormantScale(double scale)
|
||||
if (!isRealTime()) {
|
||||
if (m_mode == ProcessMode::Studying ||
|
||||
m_mode == ProcessMode::Processing) {
|
||||
m_log.log0(0, "R3Stretcher::setTimeRatio: Cannot set formant scale while studying or processing in non-RT mode");
|
||||
m_log.log(0, "R3Stretcher::setTimeRatio: Cannot set formant scale while studying or processing in non-RT mode");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -233,11 +233,11 @@ void
|
||||
R3Stretcher::setKeyFrameMap(const std::map<size_t, size_t> &mapping)
|
||||
{
|
||||
if (isRealTime()) {
|
||||
m_log.log0(0, "R3Stretcher::setKeyFrameMap: Cannot specify key frame map in RT mode");
|
||||
m_log.log(0, "R3Stretcher::setKeyFrameMap: Cannot specify key frame map in RT mode");
|
||||
return;
|
||||
}
|
||||
if (m_mode == ProcessMode::Processing || m_mode == ProcessMode::Finished) {
|
||||
m_log.log0(0, "R3Stretcher::setKeyFrameMap: Cannot specify key frame map after process() has begun");
|
||||
m_log.log(0, "R3Stretcher::setKeyFrameMap: Cannot specify key frame map after process() has begun");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,21 +269,21 @@ R3Stretcher::calculateHop()
|
||||
if (proposedOuthop > 512.0) proposedOuthop = 512.0;
|
||||
if (proposedOuthop < 128.0) proposedOuthop = 128.0;
|
||||
|
||||
m_log.log2(1, "calculateHop: ratio and proposed outhop", ratio, proposedOuthop);
|
||||
m_log.log(1, "calculateHop: ratio and proposed outhop", ratio, proposedOuthop);
|
||||
|
||||
double inhop = proposedOuthop / ratio;
|
||||
if (inhop < 1.0) {
|
||||
m_log.log2(0, "WARNING: Extreme ratio yields ideal inhop < 1, results may be suspect", ratio, inhop);
|
||||
m_log.log(0, "WARNING: Extreme ratio yields ideal inhop < 1, results may be suspect", ratio, inhop);
|
||||
inhop = 1.0;
|
||||
}
|
||||
if (inhop > 768.0) {
|
||||
m_log.log2(0, "WARNING: Extreme ratio yields ideal inhop > 768, results may be suspect", ratio, inhop);
|
||||
m_log.log(0, "WARNING: Extreme ratio yields ideal inhop > 768, results may be suspect", ratio, inhop);
|
||||
inhop = 768.0;
|
||||
}
|
||||
|
||||
m_inhop = int(floor(inhop));
|
||||
|
||||
m_log.log2(1, "calculateHop: inhop and mean outhop", m_inhop, m_inhop * ratio);
|
||||
m_log.log(1, "calculateHop: inhop and mean outhop", m_inhop, m_inhop * ratio);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -295,10 +295,10 @@ R3Stretcher::updateRatioFromMap()
|
||||
m_timeRatio = double(m_keyFrameMap.begin()->second) /
|
||||
double(m_keyFrameMap.begin()->first);
|
||||
|
||||
m_log.log2(1, "initial key-frame map entry ",
|
||||
m_log.log(1, "initial key-frame map entry ",
|
||||
double(m_keyFrameMap.begin()->first),
|
||||
double(m_keyFrameMap.begin()->second));
|
||||
m_log.log1(1, "giving initial ratio ", m_timeRatio);
|
||||
m_log.log(1, "giving initial ratio ", m_timeRatio);
|
||||
|
||||
calculateHop();
|
||||
m_lastKeyFrameSurpassed = 0;
|
||||
@@ -313,7 +313,7 @@ R3Stretcher::updateRatioFromMap()
|
||||
|
||||
if (m_processInputDuration >= i0->first) {
|
||||
|
||||
m_log.log2(2, "input duration surpasses pending key frame",
|
||||
m_log.log(2, "input duration surpasses pending key frame",
|
||||
double(m_processInputDuration), double(i0->first));
|
||||
|
||||
auto i1 = m_keyFrameMap.upper_bound(m_processInputDuration);
|
||||
@@ -339,13 +339,13 @@ R3Stretcher::updateRatioFromMap()
|
||||
|
||||
double ratio = double(toKeyFrameAtOutput) / double(toKeyFrameAtInput);
|
||||
|
||||
m_log.log2(2, "next key frame input and output",
|
||||
m_log.log(2, "next key frame input and output",
|
||||
double(keyFrameAtInput), double(keyFrameAtOutput));
|
||||
m_log.log2(2, "current input and output",
|
||||
m_log.log(2, "current input and output",
|
||||
double(m_processInputDuration), double(m_totalOutputDuration));
|
||||
m_log.log2(2, "to next key frame input and output",
|
||||
m_log.log(2, "to next key frame input and output",
|
||||
double(toKeyFrameAtInput), double(toKeyFrameAtOutput));
|
||||
m_log.log1(2, "new ratio", ratio);
|
||||
m_log.log(2, "new ratio", ratio);
|
||||
|
||||
m_timeRatio = ratio;
|
||||
calculateHop();
|
||||
@@ -420,12 +420,12 @@ void
|
||||
R3Stretcher::study(const float *const *, size_t samples, bool)
|
||||
{
|
||||
if (isRealTime()) {
|
||||
m_log.log0(0, "R3Stretcher::study: Not meaningful in realtime mode");
|
||||
m_log.log(0, "R3Stretcher::study: Not meaningful in realtime mode");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mode == ProcessMode::Processing || m_mode == ProcessMode::Finished) {
|
||||
m_log.log0(0, "R3Stretcher::study: Cannot study after processing");
|
||||
m_log.log(0, "R3Stretcher::study: Cannot study after processing");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ void
|
||||
R3Stretcher::process(const float *const *input, size_t samples, bool final)
|
||||
{
|
||||
if (m_mode == ProcessMode::Finished) {
|
||||
m_log.log0(0, "R3Stretcher::process: Cannot process again after final chunk");
|
||||
m_log.log(0, "R3Stretcher::process: Cannot process again after final chunk");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final)
|
||||
size_t ws = m_channelData[0]->inbuf->getWriteSpace();
|
||||
if (samples > ws) {
|
||||
//!!! check this
|
||||
m_log.log0(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve.");
|
||||
m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve.");
|
||||
size_t newSize = m_channelData[0]->inbuf->getSize() - ws + samples;
|
||||
for (int c = 0; c < m_parameters.channels; ++c) {
|
||||
auto newBuf = m_channelData[c]->inbuf->resized(newSize);
|
||||
@@ -516,7 +516,7 @@ R3Stretcher::retrieve(float *const *output, size_t samples) const
|
||||
int gotHere = m_channelData[c]->outbuf->read(output[c], got);
|
||||
if (gotHere < got) {
|
||||
if (c > 0) {
|
||||
m_log.log0(0, "R3Stretcher::retrieve: WARNING: channel imbalance detected");
|
||||
m_log.log(0, "R3Stretcher::retrieve: WARNING: channel imbalance detected");
|
||||
}
|
||||
got = std::min(got, std::max(gotHere, 0));
|
||||
}
|
||||
@@ -563,10 +563,10 @@ R3Stretcher::consume()
|
||||
// values.
|
||||
|
||||
if (inhop != m_prevInhop) {
|
||||
m_log.log2(2, "change in inhop", double(m_prevInhop), double(inhop));
|
||||
m_log.log(2, "change in inhop", double(m_prevInhop), double(inhop));
|
||||
}
|
||||
if (outhop != m_prevOuthop) {
|
||||
m_log.log2(2, "change in outhop", double(m_prevOuthop), double(outhop));
|
||||
m_log.log(2, "change in outhop", double(m_prevOuthop), double(outhop));
|
||||
}
|
||||
|
||||
while (m_channelData.at(0)->outbuf->getWriteSpace() >= outhop) {
|
||||
|
||||
Reference in New Issue
Block a user