changeset 168:006a775133b1

* Re-do the way the v2 structure (with durations) is returned. I bungled backward compatibility -- I failed to spot the contiguous array returned from process()... duh. Also bump library versions.
author cannam
date Thu, 24 Jul 2008 16:50:11 +0000
parents 31eda4b11f2b
children af8e59f43d1d
files Makefile rdf/generator/template-generator.cpp vamp-sdk/PluginAdapter.cpp vamp-sdk/PluginHostAdapter.cpp vamp-sdk/libvamp-hostsdk.la.in vamp-sdk/libvamp-sdk.la.in vamp-sdk/vamp-sdk.pc.in vamp/vamp.h
diffstat 8 files changed, 79 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Jul 17 08:52:26 2008 +0000
+++ b/Makefile	Thu Jul 24 16:50:11 2008 +0000
@@ -28,7 +28,7 @@
 
 # Compile flags
 #
-CXXFLAGS	:= $(CXXFLAGS) -O2 -Wall -I. -fPIC
+CXXFLAGS	:= $(CXXFLAGS) -g -Wall -I. -fPIC
 
 # ar, ranlib
 #
@@ -59,14 +59,14 @@
 INSTALL_HOSTEXT_HEADERS	  := $(INSTALL_PREFIX)/include/vamp-sdk/hostext
 INSTALL_SDK_LIBS	  := $(INSTALL_PREFIX)/lib
 
-INSTALL_SDK_LIBNAME	  := libvamp-sdk.so.1.1.2
-INSTALL_SDK_LINK_ABI	  := libvamp-sdk.so.1
+INSTALL_SDK_LIBNAME	  := libvamp-sdk.so.2.0.0
+INSTALL_SDK_LINK_ABI	  := libvamp-sdk.so.2
 INSTALL_SDK_LINK_DEV	  := libvamp-sdk.so
 INSTALL_SDK_STATIC        := libvamp-sdk.a
 INSTALL_SDK_LA            := libvamp-sdk.la
 
-INSTALL_HOSTSDK_LIBNAME   := libvamp-hostsdk.so.2.1.1
-INSTALL_HOSTSDK_LINK_ABI  := libvamp-hostsdk.so.2
+INSTALL_HOSTSDK_LIBNAME   := libvamp-hostsdk.so.3.0.0
+INSTALL_HOSTSDK_LINK_ABI  := libvamp-hostsdk.so.3
 INSTALL_HOSTSDK_LINK_DEV  := libvamp-hostsdk.so
 INSTALL_HOSTSDK_STATIC    := libvamp-hostsdk.a
 INSTALL_HOSTSDK_LA        := libvamp-hostsdk.la
--- a/rdf/generator/template-generator.cpp	Thu Jul 17 08:52:26 2008 +0000
+++ b/rdf/generator/template-generator.cpp	Thu Jul 24 16:50:11 2008 +0000
@@ -186,11 +186,17 @@
     //TrackLevelOutput
 
 
-    //SparseOutput: variable sample rate. Events are not evenly spaced so we need to record the time associated with the event as it its not ensured that we have an event after the next one (but there is not time to set the duration, it has to be calculated as the different between 2 different events). The timestamp must be read.
+    // SparseOutput: variable sample rate. Events are not evenly
+    // spaced so we need to record the time associated with the event
+    // as it its not ensured that we have an event after the next one
+    // (but there is not time to set the duration, it has to be
+    // calculated as the different between 2 different events). The
+    // timestamp must be read.
 
     string res;
 
