# HG changeset patch # User Chris Cannam # Date 1328616756 0 # Node ID 530bf5009ee2b57743ea6ff9263a06021ab8391a # Parent 9c108ad04e9bcdaabfeae4a3319369d78c8be6c1 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 diff -r 9c108ad04e9b -r 530bf5009ee2 org/vamp_plugins/Feature.java --- /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; + } +}; + diff -r 9c108ad04e9b -r 530bf5009ee2 org/vamp_plugins/Plugin.java --- 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; diff -r 9c108ad04e9b -r 530bf5009ee2 org/vamp_plugins/RealTime.java --- 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] diff -r 9c108ad04e9b -r 530bf5009ee2 org/vamp_plugins/test.java --- 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> + TreeMap> features = p.process(buffers, timestamp); System.out.println("Plugin process returned features on " + features.size() + " different output(s)"); } - TreeMap> + TreeMap> features = p.getRemainingFeatures(); System.out.println("Plugin getRemainingFeatures returned features on " + features.size() + " different output(s)"); diff -r 9c108ad04e9b -r 530bf5009ee2 src/Plugin.cpp --- 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, "", "()V"); jobject jfeature = env->NewObject(featClass, ctor); diff -r 9c108ad04e9b -r 530bf5009ee2 src/getset.cpp --- 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