# HG changeset patch # User Chris Cannam # Date 1407325080 -3600 # Node ID 6ea008aa881763587a08aa8d46d3cca799aa5686 # Parent fec395fcdc7c38589bac50541e5c6e19502d9eb6 Fixes to problems reported by plugin tester diff -r fec395fcdc7c -r 6ea008aa8817 Makefile.linux --- a/Makefile.linux Tue Aug 05 11:06:04 2014 +0100 +++ b/Makefile.linux Wed Aug 06 12:38:00 2014 +0100 @@ -1,6 +1,6 @@ -CXXFLAGS := -fPIC -ffast-math -O3 -Wall -LDFLAGS := -shared -Wl,-Bstatic -lvamp-sdk -Wl,-Bdynamic -lpthread -Wl,--version-script=vamp-plugin.map +CXXFLAGS += -fPIC -ffast-math -O3 -Wall +LDFLAGS += -shared -Wl,-Bstatic -lvamp-sdk -Wl,-Bdynamic -lpthread -Wl,--version-script=vamp-plugin.map include Makefile.inc diff -r fec395fcdc7c -r 6ea008aa8817 MatchVampPlugin.cpp --- a/MatchVampPlugin.cpp Tue Aug 05 11:06:04 2014 +0100 +++ b/MatchVampPlugin.cpp Wed Aug 06 12:38:00 2014 +0100 @@ -40,6 +40,11 @@ bool MatchVampPlugin::m_serialisingMutexInitialised = false; +// We want to ensure our freq map / crossover bin in Matcher.cpp are +// always valid with a fixed FFT length in seconds, so must reject low +// sample rates +static float sampleRateMin = 5000.f; + MatchVampPlugin::MatchVampPlugin(float inputSampleRate) : Plugin(inputSampleRate), m_stepSize(0), @@ -47,6 +52,13 @@ m_begin(true), m_locked(false) { + if (inputSampleRate < sampleRateMin) { + std::cerr << "MatchVampPlugin::MatchVampPlugin: input sample rate " + << inputSampleRate << " < min supported rate " + << sampleRateMin << ", plugin will refuse to initialise" + << std::endl; + } + if (!m_serialisingMutexInitialised) { m_serialisingMutexInitialised = true; #ifdef _WIN32 @@ -149,7 +161,7 @@ { if (name == "serialise") { m_serialise = (value > 0.5); - std::cerr << "MatchVampPlugin::setParameter: set serialise to " << m_serialise << std::endl; +// std::cerr << "MatchVampPlugin::setParameter: set serialise to " << m_serialise << std::endl; } } @@ -179,6 +191,12 @@ bool MatchVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) { + if (m_inputSampleRate < sampleRateMin) { + std::cerr << "MatchVampPlugin::MatchVampPlugin: input sample rate " + << m_inputSampleRate << " < min supported rate " + << sampleRateMin << std::endl; + return false; + } if (!pm1) createMatchers(); if (channels < getMinChannelCount() || channels > getMaxChannelCount()) return false; @@ -294,6 +312,7 @@ pthread_mutex_lock(&m_serialisingMutex); #endif } + m_startTime = timestamp; m_begin = false; } @@ -359,7 +378,7 @@ Feature feature; feature.hasTimestamp = true; - feature.timestamp = xt; + feature.timestamp = m_startTime + xt; feature.values.clear(); feature.values.push_back(yt.sec + double(yt.nsec)/1.0e9); returnFeatures[0].push_back(feature); @@ -367,7 +386,7 @@ if (x != prevx) { feature.hasTimestamp = true; - feature.timestamp = xt; + feature.timestamp = m_startTime + xt; feature.values.clear(); feature.values.push_back(yt.sec + yt.msec()/1000.0); returnFeatures[1].push_back(feature); @@ -395,7 +414,7 @@ if (y != prevy) { feature.hasTimestamp = true; - feature.timestamp = yt; + feature.timestamp = m_startTime + yt; feature.values.clear(); feature.values.push_back(xt.sec + xt.msec()/1000.0); returnFeatures[2].push_back(feature); diff -r fec395fcdc7c -r 6ea008aa8817 MatchVampPlugin.h --- a/MatchVampPlugin.h Tue Aug 05 11:06:04 2014 +0100 +++ b/MatchVampPlugin.h Wed Aug 06 12:38:00 2014 +0100 @@ -68,6 +68,7 @@ mutable Matcher *pm1; mutable Matcher *pm2; mutable MatchFeeder *feeder; + Vamp::RealTime m_startTime; size_t m_stepSize; bool m_serialise; bool m_begin; diff -r fec395fcdc7c -r 6ea008aa8817 Matcher.cpp --- a/Matcher.cpp Tue Aug 05 11:06:04 2014 +0100 +++ b/Matcher.cpp Wed Aug 06 12:38:00 2014 +0100 @@ -27,9 +27,13 @@ const double Matcher::silenceThreshold = 0.0004; const int Matcher::MAX_RUN_COUNT = 3; +//#define DEBUG_MATCHER 1 + Matcher::Matcher(float rate, Matcher *p) { +#ifdef DEBUG_MATCHER std::cerr << "Matcher::Matcher(" << rate << ", " << p << ")" << std::endl; +#endif sampleRate = rate; otherMatcher = p; // the first matcher will need this to be set later @@ -82,7 +86,9 @@ Matcher::~Matcher() { +#ifdef DEBUG_MATCHER std::cerr << "Matcher(" << this << ")::~Matcher()" << std::endl; +#endif if (initialised) {