-    if (o.sampleType == Plugin::OutputDescriptor::VariableSampleRate)
+    if (o.sampleType == Plugin::OutputDescriptor::VariableSampleRate ||
+        !o.hasFixedBinCount)
     {
 
         res=\
--- a/vamp-sdk/PluginAdapter.cpp	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp-sdk/PluginAdapter.cpp	Thu Jul 24 16:50:11 2008 +0000
@@ -584,15 +584,14 @@
         VampFeatureList *list = m_fs[plugin];
         for (unsigned int i = 0; i < outputCount; ++i) {
             for (unsigned int j = 0; j < m_fsizes[plugin][i]; ++j) {
-                if (list[i].features[j].label) {
-                    free(list[i].features[j].label);
+                if (list[i].features[j].v1.label) {
+                    free(list[i].features[j].v1.label);
                 }
-                if (list[i].features[j].values) {
-                    free(list[i].features[j].values);
+                if (list[i].features[j].v1.values) {
+                    free(list[i].features[j].v1.values);
                 }
             }
             if (list[i].features) free(list[i].features);
-            if (list[i].featuresV2) free(list[i].featuresV2);
         }
         m_fs.erase(plugin);
         m_fsizes.erase(plugin);
@@ -718,6 +717,8 @@
     resizeFS(plugin, outputCount);
     VampFeatureList *fs = m_fs[plugin];
 
+//    std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: sizeof(Feature) == " << sizeof(Plugin::Feature) << ", sizeof(VampFeature) == " << sizeof(VampFeature) << ", sizeof(VampFeatureList) == " << sizeof(VampFeatureList) << std::endl;
+
     for (Plugin::FeatureSet::const_iterator fi = features.begin();
          fi != features.end(); ++fi) {
 
@@ -746,14 +747,14 @@
 
 //            std::cerr << "PluginAdapterBase::Impl::convertFeatures: j = " << j << std::endl;
 
-            VampFeature *feature = &fs[n].features[j];
+            VampFeature *feature = &fs[n].features[j].v1;
 
             feature->hasTimestamp = fl[j].hasTimestamp;
             feature->sec = fl[j].timestamp.sec;
             feature->nsec = fl[j].timestamp.nsec;
             feature->valueCount = fl[j].values.size();
 
-            VampFeatureV2 *v2 = &fs[n].featuresV2[j];
+            VampFeatureV2 *v2 = &fs[n].features[j + sz].v2;
             
             v2->hasDuration = fl[j].hasDuration;
             v2->durationSec = fl[j].duration.sec;
@@ -788,6 +789,12 @@
         }
     }
 
+//    std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: have " << outputCount << " outputs" << std::endl;
+//    for (int i = 0; i < outputCount; ++i) {
+//        std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: output " << i << " has " << fs[i].featureCount << " features" << std::endl;
+//    }
+
+
     return fs;
 }
 
@@ -807,7 +814,6 @@
     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++;
@@ -825,18 +831,15 @@
 
 //    std::cerr << "resizing from " << i << std::endl;
 
-    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));
+    m_fs[plugin][n].features = (VampFeatureUnion *)realloc
+        (m_fs[plugin][n].features, 2 * sz * sizeof(VampFeatureUnion));
 
     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_fs[plugin][n].features[m_fsizes[plugin][n]].v1.hasTimestamp = 0;
+        m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.valueCount = 0;
+        m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.values = 0;
+        m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.label = 0;
+        m_fs[plugin][n].features[m_fsizes[plugin][n + sz]].v2.hasDuration = 0;
         m_fvsizes[plugin][n].push_back(0);
         m_fsizes[plugin][n]++;
     }
@@ -853,8 +856,8 @@
 
 //    std::cerr << "resizing from " << i << std::endl;
 
-    m_fs[plugin][n].features[j].values = (float *)realloc
-        (m_fs[plugin][n].features[j].values, sz * sizeof(float));
+    m_fs[plugin][n].features[j].v1.values = (float *)realloc
+        (m_fs[plugin][n].features[j].v1.values, sz * sizeof(float));
 
     m_fvsizes[plugin][n][j] = sz;
 }
