Wire through debug level changes; tidy

This commit is contained in:
Chris Cannam
2022-06-22 13:42:58 +01:00
parent 5137b19407
commit b318fb4e8b
8 changed files with 47 additions and 29 deletions

View File

@@ -300,7 +300,6 @@ public:
setDefaultDebugLevel(int level) setDefaultDebugLevel(int level)
{ {
Log::setDefaultDebugLevel(level); Log::setDefaultDebugLevel(level);
R2Stretcher::setDefaultDebugLevel(level); //!!!
} }
}; };

View File

@@ -54,9 +54,6 @@ R2Stretcher::m_defaultIncrement = 256;
const size_t const size_t
R2Stretcher::m_defaultFftSize = 2048; R2Stretcher::m_defaultFftSize = 2048;
int
R2Stretcher::m_defaultDebugLevel = 0;
static bool _initialised = false; static bool _initialised = false;
R2Stretcher::R2Stretcher(size_t sampleRate, R2Stretcher::R2Stretcher(size_t sampleRate,
@@ -82,7 +79,6 @@ R2Stretcher::R2Stretcher(size_t sampleRate,
m_realtime(false), m_realtime(false),
m_options(options), m_options(options),
m_log(log), m_log(log),
m_debugLevel(m_defaultDebugLevel),
m_mode(JustCreated), m_mode(JustCreated),
m_awindow(0), m_awindow(0),
m_afilter(0), m_afilter(0),
@@ -110,7 +106,10 @@ R2Stretcher::R2Stretcher(size_t sampleRate,
_initialised = true; _initialised = true;
} }
m_log.log(1, "R2Stretcher::R2Stretcher: rate, options", m_sampleRate, options); m_log.log(1, "R2Stretcher::R2Stretcher: rate, options",
m_sampleRate, options);
m_log.log(1, "R2Stretcher::R2Stretcher: initial time ratio and pitch scale",
m_timeRatio, m_pitchScale);
// Window size will vary according to the audio sample rate, but // Window size will vary according to the audio sample rate, but
// we don't let it drop below the 48k default // we don't let it drop below the 48k default
@@ -641,7 +640,7 @@ R2Stretcher::configure()
if (!m_realtime && fftSizeChanged) { if (!m_realtime && fftSizeChanged) {
delete m_studyFFT; delete m_studyFFT;
m_studyFFT = new FFT(m_fftSize, m_debugLevel); m_studyFFT = new FFT(m_fftSize, m_log.getDebugLevel());
m_studyFFT->initFloat(); m_studyFFT->initFloat();
} }
@@ -666,7 +665,8 @@ R2Stretcher::configure()
} }
params.maxBufferSize = 4096 * 16; params.maxBufferSize = 4096 * 16;
params.debugLevel = (m_debugLevel > 0 ? m_debugLevel-1 : 0); int myLevel = m_log.getDebugLevel();
params.debugLevel = (myLevel > 0 ? myLevel-1 : 0);
m_channelData[c]->resampler = new Resampler(params, 1); m_channelData[c]->resampler = new Resampler(params, 1);
@@ -695,7 +695,7 @@ R2Stretcher::configure()
!(m_options & RubberBandStretcher::OptionTransientsSmooth), !(m_options & RubberBandStretcher::OptionTransientsSmooth),
m_log); m_log);
m_stretchCalculator->setDebugLevel(m_debugLevel); m_stretchCalculator->setDebugLevel(m_log.getDebugLevel());
m_inputDuration = 0; m_inputDuration = 0;
// Prepare the inbufs with half a chunk of emptiness. The centre // Prepare the inbufs with half a chunk of emptiness. The centre
@@ -801,7 +801,8 @@ R2Stretcher::reconfigure()
params.dynamism = Resampler::RatioOftenChanging; params.dynamism = Resampler::RatioOftenChanging;
params.ratioChange = Resampler::SmoothRatioChange; params.ratioChange = Resampler::SmoothRatioChange;
params.maxBufferSize = m_sWindowSize; params.maxBufferSize = m_sWindowSize;
params.debugLevel = (m_debugLevel > 0 ? m_debugLevel-1 : 0); int myLevel = m_log.getDebugLevel();
params.debugLevel = (myLevel > 0 ? myLevel-1 : 0);
m_channelData[c]->resampler = new Resampler(params, 1); m_channelData[c]->resampler = new Resampler(params, 1);
@@ -1152,8 +1153,10 @@ R2Stretcher::calculateStretch()
void void
R2Stretcher::setDebugLevel(int level) R2Stretcher::setDebugLevel(int level)
{ {
m_debugLevel = level; m_log.setDebugLevel(level);
if (m_stretchCalculator) m_stretchCalculator->setDebugLevel(level); if (m_stretchCalculator) {
m_stretchCalculator->setDebugLevel(level);
}
} }
size_t size_t

View File

@@ -100,7 +100,6 @@ public:
void calculateStretch(); void calculateStretch();
void setDebugLevel(int level); void setDebugLevel(int level);
static void setDefaultDebugLevel(int level) { m_defaultDebugLevel = level; }
protected: protected:
size_t m_sampleRate; size_t m_sampleRate;
@@ -177,7 +176,6 @@ protected:
bool m_realtime; bool m_realtime;
RubberBandStretcher::Options m_options; RubberBandStretcher::Options m_options;
Log m_log; Log m_log;
int m_debugLevel; //!!! to go once Log switch complete
enum ProcessMode { enum ProcessMode {
JustCreated, JustCreated,
@@ -255,7 +253,6 @@ protected:
void writeOutput(RingBuffer<float> &to, float *from, void writeOutput(RingBuffer<float> &to, float *from,
size_t qty, size_t &outCount, size_t theoreticalOut); size_t qty, size_t &outCount, size_t theoreticalOut);
static int m_defaultDebugLevel; //!!! to go
static const size_t m_defaultIncrement; static const size_t m_defaultIncrement;
static const size_t m_defaultFftSize; static const size_t m_defaultFftSize;
}; };

