# HG changeset patch # User Chris Cannam # Date 1420719087 0 # Node ID cfba9aec756991dd22feea1b92e8c01d39323a92 # Parent b62dbe2ba958168df5bc52cdb7e5edf05b1cc619 Separate out the raw & conditioned feature outputs (previously only conditioned was available, but we want raw for our tests). Plus some optional debug output diff -r b62dbe2ba958 -r cfba9aec7569 src/DistanceMetric.cpp --- a/src/DistanceMetric.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/DistanceMetric.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -22,6 +22,16 @@ using namespace std; +//#define DEBUG_DISTANCE_METRIC 1 + +DistanceMetric::DistanceMetric(DistanceNormalisation norm) : + m_norm(norm) +{ +#ifdef DEBUG_DISTANCE_METRIC + cerr << "*** DistanceMetric: norm = " << m_norm << endl; +#endif +} + double DistanceMetric::calcDistance(const vector &f1, const vector &f2) diff -r b62dbe2ba958 -r cfba9aec7569 src/DistanceMetric.h --- a/src/DistanceMetric.h Fri Dec 19 15:07:57 2014 +0000 +++ b/src/DistanceMetric.h Thu Jan 08 12:11:27 2015 +0000 @@ -36,7 +36,7 @@ NormaliseDistanceToLogSum, }; - DistanceMetric(DistanceNormalisation norm) : m_norm(norm) { } + DistanceMetric(DistanceNormalisation norm); /** Calculates the Manhattan distance between two vectors, with an * optional normalisation by the combined values in the diff -r b62dbe2ba958 -r cfba9aec7569 src/FeatureConditioner.cpp --- a/src/FeatureConditioner.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/FeatureConditioner.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -20,6 +20,20 @@ using namespace std; +//#define DEBUG_FEATURE_CONDITIONER 1 + +FeatureConditioner::FeatureConditioner(Parameters parameters) : + m_params(parameters), + m_ltAverage(0.0) +{ +#ifdef DEBUG_FEATURE_CONDITIONER + cerr << "*** FeatureConditioner: norm = " << parameters.norm + << ", order = " << parameters.order + << ", silenceThreshold = " << parameters.silenceThreshold + << ", decay = " << parameters.decay << endl; +#endif +} + vector FeatureConditioner::process(const vector &feature) { diff -r b62dbe2ba958 -r cfba9aec7569 src/FeatureConditioner.h --- a/src/FeatureConditioner.h Fri Dec 19 15:07:57 2014 +0000 +++ b/src/FeatureConditioner.h Thu Jan 08 12:11:27 2015 +0000 @@ -91,8 +91,7 @@ * state: use one FeatureConditioner per audio source, and construct * a new one for each new source. */ - FeatureConditioner(Parameters parameters) : - m_params(parameters), m_ltAverage(0.0) { } + FeatureConditioner(Parameters parameters); /** * Process the given feature and return the conditioned feature. diff -r b62dbe2ba958 -r cfba9aec7569 src/FeatureExtractor.cpp --- a/src/FeatureExtractor.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/FeatureExtractor.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -24,11 +24,19 @@ using namespace std; +//#define DEBUG_FEATURE_EXTRACTOR 1 + FeatureExtractor::FeatureExtractor(Parameters parameters) : m_params(parameters) { m_featureSize = getFeatureSizeFor(parameters); makeFreqMap(); + +#ifdef DEBUG_FEATURE_EXTRACTOR + cerr << "*** FeatureExtractor: sampleRate = " << parameters.sampleRate + << ", useChromaFrequencyMap = " << parameters.useChromaFrequencyMap + << ", fftSize = " << parameters.fftSize << endl; +#endif } int @@ -47,12 +55,12 @@ m_freqMap = vector(m_params.fftSize / 2 + 1, 0); if (m_params.useChromaFrequencyMap) { -#ifdef DEBUG_MATCHER +#ifdef DEBUG_FEATURE_EXTRACTOR cerr << "makeFreqMap: calling makeChromaFrequencyMap" << endl; #endif makeChromaFrequencyMap(); } else { -#ifdef DEBUG_MATCHER +#ifdef DEBUG_FEATURE_EXTRACTOR cerr << "makeFreqMap: calling makeStandardFrequencyMap" << endl; #endif makeStandardFrequencyMap(); diff -r b62dbe2ba958 -r cfba9aec7569 src/Finder.cpp --- a/src/Finder.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/Finder.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -23,6 +23,9 @@ using namespace std; +//#define DEBUG_FINDER 1 +//#define PERFORM_ERROR_CHECKS 1 + Finder::Finder(Matcher *pm) { m_m = pm; @@ -37,6 +40,9 @@ void Finder::setDurations(int d1, int d2) { +#ifdef DEBUG_FINDER + cerr << "*** setDurations: " << d1 << ", " << d2 << endl; +#endif m_duration1 = d1; m_duration2 = d2; } @@ -349,14 +355,17 @@ int x = ex; int y = ey; +#ifdef DEBUG_FINDER + cerr << "*** retrievePath: smooth = " << smooth << endl; + cerr << "*** retrievePath: before: x = " << x << ", y = " << y << endl; +#endif + if (m_duration2 > 0 && m_duration2 < m_m->getOtherFrameCount()) { x = m_duration2 - 1; } if (m_duration1 > 0 && m_duration1 < m_m->getFrameCount()) { y = m_duration1 - 1; } - -// cerr << "before: x = " << x << ", y = " << y << endl; if (!m_m->isAvailable(y, x)) { // Path did not pass through the expected end point -- @@ -370,7 +379,9 @@ recalculatePathCostMatrix(0, 0, y, x); -// cerr << "start: x = " << x << ", y = " << y << endl; +#ifdef DEBUG_FINDER + cerr << "*** retrievePath: start: x = " << x << ", y = " << y << endl; +#endif while (m_m->isAvailable(y, x) && (x > 0 || y > 0)) { diff -r b62dbe2ba958 -r cfba9aec7569 src/MatchPipeline.cpp --- a/src/MatchPipeline.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/MatchPipeline.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -15,6 +15,8 @@ #include "MatchPipeline.h" +//#define DEBUG_MATCH_PIPELINE 1 + MatchPipeline::MatchPipeline(FeatureExtractor::Parameters feParams, FeatureConditioner::Parameters fcParams, Matcher::Parameters matchParams) : @@ -48,6 +50,16 @@ m_f1 = f1; m_f2 = f2; +#ifdef DEBUG_MATCH_PIPELINE + if (m_lastFrameIn1 == 1) { + cerr << "features 1 -> "; + for (int i = 0; i < (int) m_f1.size(); ++i) { + cerr << m_f1[i] << " "; + } + cerr << endl; + } +#endif + feedConditionedFeatures(m_fc1.process(f1), m_fc2.process(f2)); } @@ -56,12 +68,27 @@ { m_c1 = c1; m_c2 = c2; + +#ifdef DEBUG_MATCH_PIPELINE + if (m_lastFrameIn1 == 1) { + cerr << "conditioned features 1 -> "; + for (int i = 0; i < (int) m_c1.size(); ++i) { + cerr << m_c1[i] << " "; + } + cerr << endl; + } +#endif m_feeder.feed(c1, c2); if (aboveThreshold(c1)) m_lastFrameIn1 = m_frameNo; if (aboveThreshold(c2)) m_lastFrameIn2 = m_frameNo; +#ifdef DEBUG_MATCH_PIPELINE + cerr << "last frames are " << m_lastFrameIn1 << ", " << m_lastFrameIn2 + << endl; +#endif + ++m_frameNo; } @@ -82,11 +109,20 @@ bool MatchPipeline::aboveThreshold(const vector &f) { + // This threshold is used only to determine when either of the + // input streams has ended -- the last frame for a stream is + // considered to be the last one that was above the + // threshold. This is different from the silence threshold in + // FeatureConditioner. double threshold = 1e-4f; double sum = 0.f; for (int i = 0; i < int(f.size()); ++i) { sum += f[i] * f[i]; } +#ifdef DEBUG_MATCH_PIPELINE + cerr << "aboveThreshold: sum " << sum << ", threshold " << threshold + << ", returning " << (sum >= threshold) << endl; +#endif return (sum >= threshold); } diff -r b62dbe2ba958 -r cfba9aec7569 src/MatchVampPlugin.cpp --- a/src/MatchVampPlugin.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/MatchVampPlugin.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -446,7 +446,7 @@ int featureSize = FeatureExtractor(m_feParams).getFeatureSize(); desc.identifier = "a_features"; - desc.name = "A Features"; + desc.name = "Raw A Features"; desc.description = "Spectral features extracted from performance A"; desc.unit = ""; desc.hasFixedBinCount = true; @@ -459,7 +459,7 @@ list.push_back(desc); desc.identifier = "b_features"; - desc.name = "B Features"; + desc.name = "Raw B Features"; desc.description = "Spectral features extracted from performance B"; desc.unit = ""; desc.hasFixedBinCount = true; @@ -471,6 +471,32 @@ m_bFeaturesOutNo = list.size(); list.push_back(desc); + desc.identifier = "a_cfeatures"; + desc.name = "Conditioned A Features"; + desc.description = "Spectral features extracted from performance A, after normalisation and conditioning"; + desc.unit = ""; + desc.hasFixedBinCount = true; + desc.binCount = featureSize; + desc.hasKnownExtents = false; + desc.isQuantized = false; + desc.sampleType = OutputDescriptor::FixedSampleRate; + desc.sampleRate = outRate; + m_caFeaturesOutNo = list.size(); + list.push_back(desc); + + desc.identifier = "b_cfeatures"; + desc.name = "Conditioned B Features"; + desc.description = "Spectral features extracted from performance B, after norrmalisation and conditioning"; + desc.unit = ""; + desc.hasFixedBinCount = true; + desc.binCount = featureSize; + desc.hasKnownExtents = false; + desc.isQuantized = false; + desc.sampleType = OutputDescriptor::FixedSampleRate; + desc.sampleRate = outRate; + m_cbFeaturesOutNo = list.size(); + list.push_back(desc); + return list; } @@ -495,10 +521,13 @@ m_pipeline->feedFrequencyDomainAudio(inputBuffers[0], inputBuffers[1]); + FeatureSet returnFeatures; + vector f1, f2; - m_pipeline->extractConditionedFeatures(f1, f2); + m_pipeline->extractFeatures(f1, f2); - FeatureSet returnFeatures; + vector cf1, cf2; + m_pipeline->extractConditionedFeatures(cf1, cf2); Feature f; f.hasTimestamp = false; @@ -515,6 +544,18 @@ } returnFeatures[m_bFeaturesOutNo].push_back(f); + f.values.clear(); + for (int j = 0; j < (int)cf1.size(); ++j) { + f.values.push_back(float(cf1[j])); + } + returnFeatures[m_caFeaturesOutNo].push_back(f); + + f.values.clear(); + for (int j = 0; j < (int)cf2.size(); ++j) { + f.values.push_back(float(cf2[j])); + } + returnFeatures[m_cbFeaturesOutNo].push_back(f); + // std::cerr << "."; // std::cerr << std::endl; diff -r b62dbe2ba958 -r cfba9aec7569 src/MatchVampPlugin.h --- a/src/MatchVampPlugin.h Fri Dec 19 15:07:57 2014 +0000 +++ b/src/MatchVampPlugin.h Thu Jan 08 12:11:27 2015 +0000 @@ -97,6 +97,8 @@ mutable int m_abRatioOutNo; mutable int m_aFeaturesOutNo; mutable int m_bFeaturesOutNo; + mutable int m_caFeaturesOutNo; + mutable int m_cbFeaturesOutNo; #ifdef _WIN32 static HANDLE m_serialisingMutex; diff -r b62dbe2ba958 -r cfba9aec7569 src/Matcher.cpp --- a/src/Matcher.cpp Fri Dec 19 15:07:57 2014 +0000 +++ b/src/Matcher.cpp Thu Jan 08 12:11:27 2015 +0000 @@ -30,9 +30,13 @@ m_metric(parameters.distanceNorm) { #ifdef DEBUG_MATCHER - cerr << "Matcher::Matcher(" << m_params.sampleRate << ", " << p << ")" << endl; + cerr << "*** Matcher: distanceNorm = " << parameters.distanceNorm + << ", hopTime = " << parameters.hopTime + << ", blockTime = " << parameters.blockTime + << ", maxRunCount = " << parameters.maxRunCount + << ", diagonalWeight = " << parameters.diagonalWeight << endl; #endif - + m_otherMatcher = p; // the first matcher will need this to be set later m_firstPM = (!p); m_frameCount = 0;