changeset 103:1ff7bc742ec5

A typing workaround, so that we can get the right type in to vamppost
author Chris Cannam
date Tue, 26 Mar 2013 22:41:06 +0000
parents 190ba28b64ab
children 4e57dd686674
files bin/yetilab yetilab/vamp/vamp.yeti yetilab/vamp/vamppost.yeti
diffstat 3 files changed, 19 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/bin/yetilab	Fri Mar 22 23:06:12 2013 +0000
+++ b/bin/yetilab	Tue Mar 26 22:41:06 2013 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 MYDIR=`dirname $0`
-YETII_DIR=../yetii
+AYR_DIR=../ayr
 YETI_LIBDIR=${YETI_LIBDIR:=../yeti}
 if [ ! -d "$YETI_LIBDIR" ]; then 
     YETI_LIBDIR=../other/yeti
@@ -9,8 +9,8 @@
 YERTLE_DIR=${YERTLE_DIR:=../yertle}
 
 YETI_MODULE_SOURCE_PATH=${YETI_LIBDIR}/modules \
-    LD_LIBRARY_PATH=$YETII_DIR:$JVAMP_DIR:$LD_LIBRARY_PATH \
+    LD_LIBRARY_PATH=$AYR_DIR:$JVAMP_DIR:$LD_LIBRARY_PATH \
     $JAVA_HOME/bin/java -classpath \
-        $YETII_DIR/yetii.jar:$YETI_LIBDIR/yeti.jar:$YETI_LIBDIR/yeti-lib.jar:$YETII_DIR/libreadline-java.jar:$JVAMP_DIR/jvamp.jar:$YERTLE_DIR/yertle.jar:./jtransforms-2.4.jar \
-    com.particularprograms.yetii "$@"
+        $AYR_DIR/ayr.jar:$YETI_LIBDIR/yeti.jar:$YETI_LIBDIR/yeti-lib.jar:$AYR_DIR/libreadline-java.jar:$JVAMP_DIR/jvamp.jar:$YERTLE_DIR/yertle.jar:./jtransforms-2.4.jar \
+    com.particularprograms.ayr "$@"
 
--- a/yetilab/vamp/vamp.yeti	Fri Mar 22 23:06:12 2013 +0000
+++ b/yetilab/vamp/vamp.yeti	Tue Mar 26 22:41:06 2013 +0000
@@ -10,7 +10,7 @@
 
 import java.util: Map, List;
 
-block = load yetilab.block.block;
+bl = load yetilab.block.block;
 fr = load yetilab.stream.framer;
 af = load yetilab.stream.audiofile;
 vamprdf = load yetilab.vamp.vamprdf;
@@ -22,7 +22,7 @@
 feature f is ~Feature -> 'a = {
     timestamp = if f#hasTimestamp then Time (realTime f#timestamp) else Untimed () fi,
     duration = if f#hasDuration then Time (realTime f#duration) else Untimed () fi,
-    values = f#values,
+    values = bl.fromFloats f#values,
     label = f#label,
     };
 
@@ -185,7 +185,7 @@
         None (): map (outputDescriptor (None ())) p#getOutputDescriptors();
         esac,
     process blocks time is 'a -> ~RealTime -> 'b = 
-        featureSet p#process((map block.floats blocks) as ~float[][], 0, time),
+        featureSet p#process((map bl.floats blocks) as ~float[][], 0, time),
     getRemainingFeatures () = featureSet p#getRemainingFeatures(),
     dispose () = p#dispose(),
     });
@@ -209,6 +209,10 @@
         Error "Failed to load Vamp plugin with key \(key)"
     yrt;
 
+//!!! bring block typedef into scope -- this shouldn't be necessary,
+//but see comment in processed below
+load yetilab.block.block;
+
 processed { p, sampleRate, hop } frames count 
     // I don't know why this type declaration is necessary. Without
     // it, yeti records the return type as 'a and can't do anything
@@ -219,7 +223,7 @@
                   list<{ timestamp is Time number | Untimed (), 
                          duration  is Time number | Untimed (),
                          label is string,
-                         values is ~float[]
+                         values is block
                        }>>> =
     case frames of
     frame::rest:
@@ -265,7 +269,7 @@
         returnErrorFrom p stream "Failed to initialise plugin \(key) with channels = \(channels), blockSize = \(blockSize), stepSize = \(stepSize)";
     fi);
 
-process key output stream =
+processStream key output stream =
     case loadPlugin stream.sampleRate key of
     OK p:
         outputNo = outputNumberByName p output;
@@ -273,14 +277,14 @@
             processWith key p outputNo stream
         else
             outputs = strJoin ", " (map (.identifier) p.outputs);
-            returnErrorFrom p stream "Plugin \(key) has no output named \(output) (outputs are \(outputs))"
+            returnErrorFrom p stream "Plugin \(key) has no output named \(output) (outputs are: \(outputs))"
         fi;
     Error e: Error e;
     esac;
 
 processFile key output filename = 
     case af.open filename of
-    Stream s: process key output s;
+    Stream s: processStream key output s;
     Error e: Error e;
     esac;
 
@@ -289,7 +293,7 @@
 get pluginKeys = listPlugins,
 loadPlugin,
 categoryOf,
-process,
+processStream,
 processFile,
 }
 
--- a/yetilab/vamp/vamppost.yeti	Fri Mar 22 23:06:12 2013 +0000
+++ b/yetilab/vamp/vamppost.yeti	Tue Mar 26 22:41:06 2013 +0000
@@ -1,6 +1,7 @@
 module yetilab.vamp.vamppost;
 
 fmat = load yetilab.block.fmatrix;
+bl = load yetilab.block.block;
 
 fillOneSamplePerStep config features =
    (fill' n pending features =
@@ -50,7 +51,8 @@
     else
         fmat.generate
             do row col:
-                features[col].values[row];
+                v = bl.data features[col].values;
+                v[row];
             done binCount (length features);
     fi;