Start reworking log output

This commit is contained in:
Chris Cannam
2022-06-21 16:06:16 +01:00
parent e546767a6d
commit 35653f3a86
13 changed files with 258 additions and 71 deletions

View File

@@ -26,6 +26,7 @@
#include "Guide.h"
#include "../common/Log.h"
#include "../common/mathmisc.h"
#include <sstream>
@@ -41,15 +42,13 @@ public:
int fftSize;
double sampleRate;
int channels;
std::function<void(const std::string &)> logger;
Parameters(int _fftSize, double _sampleRate, int _channels,
std::function<void(const std::string &)> _log) :
fftSize(_fftSize), sampleRate(_sampleRate),
channels(_channels), logger(_log) { }
Parameters(int _fftSize, double _sampleRate, int _channels) :
fftSize(_fftSize), sampleRate(_sampleRate), channels(_channels) { }
};
GuidedPhaseAdvance(Parameters parameters) :
GuidedPhaseAdvance(Parameters parameters, Log log) :
m_parameters(parameters),
m_log(log),
m_binCount(parameters.fftSize / 2 + 1),
m_peakPicker(m_binCount),
m_reported(false) {
@@ -111,7 +110,7 @@ public:
int lowest = configuration.fftBandLimits[myFftBand].b0min;
int highest = configuration.fftBandLimits[myFftBand].b1max;
if (!m_reported) {
if (m_log.getDebugLevel() > 0 && !m_reported) {
std::ostringstream ostr;
ostr << "PhaseAdvance: fftSize = " << m_parameters.fftSize
<< ": bins = " << bs << ", channels = " << channels
@@ -122,7 +121,7 @@ public:
<< "Hz), highest = " << highest
<< " (" << configuration.fftBandLimits[myFftBand].f1max
<< "Hz)" << std::endl;
m_parameters.logger(ostr.str());
m_log.log0(1, ostr.str().c_str());
m_reported = true;
}
@@ -231,8 +230,13 @@ public:
}
}
void setDebugLevel(int debugLevel) {
m_log.setDebugLevel(debugLevel);
}
protected:
Parameters m_parameters;
Log m_log;
int m_binCount;
Peak<double> m_peakPicker;
int **m_currentPeaks;