Update of /cvsroot/audacity/audacity-src/src/effects/vamp
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv28958

Modified Files:
        LoadVamp.cpp VampEffect.cpp 
Log Message:
* Expand the range of Vamp plugin outputs that Audacity can display,
  to include those that return features with duration and
  unequally-spaced features with single values.

  This greatly increases the number of interesting plugins Audacity
  can run, including for example the QM key detector, tempo estimation
  and structural segmentation plugins.



Index: VampEffect.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/vamp/VampEffect.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- VampEffect.cpp      30 Dec 2008 00:36:55 -0000      1.10
+++ VampEffect.cpp      9 Jan 2009 13:49:34 -0000       1.11
@@ -308,15 +308,23 @@
    for (Vamp::Plugin::FeatureList::iterator fli = features[mOutput].begin();
         fli != features[mOutput].end(); ++fli) {
       
-      Vamp::RealTime ftime = fli->timestamp;
-      double ltime = ftime.sec + (double(ftime.nsec) / 1000000000.0);
+      Vamp::RealTime ftime0 = fli->timestamp;
+      double ltime0 = ftime0.sec + (double(ftime0.nsec) / 1000000000.0);
+
+      Vamp::RealTime ftime1 = ftime0;
+      if (fli->hasDuration) ftime1 = ftime0 + fli->duration;
+      double ltime1 = ftime1.sec + (double(ftime1.nsec) / 1000000000.0);
 
       wxString label = LAT1CTOWX(fli->label.c_str());
       if (label == wxString()) {
-         label = wxString::Format(LAT1CTOWX("%.3f"), ltime);
+         if (fli->values.empty()) {
+            label = wxString::Format(LAT1CTOWX("%.3f"), ltime0);
+         } else {
+            label = wxString::Format(LAT1CTOWX("%.3f"), *fli->values.begin());
+         }
       }
       
-      ltrack->AddLabel(ltime, ltime, label);
+      ltrack->AddLabel(ltime0, ltime1, label);
    }
 }
 

Index: LoadVamp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/vamp/LoadVamp.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- LoadVamp.cpp        23 Jun 2008 13:10:57 -0000      1.7
+++ LoadVamp.cpp        9 Jan 2009 13:49:34 -0000       1.8
@@ -95,7 +95,24 @@
 
 #endif
       
-      // For now we only support "time instants" conformable outputs
+      // We limit the listed plugin outputs to those whose results can
+      // readily be displayed in an Audacity label track.
+      //
+      // - Any output whose features have no values (time instants only),
+      //   with or without duration, is fine
+      //
+      // - Any output whose features have more than one value, or an
+      //   unknown or variable number of values, is right out
+      // 
+      // - Any output whose features have exactly one value, with
+      //   variable sample rate or with duration, should be OK --
+      //   this implies a sparse feature, of which the time and/or
+      //   duration are significant aspects worth displaying
+      //
+      // - An output whose features have exactly one value, with
+      //   fixed sample rate and no duration, cannot be usefully
+      //   displayed -- the value is the only significant piece of
+      //   data there and we have no good value plot
 
       Plugin::OutputList outputs = vp->getOutputDescriptors();
 
@@ -105,32 +122,38 @@
       
       for (Plugin::OutputList::iterator j = outputs.begin();
            j != outputs.end(); ++j) {
-         
-         if (j->hasFixedBinCount &&
-             j->binCount == 0 &&
-             j->sampleType == Plugin::OutputDescriptor::VariableSampleRate) {
 
-            wxString name = LAT1CTOWX(vp->getName().c_str());
+         if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate ||
+             j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep ||
+             !j->hasFixedBinCount ||
+             (j->hasFixedBinCount && j->binCount > 1)) {
 
-            if (outputs.size() > 1) {
-               // This is not the plugin's only output.
-               // Use "plugin name: output name" as the effect name,
-               // unless the output name is the same as the plugin name
-               wxString outputName = LAT1CTOWX(j->name.c_str());
-               if (outputName != name) {
-                  name = wxString::Format(wxT("%s: %s"),
-                                          name.c_str(), outputName.c_str());
-               }
+            // All of these qualities disqualify (see notes above)
+
+            ++n;
+            continue;
+         }
+         
+         wxString name = LAT1CTOWX(vp->getName().c_str());
+
+         if (outputs.size() > 1) {
+            // This is not the plugin's only output.
+            // Use "plugin name: output name" as the effect name,
+            // unless the output name is the same as the plugin name
+            wxString outputName = LAT1CTOWX(j->name.c_str());
+            if (outputName != name) {
+               name = wxString::Format(wxT("%s: %s"),
+                                       name.c_str(), outputName.c_str());
             }
+         }
 
 #ifdef EFFECT_CATEGORIES
-            VampEffect *effect = new VampEffect(*i, n, hasParameters, name,
+         VampEffect *effect = new VampEffect(*i, n, hasParameters, name,
                                                 vampCategory);
 #else
-            VampEffect *effect = new VampEffect(*i, n, hasParameters, name);
+         VampEffect *effect = new VampEffect(*i, n, hasParameters, name);
 #endif
-            em.RegisterEffect(effect);
-         }
+         em.RegisterEffect(effect);
 
          ++n;
       }


------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to