Mercurial > hg > vamp-aubio-plugins
diff plugins/Silence.cpp @ 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 | eb246395f576 |
children | 8a20f3488d88 |
line wrap: on
line diff
--- 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) {