--- a/vamp-sdk/PluginHostAdapter.cpp	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp-sdk/PluginHostAdapter.cpp	Thu Jul 24 16:50:11 2008 +0000
@@ -396,37 +396,37 @@
         if (list.featureCount > 0) {
 
             Feature feature;
-            feature.values.reserve(list.features[0].valueCount);
+            feature.values.reserve(list.features[0].v1.valueCount);
 
             for (unsigned int j = 0; j < list.featureCount; ++j) {
 
-                feature.hasTimestamp = list.features[j].hasTimestamp;
-                feature.timestamp = RealTime(list.features[j].sec,
-                                             list.features[j].nsec);
+                feature.hasTimestamp = list.features[j].v1.hasTimestamp;
+                feature.timestamp = RealTime(list.features[j].v1.sec,
+                                             list.features[j].v1.nsec);
+                feature.hasDuration = false;
 
                 if (m_descriptor->vampApiVersion >= 2) {
-                    feature.hasDuration = list.featuresV2[j].hasDuration;
-                    feature.duration = RealTime(list.featuresV2[j].durationSec,
-                                                list.featuresV2[j].durationNsec);
-                } else {
-                    feature.hasDuration = false;
+                    unsigned int j2 = j + list.featureCount;
+                    feature.hasDuration = list.features[j2].v2.hasDuration;
+                    feature.duration = RealTime(list.features[j2].v2.durationSec,
+                                                list.features[j2].v2.durationNsec);
                 }
 
-                for (unsigned int k = 0; k < list.features[j].valueCount; ++k) {
-                    feature.values.push_back(list.features[j].values[k]);
+                for (unsigned int k = 0; k < list.features[j].v1.valueCount; ++k) {
+                    feature.values.push_back(list.features[j].v1.values[k]);
                 }
 
-                if (list.features[j].label) {
-                    feature.label = list.features[j].label;
+                if (list.features[j].v1.label) {
+                    feature.label = list.features[j].v1.label;
                 }
 
                 fs[i].push_back(feature);
 
-                if (list.features[j].valueCount > 0) {
+                if (list.features[j].v1.valueCount > 0) {
                     feature.values.clear();
                 }
 
-                if (list.features[j].label) {
+                if (list.features[j].v1.label) {
                     feature.label = "";
                 }
             }
--- a/vamp-sdk/libvamp-hostsdk.la.in	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp-sdk/libvamp-hostsdk.la.in	Thu Jul 24 16:50:11 2008 +0000
@@ -2,8 +2,8 @@
 library_names='%LIBNAME% %LINK_ABI% %LINK_DEV%'
 old_library='%STATIC%'
 dependency_libs=''
-current=2
-age=1
-revision=1
+current=3
+age=0
+revision=0
 installed=yes
 libdir='%LIBS%'
--- a/vamp-sdk/libvamp-sdk.la.in	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp-sdk/libvamp-sdk.la.in	Thu Jul 24 16:50:11 2008 +0000
@@ -2,8 +2,8 @@
 library_names='%LIBNAME% %LINK_ABI% %LINK_DEV%'
 old_library='%STATIC%'
 dependency_libs=''
-current=1
-age=1
-revision=2
+current=2
+age=0
+revision=0
 installed=yes
 libdir='%LIBS%'
--- a/vamp-sdk/vamp-sdk.pc.in	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp-sdk/vamp-sdk.pc.in	Thu Jul 24 16:50:11 2008 +0000
@@ -4,7 +4,7 @@
 includedir=${prefix}/include
 
 Name: vamp-sdk
-Version: 1.3.0
+Version: 2.0.0
 Description: Development library for Vamp audio analysis plugins
 Libs: -L${libdir} -lvamp-sdk
 Cflags: -I${includedir} 
--- a/vamp/vamp.h	Thu Jul 17 08:52:26 2008 +0000
+++ b/vamp/vamp.h	Thu Jul 24 16:50:11 2008 +0000
@@ -197,16 +197,33 @@
 
 } VampFeatureV2;
 
+typedef union _VampFeatureUnion
+{
+    // sizeof(featureV1) >= sizeof(featureV2) for backward compatibility
+    VampFeature   v1;
+    VampFeatureV2 v2;
+
+} VampFeatureUnion;
+
 typedef struct _VampFeatureList
 {
     /** Number of features in this feature list. */
     unsigned int featureCount;
 
-    /** Features in this feature list.  May be NULL if featureCount is zero. */
-    VampFeature *features;
+    /** Features in this feature list.  May be NULL if featureCount is
+        zero.
 
-    /** Vamp 2.0 extended information for features in this feature list. */
-    VampFeatureV2 *featuresV2;
+        If present, this array must contain featureCount feature
+        structures for a Vamp 1.0 plugin, or 2*featureCount feature
+        unions for a Vamp 2.0 plugin.
+
+        The features returned by a Vamp 2.0 plugin must consist of the
+        same feature structures as in 1.0 for the first featureCount
+        array elements, followed by featureCount unions that contain
+        pointers to V2 feature structures (or NULL pointers if no V2
+        feature structures are present).
+     */
+    VampFeatureUnion *features;
 
 } VampFeatureList;