Mercurial > hg > vamp-aubio-plugins
changeset 31:2e979622bd93
Update plugin version numbers, remove API version back compatibility (API v1 is now so long out of date)
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Mon, 09 Jul 2012 15:44:07 +0100 |
parents | 7fd8f7a0b088 |
children | 8a20f3488d88 |
files | Makefile libmain.cpp plugins/Notes.cpp plugins/Notes.h plugins/Onset.cpp plugins/Pitch.cpp plugins/Pitch.h plugins/Silence.cpp plugins/Silence.h plugins/Tempo.cpp |
diffstat | 10 files changed, 70 insertions(+), 176 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Jul 09 15:10:35 2012 +0100 +++ b/Makefile Mon Jul 09 15:44:07 2012 +0100 @@ -5,13 +5,13 @@ # Compile flags # -CXXFLAGS := -I/Users/cannam/code/inst/include $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. +CXXFLAGS := -I../ -I../inst/include $(CXXFLAGS) -fPIC -DNDEBUG -O2 -Wall -I. # Libraries required for the plugins. Note that we can (and actively # want to) statically link libstdc++, because our plugin exposes only # a C API so there are no boundary compatibility problems. # -PLUGIN_LIBS = -L/Users/cannam/code/inst/lib -lvamp-sdk -laubio +PLUGIN_LIBS = -L../inst/lib -lvamp-sdk -laubio # Flags required to tell the compiler to make a dynamically loadable object #
--- a/libmain.cpp Mon Jul 09 15:10:35 2012 +0100 +++ b/libmain.cpp Mon Jul 09 15:44:07 2012 +0100 @@ -23,58 +23,23 @@ #include "plugins/Tempo.h" #include "plugins/Silence.h" -template <typename P> -class VersionedPluginAdapter : public Vamp::PluginAdapterBase -{ -public: - VersionedPluginAdapter(unsigned int v) : PluginAdapterBase(), m_v(v) { } - virtual ~VersionedPluginAdapter() { } - -protected: - Vamp::Plugin *createPlugin(float inputSampleRate) { - P *p = new P(inputSampleRate, m_v); - Vamp::Plugin *plugin = dynamic_cast<Vamp::Plugin *>(p); - return plugin; - } - unsigned int m_v; -}; - static Vamp::PluginAdapter<Onset> onsetAdapter; static Vamp::PluginAdapter<Pitch> pitchAdapter; +static Vamp::PluginAdapter<Notes> notesAdapter; static Vamp::PluginAdapter<Tempo> tempoAdapter; - -// These two plugins both benefit from the Vamp v2 API if available -static VersionedPluginAdapter<Notes> *notesAdapter = 0; -static VersionedPluginAdapter<Silence> *silenceAdapter = 0; - -struct Tidy -{ - ~Tidy() { delete notesAdapter; delete silenceAdapter; } -}; -static Tidy tidy; +static Vamp::PluginAdapter<Silence> silenceAdapter; const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int vampApiVersion, unsigned int index) { - if (vampApiVersion < 1) return 0; + if (vampApiVersion < 2) return 0; switch (index) { case 0: return onsetAdapter.getDescriptor(); case 1: return pitchAdapter.getDescriptor(); + case 2: return notesAdapter.getDescriptor(); case 3: return tempoAdapter.getDescriptor(); - - case 2: - if (!notesAdapter) { - notesAdapter = new VersionedPluginAdapter<Notes>(vampApiVersion); - } - return notesAdapter->getDescriptor(); - - case 4: - if (!silenceAdapter) { - silenceAdapter = new VersionedPluginAdapter<Silence>(vampApiVersion); - } - return silenceAdapter->getDescriptor(); - + case 4: return silenceAdapter.getDescriptor(); default: return 0; } }
--- a/plugins/Notes.cpp Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Notes.cpp Mon Jul 09 15:44:07 2012 +0100 @@ -24,9 +24,8 @@ using std::cerr; using std::endl; -Notes::Notes(float inputSampleRate, unsigned int apiVersion) : +Notes::Notes(float inputSampleRate) : Plugin(inputSampleRate), - m_apiVersion(apiVersion), m_ibuf(0), m_fftgrain(0), m_onset(0), @@ -45,12 +44,6 @@ m_avoidLeaps(false), m_prevPitch(-1) { - if (apiVersion == 1) { - cerr << "vamp-aubio: WARNING: using compatibility version 1 of the Vamp API for note\n" - << "tracker plugin: upgrade your host to v2 for proper duration support" << endl; - } else { - cerr << "vamp-aubio: NOTE: using v2 API for true durations" << endl; - } } Notes::~Notes() @@ -91,8 +84,7 @@ int Notes::getPluginVersion() const { - if (m_apiVersion == 1) return 2; - return 3; + return 4; } string @@ -330,17 +322,10 @@ d.unit = "Hz"; d.hasFixedBinCount = true; - if (m_apiVersion == 1) { - d.binCount = 3; - d.binNames.push_back("Frequency"); - d.binNames.push_back("Duration"); - d.binNames.push_back("Velocity"); - } else { - d.binCount = 2; - d.binNames.push_back("Frequency"); - d.binNames.push_back("Velocity"); - d.hasDuration = true; - } + d.binCount = 2; + d.binNames.push_back("Frequency"); + d.binNames.push_back("Velocity"); + d.hasDuration = true; d.hasKnownExtents = false; d.isQuantized = false; @@ -448,17 +433,12 @@ feature.timestamp = m_currentOnset - m_delay; feature.values.push_back(freq); - if (m_apiVersion == 1) { - feature.values.push_back - (Vamp::RealTime::realTime2Frame - (offTime, lrintf(m_inputSampleRate)) - - Vamp::RealTime::realTime2Frame - (m_currentOnset, lrintf(m_inputSampleRate))); - feature.hasDuration = false; - } else { - feature.hasDuration = true; - feature.duration = offTime - m_currentOnset; - } + feature.values.push_back + (Vamp::RealTime::realTime2Frame + (offTime, lrintf(m_inputSampleRate)) - + Vamp::RealTime::realTime2Frame + (m_currentOnset, lrintf(m_inputSampleRate))); + feature.hasDuration = false; feature.values.push_back(m_currentLevel); fs[0].push_back(feature);
--- a/plugins/Notes.h Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Notes.h Mon Jul 09 15:44:07 2012 +0100 @@ -27,7 +27,7 @@ class Notes : public Vamp::Plugin { public: - Notes(float inputSampleRate, unsigned int apiVersion); + Notes(float inputSampleRate); virtual ~Notes(); bool initialise(size_t channels, size_t stepSize, size_t blockSize); @@ -57,7 +57,6 @@ FeatureSet getRemainingFeatures(); protected: - int m_apiVersion; fvec_t *m_ibuf; cvec_t *m_fftgrain; fvec_t *m_onset;
--- a/plugins/Onset.cpp Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Onset.cpp Mon Jul 09 15:44:07 2012 +0100 @@ -74,7 +74,7 @@ int Onset::getPluginVersion() const { - return 1; + return 2; } string
--- a/plugins/Pitch.cpp Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Pitch.cpp Mon Jul 09 15:44:07 2012 +0100 @@ -32,8 +32,7 @@ Plugin(inputSampleRate), m_ibuf(0), m_pitchdet(0), - m_pitchtype(aubio_pitch_yinfft), - m_pitchmode(aubio_pitchm_freq), + m_pitchtype(PitchYinFFT), m_minfreq(getFrequencyForMIDIPitch(32)), m_maxfreq(getFrequencyForMIDIPitch(95)), m_silence(-90), @@ -46,7 +45,7 @@ Pitch::~Pitch() { - if (m_pitchdet) del_aubio_pitchdetection(m_pitchdet); + if (m_pitchdet) del_aubio_pitch(m_pitchdet); if (m_ibuf) del_fvec(m_ibuf); } @@ -77,7 +76,7 @@ int Pitch::getPluginVersion() const { - return 2; + return 3; } string
--- a/plugins/Pitch.h Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Pitch.h Mon Jul 09 15:44:07 2012 +0100 @@ -20,6 +20,8 @@ #include <vamp-sdk/Plugin.h> #include <aubio/aubio.h> +#include "Types.h" + class Pitch : public Vamp::Plugin { public:
--- a/plugins/Silence.cpp Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Silence.cpp Mon Jul 09 15:44:07 2012 +0100 @@ -21,9 +21,8 @@ using std::cerr; using std::endl; -Silence::Silence(float inputSampleRate, unsigned int apiVersion) : +Silence::Silence(float inputSampleRate) : Plugin(inputSampleRate), - m_apiVersion(apiVersion), m_ibuf(0), m_pbuf(0), m_tmpptrs(0), @@ -31,10 +30,6 @@ m_prevSilent(false), m_first(true) { - if (m_apiVersion == 1) { - cerr << "vamp-aubio: WARNING: using compatibility version 1 of the Vamp API for silence\n" - << "detector plugin: upgrade your host to v2 for proper duration support" << endl; - } } Silence::~Silence() @@ -71,8 +66,7 @@ int Silence::getPluginVersion() const { - if (m_apiVersion == 1) return 2; - return 3; + return 4; } string @@ -157,52 +151,27 @@ OutputDescriptor d; - if (m_apiVersion == 1) { + d.identifier = "silent"; + d.name = "Silent Regions"; + d.description = "Return an interval covering each silent region"; + d.hasFixedBinCount = true; + d.binCount = 0; + d.hasKnownExtents = false; + d.sampleType = OutputDescriptor::VariableSampleRate; + d.sampleRate = 0; + d.hasDuration = true; + list.push_back(d); - d.identifier = "silencestart"; - d.name = "Beginnings of Silent Regions"; - d.description = "Return a single instant at the point where each silent region begins"; - d.hasFixedBinCount = true; - d.binCount = 0; - d.hasKnownExtents = false; - d.sampleType = OutputDescriptor::VariableSampleRate; - d.sampleRate = 0; - list.push_back(d); - - d.identifier = "silenceend"; - d.name = "Ends of Silent Regions"; - d.description = "Return a single instant at the point where each silent region ends"; - d.hasFixedBinCount = true; - d.binCount = 0; - d.hasKnownExtents = false; - d.sampleType = OutputDescriptor::VariableSampleRate; - d.sampleRate = 0; - list.push_back(d); - - } else { - - d.identifier = "silent"; - d.name = "Silent Regions"; - d.description = "Return an interval covering each silent region"; - d.hasFixedBinCount = true; - d.binCount = 0; - d.hasKnownExtents = false; - d.sampleType = OutputDescriptor::VariableSampleRate; - d.sampleRate = 0; - d.hasDuration = true; - list.push_back(d); - - d.identifier = "noisy"; - d.name = "Non-Silent Regions"; - d.description = "Return an interval covering each non-silent region"; - d.hasFixedBinCount = true; - d.binCount = 0; - d.hasKnownExtents = false; - d.sampleType = OutputDescriptor::VariableSampleRate; - d.sampleRate = 0; - d.hasDuration = true; - list.push_back(d); - } + d.identifier = "noisy"; + d.name = "Non-Silent Regions"; + d.description = "Return an interval covering each non-silent region"; + d.hasFixedBinCount = true; + d.binCount = 0; + d.hasKnownExtents = false; + d.sampleType = OutputDescriptor::VariableSampleRate; + d.sampleRate = 0; + d.hasDuration = true; + list.push_back(d); d.identifier = "silencelevel"; d.name = "Silence Test"; @@ -288,31 +257,21 @@ feature.values.clear(); - if (m_apiVersion == 1) { + if (!m_first) { + feature.timestamp = m_lastChange; + feature.hasDuration = true; + feature.duration = featureStamp - m_lastChange; if (silent) { - // silencestart feature + // non-silent regions feature + // (becoming silent, so this is a non-silent region) + returnFeatures[1].push_back(feature); + } else { + // silent regions feature + // (becoming non-silent, so this is a silent region) returnFeatures[0].push_back(feature); - } else { - // silenceend feature - returnFeatures[1].push_back(feature); - } - } else { - if (!m_first) { - feature.timestamp = m_lastChange; - feature.hasDuration = true; - feature.duration = featureStamp - m_lastChange; - if (silent) { - // non-silent regions feature - // (becoming silent, so this is a non-silent region) - returnFeatures[1].push_back(feature); - } else { - // silent regions feature - // (becoming non-silent, so this is a silent region) - returnFeatures[0].push_back(feature); - } - } - m_lastChange = featureStamp; + } } + m_lastChange = featureStamp; m_prevSilent = silent; m_first = false; @@ -342,24 +301,15 @@ Feature feature; feature.hasTimestamp = true; - if (m_apiVersion == 1) { - if (m_prevSilent) { - // silenceend feature - feature.timestamp = m_lastTimestamp; - returnFeatures[1].push_back(feature); - } + feature.timestamp = m_lastChange; + feature.hasDuration = true; + feature.duration = m_lastTimestamp - m_lastChange; + if (m_prevSilent) { + // silent regions feature + returnFeatures[0].push_back(feature); } else { - - feature.timestamp = m_lastChange; - feature.hasDuration = true; - feature.duration = m_lastTimestamp - m_lastChange; - if (m_prevSilent) { - // silent regions feature - returnFeatures[0].push_back(feature); - } else { - // non-silent regions feature - returnFeatures[1].push_back(feature); - } + // non-silent regions feature + returnFeatures[1].push_back(feature); } if (!m_prevSilent) {
--- a/plugins/Silence.h Mon Jul 09 15:10:35 2012 +0100 +++ b/plugins/Silence.h Mon Jul 09 15:44:07 2012 +0100 @@ -23,7 +23,7 @@ class Silence : public Vamp::Plugin { public: - Silence(float inputSampleRate, unsigned int apiVersion); + Silence(float inputSampleRate); virtual ~Silence(); bool initialise(size_t channels, size_t stepSize, size_t blockSize); @@ -53,7 +53,6 @@ FeatureSet getRemainingFeatures(); protected: - unsigned int m_apiVersion; fvec_t *m_ibuf; fvec_t *m_pbuf; smpl_t **m_tmpptrs;