From 7434abe664e1e95e6c8852d7b7428e6b43ff7dbc Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Tue, 21 Jun 2022 17:03:24 +0100 Subject: [PATCH] More on logging --- src/common/Log.cpp | 30 ++++++++++++++++++++++++++++++ src/finer/R3Stretcher.cpp | 35 +++++++++++++++++++++-------------- 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 src/common/Log.cpp diff --git a/src/common/Log.cpp b/src/common/Log.cpp new file mode 100644 index 0000000..7b4d32d --- /dev/null +++ b/src/common/Log.cpp @@ -0,0 +1,30 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Rubber Band Library + An audio time-stretching and pitch-shifting library. + Copyright 2007-2022 Particular Programs Ltd. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. + + Alternatively, if you have a valid commercial licence for the + Rubber Band Library obtained by agreement with the copyright + holders, you may redistribute and/or modify it under the terms + described in that licence. + + If you wish to distribute code using the Rubber Band Library + under terms other than those of the GNU General Public License, + you must obtain a valid commercial licence before doing so. +*/ + +#include "Log.h" + +namespace RubberBand { + +int Log::m_defaultDebugLevel = 0; + +} diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index 4c750da..09b48db 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -90,8 +90,8 @@ R3Stretcher::R3Stretcher(Parameters parameters, int fftSize = band.fftSize; GuidedPhaseAdvance::Parameters guidedParameters (fftSize, m_parameters.sampleRate, m_parameters.channels); - m_scaleData[fftSize] = std::make_shared(guidedParameters, - m_log); + m_scaleData[fftSize] = std::make_shared + (guidedParameters, m_log); } m_calculator = std::unique_ptr @@ -294,7 +294,12 @@ R3Stretcher::updateRatioFromMap() if (m_processInputDuration == 0) { m_timeRatio = double(m_keyFrameMap.begin()->second) / double(m_keyFrameMap.begin()->first); - std::cout << "initial key-frame map entry " << m_keyFrameMap.begin()->first << " -> " << m_keyFrameMap.begin()->second << " gives initial ratio " << m_timeRatio << std::endl; + + m_log.log2(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); + calculateHop(); m_lastKeyFrameSurpassed = 0; return; @@ -308,7 +313,8 @@ R3Stretcher::updateRatioFromMap() if (m_processInputDuration >= i0->first) { - std::cout << "at " << m_processInputDuration << " (output = " << m_totalOutputDuration << ") we have passed " << i0->first << ", looking ahead to next key frame" << std::endl; + m_log.log2(2, "input duration surpasses pending key frame", + double(m_processInputDuration), double(i0->first)); auto i1 = m_keyFrameMap.upper_bound(m_processInputDuration); @@ -333,10 +339,13 @@ R3Stretcher::updateRatioFromMap() double ratio = double(toKeyFrameAtOutput) / double(toKeyFrameAtInput); - std::cout << "keyFrameAtInput = " << keyFrameAtInput << ", keyFrameAtOutput = " << keyFrameAtOutput << std::endl; - std::cout << "currently at input = " << m_processInputDuration << ", currently at output = " << m_totalOutputDuration << std::endl; - std::cout << "toKeyFrameAtInput = " << toKeyFrameAtInput << ", toKeyFrameAtOutput = " << toKeyFrameAtOutput << std::endl; - std::cout << "ratio = " << ratio << std::endl; + m_log.log2(2, "next key frame input and output", + double(keyFrameAtInput), double(keyFrameAtOutput)); + m_log.log2(2, "current input and output", + double(m_processInputDuration), double(m_totalOutputDuration)); + m_log.log2(2, "to next key frame input and output", + double(toKeyFrameAtInput), double(toKeyFrameAtOutput)); + m_log.log1(2, "new ratio", ratio); m_timeRatio = ratio; calculateHop(); @@ -552,16 +561,14 @@ R3Stretcher::consume() // advanced the input and output since the previous frame, not the // distances we are about to advance them, so they use the m_prev // values. -/* + if (inhop != m_prevInhop) { - std::cout << "Note: inhop has changed from " << m_prevInhop - << " to " << inhop << std::endl; + m_log.log2(2, "change in inhop", double(m_prevInhop), double(inhop)); } if (outhop != m_prevOuthop) { - std::cout << "Note: outhop has changed from " << m_prevOuthop - << " to " << outhop << std::endl; + m_log.log2(2, "change in outhop", double(m_prevOuthop), double(outhop)); } -*/ + while (m_channelData.at(0)->outbuf->getWriteSpace() >= outhop) { // NB our ChannelData, ScaleData, and ChannelScaleData maps