Make this a default implementation of Logger rather than a special case in Log

This commit is contained in:
Chris Cannam
2022-06-23 09:52:23 +01:00
parent b318fb4e8b
commit 9845e4bb38
5 changed files with 53 additions and 43 deletions

View File

@@ -454,6 +454,28 @@ RubberBandVampPlugin::Impl::processOffline(const float *const *inputBuffers,
return FeatureSet();
}
static RubberBand::Log makeCerrLog()
{
auto log0 = [](const char *message) {
std::cerr << "RubberBand: " << message << "\n";
};
auto log1 = [](const char *message, double arg0) {
auto prec = std::cerr.precision();
std::cerr.precision(10);
std::cerr << "RubberBand: " << message << ": " << arg0 << "\n";
std::cerr.precision(prec);
};
auto log2 = [](const char *message, double arg0, double arg1) {
auto prec = std::cerr.precision();
std::cerr.precision(10);
std::cerr << "RubberBand: " << message
<< ": (" << arg0 << ", " << arg1 << ")" << "\n";
std::cerr.precision(prec);
};
return RubberBand::Log(log0, log1, log2);
}
RubberBandVampPlugin::FeatureSet
RubberBandVampPlugin::Impl::getRemainingFeaturesOffline()
{
@@ -464,8 +486,7 @@ RubberBandVampPlugin::Impl::getRemainingFeaturesOffline()
int rate = m_sampleRate;
RubberBand::StretchCalculator sc
(rate, m_stretcher->getInputIncrement(), true,
RubberBand::Log::makeCoutLog());
(rate, m_stretcher->getInputIncrement(), true, makeCerrLog());
size_t inputIncrement = m_stretcher->getInputIncrement();
std::vector<int> outputIncrements = m_stretcher->getOutputIncrements();