changeset 18:530bf5009ee2

Pull out Feature to a separate file; JNI doesn't seem to be able to find its constructor otherwise. Also a couple of other fixes
author Chris Cannam
date Tue, 07 Feb 2012 12:12:36 +0000
parents 9c108ad04e9b
children 5b0847d344c3
files org/vamp_plugins/Feature.java org/vamp_plugins/Plugin.java org/vamp_plugins/RealTime.java org/vamp_plugins/test.java src/Plugin.cpp src/getset.cpp
diffstat 6 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org/vamp_plugins/Feature.java	Tue Feb 07 12:12:36 2012 +0000
@@ -0,0 +1,15 @@
+
+package org.vamp_plugins;
+
+public class Feature {
+    public boolean hasTimestamp;
+    public RealTime timestamp;
+    public boolean hasDuration;
+    public RealTime duration;
+    public float[] values;
+    public String label;
+    Feature() {
+	hasTimestamp = false; hasDuration = false;
+    }
+};
+
--- a/org/vamp_plugins/Plugin.java	Mon Feb 06 18:01:58 2012 +0000
+++ b/org/vamp_plugins/Plugin.java	Tue Feb 07 12:12:36 2012 +0000
@@ -45,18 +45,6 @@
 
     public native OutputDescriptor[] getOutputDescriptors();
 
-    public class Feature {
-	public boolean hasTimestamp;
-	public RealTime timestamp;
-	public boolean hasDuration;
-	public RealTime duration;
-	public float[] values;
-	public String label;
-	Feature() {
-	    hasTimestamp = false; hasDuration = false;
-	}
-    };
-
 // "Pseudo-typedef antipattern - don't do this": http://www.ibm.com/developerworks/java/library/j-jtp02216/index.html
 // (I would like to!)
 //    public class FeatureList extends ArrayList<Feature>;
--- a/org/vamp_plugins/RealTime.java	Mon Feb 06 18:01:58 2012 +0000
+++ b/org/vamp_plugins/RealTime.java	Tue Feb 07 12:12:36 2012 +0000
@@ -5,7 +5,7 @@
     public int sec;
     public int nsec;
 
-    RealTime(int s, int n) { sec = s; nsec = n; }
+    public RealTime(int s, int n) { sec = s; nsec = n; }
 
     static RealTime frame2RealTime(int frame, int sampleRate) {
 	//!!! warning! doesn't support -ve frame [unlike Vamp SDK version]
--- a/org/vamp_plugins/test.java	Mon Feb 06 18:01:58 2012 +0000
+++ b/org/vamp_plugins/test.java	Tue Feb 07 12:12:36 2012 +0000
@@ -3,6 +3,7 @@
 
 import java.util.ArrayList;
 import java.util.TreeMap;
+import java.lang.RuntimeException;
 
 public class test
 {
@@ -42,8 +43,11 @@
 		System.out.println(i + ": " + outputs[i].identifier + " (sample type: " + outputs[i].sampleType + ")");
 	    }
 
-	    boolean b = p.initialise(1, 0, 1024);
+	    boolean b = p.initialise(1, 1024, 1024);
 	    System.out.println("Plugin initialise returned " + b);
+	    if (!b) {
+		throw new RuntimeException("Plugin initialise failed");
+	    }
 	    
 	    float[][] buffers = new float[1][1024];
 	    for (int block = 0; block < 1024; ++block) {
@@ -54,12 +58,12 @@
 		    buffers[0][0] = 1.0f;
 		}
 		RealTime timestamp = RealTime.frame2RealTime(block * 1024, 44100);
-		TreeMap<Integer, ArrayList<Plugin.Feature>>
+		TreeMap<Integer, ArrayList<Feature>>
 		    features = p.process(buffers, timestamp);
 		System.out.println("Plugin process returned features on " + features.size() + " different output(s)");
 	    }
 
-	    TreeMap<Integer, ArrayList<Plugin.Feature>>
+	    TreeMap<Integer, ArrayList<Feature>>
 		features = p.getRemainingFeatures();
 	    System.out.println("Plugin getRemainingFeatures returned features on " + features.size() + " different output(s)");
 
--- a/src/Plugin.cpp	Mon Feb 06 18:01:58 2012 +0000
+++ b/src/Plugin.cpp	Tue Feb 07 12:12:36 2012 +0000
@@ -261,7 +261,7 @@
 static jobject
 convertFeature(JNIEnv *env, const Plugin::Feature &feature)
 {
-    jclass featClass = env->FindClass("org/vamp_plugins/Plugin$Feature");
+    jclass featClass = env->FindClass("org/vamp_plugins/Feature");
     jmethodID ctor = env->GetMethodID(featClass, "<init>", "()V");
     jobject jfeature = env->NewObject(featClass, ctor);
 
--- a/src/getset.cpp	Mon Feb 06 18:01:58 2012 +0000
+++ b/src/getset.cpp	Tue Feb 07 12:12:36 2012 +0000
@@ -69,7 +69,7 @@
 {
     jfloatArray jarr = env->NewFloatArray(values.size());
     env->SetFloatArrayRegion(jarr, 0, values.size(), values.data());
-    setObjectField(env, obj, name, "[float", jarr);
+    setObjectField(env, obj, name, "[F", jarr);
 }
 
 void