Mercurial > hg > tipic
changeset 37:47d5321a57c2
Fix downsampling: correct window to match MATLAB implementation, apply re-normalisation
author | Chris Cannam |
---|---|
date | Thu, 01 Oct 2015 11:21:37 +0100 |
parents | 13276c5113be |
children | ec93dacba3bd |
files | src/FeatureDownsample.cpp src/FeatureDownsample.h src/TipicVampPlugin.cpp |
diffstat | 3 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/FeatureDownsample.cpp Thu Oct 01 09:28:38 2015 +0100 +++ b/src/FeatureDownsample.cpp Thu Oct 01 11:21:37 2015 +0100 @@ -4,6 +4,7 @@ #include "Filter.h" #include "Window.h" +#include "Normalise.h" #include <stdexcept> @@ -19,9 +20,9 @@ // Our windows are periodic rather than symmetric, but we want a // symmetric window here - Window<double> w(HanningWindow, params.windowLength - 1); - vector<double> wd(w.getWindowData()); - wd.push_back(wd[0]); + Window<double> w(HanningWindow, params.windowLength + 1); + vector<double> wdat(w.getWindowData());; + vector<double> wd(wdat.begin()+1, wdat.end()); double divisor = 0.0; for (auto x: wd) divisor += x; @@ -73,7 +74,8 @@ } } if (m_toNext == 0) { - out.push_back(outcol); + out.push_back(Normalise::normalise + (outcol, m_params.normP, m_params.normThresh)); m_toNext = m_params.downsampleFactor; ++m_outCount; } @@ -93,7 +95,8 @@ for (int i = 0; m_outCount < expected && i < int(tail.size()); ++i, ++m_outCount) { - out.push_back(tail[i]); + out.push_back(Normalise::normalise + (tail[i], m_params.normP, m_params.normThresh)); } return out; }
--- a/src/FeatureDownsample.h Thu Oct 01 09:28:38 2015 +0100 +++ b/src/FeatureDownsample.h Thu Oct 01 11:21:37 2015 +0100 @@ -18,10 +18,14 @@ int featureSize; int downsampleFactor; int windowLength; + int normP; // 0 = no normalisation, 1 = L^1, 2 = L^2 + double normThresh; Parameters() : featureSize(1), downsampleFactor(10), - windowLength(41) + windowLength(41), + normP(2), + normThresh(1e-6) { } };
--- a/src/TipicVampPlugin.cpp Thu Oct 01 09:28:38 2015 +0100 +++ b/src/TipicVampPlugin.cpp Thu Oct 01 11:21:37 2015 +0100 @@ -217,7 +217,7 @@ d.sampleRate /= 10.0; list.push_back(d); - d.identifier = "cp"; + d.identifier = "chroma"; d.name = "Chroma Pitch Features"; d.description = ""; d.unit = ""; @@ -375,7 +375,7 @@ v_convert(f.values.data(), block[i].data(), h); fs[outputNo].push_back(f); } - + if (m_downsamplers.find(outputNo) == m_downsamplers.end()) { FeatureDownsample::Parameters params; params.featureSize = block[0].size();