# HG changeset patch # User Chris Cannam # Date 1423129411 0 # Node ID 9c5ec36c223e927991cb9886c6c85f58dab064b3 # Parent c40c58215162b257bba74f095a7cfdd2b2a97eb4 Return values through plugin outputs diff -r c40c58215162 -r 9c5ec36c223e README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Thu Feb 05 09:43:31 2015 +0000 @@ -0,0 +1,4 @@ + +The successful attempt is in chroma-compare-plugin. It's very slow, +will be working on that. + diff -r c40c58215162 -r 9c5ec36c223e chroma-compare-plugin/TuningDifference.cpp --- a/chroma-compare-plugin/TuningDifference.cpp Thu Feb 05 08:56:42 2015 +0000 +++ b/chroma-compare-plugin/TuningDifference.cpp Thu Feb 05 09:43:31 2015 +0000 @@ -378,13 +378,14 @@ return best; } -double +pair TuningDifference::findFineFrequency(int coarseCents, double coarseScore) { int coarseResolution = 1200 / m_bpo; int searchDistance = coarseResolution/2 - 1; double bestScore = coarseScore; + int bestCents = coarseCents; double bestHz = frequencyForCentsAbove440(coarseCents); cerr << "corresponding coarse Hz " << bestHz << " scores " << coarseScore << endl; @@ -408,6 +409,7 @@ if (fineScore < bestScore) { cerr << "is good!" << endl; bestScore = fineScore; + bestCents = fineCents; bestHz = fineHz; } else { break; @@ -415,7 +417,7 @@ } } - return bestHz; + return pair(bestCents, bestHz); } TuningDifference::FeatureSet @@ -450,12 +452,23 @@ cerr << "corresponding Hz " << coarseHz << " scores " << coarseScore << endl; + //!!! This should be returning the fine chroma, not the coarse f.values.clear(); for (auto v: coarseFeature) f.values.push_back(v); fs[m_outputs["rotfeature"]].push_back(f); - double fineHz = findFineFrequency(coarseCents, coarseScore); + pair fine = findFineFrequency(coarseCents, coarseScore); + int fineCents = fine.first; + double fineHz = fine.second; + f.values.clear(); + f.values.push_back(fineHz); + fs[m_outputs["tuningfreq"]].push_back(f); + + f.values.clear(); + f.values.push_back(fineCents); + fs[m_outputs["cents"]].push_back(f); + cerr << "overall best Hz = " << fineHz << endl; return fs; diff -r c40c58215162 -r 9c5ec36c223e chroma-compare-plugin/TuningDifference.h --- a/chroma-compare-plugin/TuningDifference.h Thu Feb 05 08:56:42 2015 +0000 +++ b/chroma-compare-plugin/TuningDifference.h Thu Feb 05 09:43:31 2015 +0000 @@ -64,7 +64,7 @@ TFeature computeFeatureFromSignal(const Signal &signal, double hz) const; double featureDistance(const TFeature &other, int rotation = 0) const; int findBestRotation(const TFeature &other) const; - double findFineFrequency(int coarseCents, double coarseScore); + std::pair findFineFrequency(int coarseCents, double coarseScore); mutable std::map m_outputs; };