Mercurial > hg > vamp-plugin-sdk
diff vamp-sdk/PluginAdapter.cpp @ 167:31eda4b11f2b
* First bit of Vamp v2 work -- add an optional duration to features in
a backward compatible way.
Warning: this code is unstable and experimental and may change
significantly in the coming weeks.
author | cannam |
---|---|
date | Thu, 17 Jul 2008 08:52:26 +0000 |
parents | 44e6b94c2696 |
children | 006a775133b1 |
line wrap: on
line diff
--- a/vamp-sdk/PluginAdapter.cpp Wed Jul 09 11:00:16 2008 +0000 +++ b/vamp-sdk/PluginAdapter.cpp Thu Jul 17 08:52:26 2008 +0000 @@ -55,7 +55,7 @@ PluginAdapterBase *m_base; static VampPluginHandle vampInstantiate(const VampPluginDescriptor *desc, - float inputSampleRate); + float inputSampleRate); static void vampCleanup(VampPluginHandle handle); @@ -592,6 +592,7 @@ } } if (list[i].features) free(list[i].features); + if (list[i].featuresV2) free(list[i].featuresV2); } m_fs.erase(plugin); m_fsizes.erase(plugin); @@ -707,7 +708,7 @@ VampFeatureList * PluginAdapterBase::Impl::convertFeatures(Plugin *plugin, - const Plugin::FeatureSet &features) + const Plugin::FeatureSet &features) { int lastN = -1; @@ -752,6 +753,12 @@ feature->nsec = fl[j].timestamp.nsec; feature->valueCount = fl[j].values.size(); + VampFeatureV2 *v2 = &fs[n].featuresV2[j]; + + v2->hasDuration = fl[j].hasDuration; + v2->durationSec = fl[j].duration.sec; + v2->durationNsec = fl[j].duration.nsec; + if (feature->label) free(feature->label); if (fl[j].label.empty()) { @@ -800,6 +807,7 @@ while (i < n) { m_fs[plugin][i].featureCount = 0; m_fs[plugin][i].features = 0; + m_fs[plugin][i].featuresV2 = 0; m_fsizes[plugin].push_back(0); m_fvsizes[plugin].push_back(std::vector<size_t>()); i++; @@ -820,10 +828,15 @@ m_fs[plugin][n].features = (VampFeature *)realloc (m_fs[plugin][n].features, sz * sizeof(VampFeature)); + m_fs[plugin][n].featuresV2 = (VampFeatureV2 *)realloc + (m_fs[plugin][n].featuresV2, sz * sizeof(VampFeatureV2)); + while (m_fsizes[plugin][n] < sz) { + m_fs[plugin][n].features[m_fsizes[plugin][n]].hasTimestamp = 0; m_fs[plugin][n].features[m_fsizes[plugin][n]].valueCount = 0; m_fs[plugin][n].features[m_fsizes[plugin][n]].values = 0; m_fs[plugin][n].features[m_fsizes[plugin][n]].label = 0; + m_fs[plugin][n].featuresV2[m_fsizes[plugin][n]].hasDuration = 0; m_fvsizes[plugin][n].push_back(0); m_fsizes[plugin][n]++; }