changeset 89:ef650ce77237

Start trying to adapt grids
author Chris Cannam
date Mon, 18 Mar 2013 21:24:04 +0000
parents a52cb6cd7a02
children cf88733911fd
files vamp.yeti vamppost.yeti
diffstat 2 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/vamp.yeti	Mon Mar 18 10:06:35 2013 +0000
+++ b/vamp.yeti	Mon Mar 18 21:24:04 2013 +0000
@@ -129,7 +129,8 @@
             fi;
         _: Curve ();
         esac;
-    elif od#sampleType != OutputDescriptor$SampleType#VariableSampleRate then
+    elif od#hasFixedBinCount and
+         od#sampleType != OutputDescriptor$SampleType#VariableSampleRate then
         Grid ();
     else
         Unknown ();
--- a/vamppost.yeti	Mon Mar 18 10:06:35 2013 +0000
+++ b/vamppost.yeti	Mon Mar 18 21:24:04 2013 +0000
@@ -1,5 +1,7 @@
 module vamppost;
 
+fmat = load fmatrix;
+
 fillOneSamplePerStep config features =
    (fill' n pending features =
         case pending of
@@ -42,12 +44,33 @@
         concat features;
     esac;
 
-structure type features =
+structureGrid binCount features =
+    if empty? features then
+        fmat.constMatrix binCount 0 0;
+    else
+        fmat.generate
+            do row col:
+                features[col].values[row];
+            done binCount (length features);
+    fi;
+
+structure data =
+   (type = data.output.inferredStructure;
+    features =
+        case type of
+        Grid (): concat data.features;
+        _: fillTimestamps data;
+        esac;
+    binCount = 
+        case data.output.binCount of
+        Fixed n: n;
+        _: 0;
+        esac;
     case type of
     Curve ():               // No duration, one value
         Curve features;
     Grid ():                // No duration, >1 value, not variable rate
-        Grid features;
+        Grid (structureGrid binCount (array features));
     Instants ():            // Zero-valued features
         Instants features;
     Notes ():               // Duration, at least one value (pitch or freq)
@@ -58,13 +81,12 @@
         Segmentation features;
     Unknown ():             // Other
         Unknown features;
-    esac;
+    esac);
 
 postprocess data =
     case data of
     OK data:
-        filled = fillTimestamps data;
-        structure data.output.inferredStructure filled;
+        structure data;
     Error e:
         Error e;
     esac;