View File

@@ -441,7 +441,7 @@ R2Stretcher::processChunkForChannel(size_t c,
modifyChunk(c, phaseIncrement, phaseReset); modifyChunk(c, phaseIncrement, phaseReset);
synthesiseChunk(c, shiftIncrement); // reads from cd.mag, cd.phase synthesiseChunk(c, shiftIncrement); // reads from cd.mag, cd.phase
if (m_debugLevel > 2) { if (m_log.getDebugLevel() > 2) {
if (phaseReset) { if (phaseReset) {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
cd.accumulator[i] = 1.2f - (i % 3) * 1.2f; cd.accumulator[i] = 1.2f - (i % 3) * 1.2f;

View File

@@ -119,10 +119,12 @@ public:
{ {
double rate = m_parameters.sampleRate; double rate = m_parameters.sampleRate;
m_log.log(1, "Guide: rate", rate);
int bandFftSize = roundUp(int(ceil(rate/16.0))); int bandFftSize = roundUp(int(ceil(rate/16.0)));
m_configuration.fftBandLimits[0] = m_configuration.fftBandLimits[0] =
BandLimits(bandFftSize, rate, 0.0, m_maxLower); BandLimits(bandFftSize, rate, 0.0, m_maxLower);
// This is the classification and fallback FFT: we need it to // This is the classification and fallback FFT: we need it to
// go up to Nyquist so we can seamlessly switch to it for // go up to Nyquist so we can seamlessly switch to it for
// longer stretches // longer stretches
@@ -133,6 +135,9 @@ public:
bandFftSize = roundUp(int(ceil(rate/64.0))); bandFftSize = roundUp(int(ceil(rate/64.0)));
m_configuration.fftBandLimits[2] = m_configuration.fftBandLimits[2] =
BandLimits(bandFftSize, rate, m_minHigher, rate/2.0); BandLimits(bandFftSize, rate, m_minHigher, rate/2.0);
m_log.log(1, "Guide: classification FFT size",
m_configuration.classificationFftSize);
} }
const Configuration &getConfiguration() const { const Configuration &getConfiguration() const {
@@ -331,6 +336,10 @@ public:
*/ */
} }
void setDebugLevel(int level) {
m_log.setDebugLevel(level);
}
protected: protected:
Parameters m_parameters; Parameters m_parameters;
Log m_log; Log m_log;

View File

@@ -111,17 +111,17 @@ public:
int highest = configuration.fftBandLimits[myFftBand].b1max; int highest = configuration.fftBandLimits[myFftBand].b1max;
if (m_log.getDebugLevel() > 0 && !m_reported) { if (m_log.getDebugLevel() > 0 && !m_reported) {
std::ostringstream ostr; m_log.log(1, "PhaseAdvance: for fftSize and bins",
ostr << "PhaseAdvance: fftSize = " << m_parameters.fftSize m_parameters.fftSize, bs);
<< ": bins = " << bs << ", channels = " << channels m_log.log(1, "PhaseAdvance: channels", channels);
<< ", inhop = "<< inhop << ", outhop = " << outhop m_log.log(1, "PhaseAdvance: widest bin range for this size",
<< ", ratio = " << ratio << std::endl; lowest, highest);
ostr << "PhaseAdvance: lowest possible bin = " << lowest m_log.log(1, "PhaseAdvance: widest freq range for this size",
<< " (" << configuration.fftBandLimits[myFftBand].f0min configuration.fftBandLimits[myFftBand].f0min,
<< "Hz), highest = " << highest configuration.fftBandLimits[myFftBand].f1max);
<< " (" << configuration.fftBandLimits[myFftBand].f1max m_log.log(1, "PhaseAdvance: initial inhop and outhop",
<< "Hz)" << std::endl; inhop, outhop);
m_log.log(1, ostr.str().c_str()); m_log.log(1, "PhaseAdvance: initial ratio", ratio);
m_reported = true; m_reported = true;
} }

View File

@@ -53,6 +53,11 @@ R3Stretcher::R3Stretcher(Parameters parameters,
m_totalOutputDuration(0), m_totalOutputDuration(0),
m_mode(ProcessMode::JustCreated) m_mode(ProcessMode::JustCreated)
{ {
m_log.log(1, "R3Stretcher::R3Stretcher: rate, options",
m_parameters.sampleRate, m_parameters.options);
m_log.log(1, "R3Stretcher::R3Stretcher: initial time ratio and pitch scale",
m_timeRatio, m_pitchScale);
double maxClassifierFrequency = 16000.0; double maxClassifierFrequency = 16000.0;
if (maxClassifierFrequency > m_parameters.sampleRate/2) { if (maxClassifierFrequency > m_parameters.sampleRate/2) {
maxClassifierFrequency = m_parameters.sampleRate/2; maxClassifierFrequency = m_parameters.sampleRate/2;

View File

@@ -88,7 +88,12 @@ public:
size_t getChannelCount() const; size_t getChannelCount() const;
void setDebugLevel(int level) { void setDebugLevel(int level) {
m_log.setDebugLevel(level); //!!! +others m_log.setDebugLevel(level);
for (auto &sd : m_scaleData) {
sd.second->guided.setDebugLevel(level);
}
m_guide.setDebugLevel(level);
m_calculator->setDebugLevel(level);
} }
protected: protected: