Mercurial > hg > jvamp
diff org/vamp_plugins/PluginLoader.java @ 0:f718b0961713
First draft -- can load a plugin and print its name & description
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2012 14:08:01 +0000 |
parents | |
children | cc9c503535d1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/vamp_plugins/PluginLoader.java Fri Jan 13 14:08:01 2012 +0000 @@ -0,0 +1,33 @@ + +package org.vamp_plugins; + +public class PluginLoader +{ + public class LoadFailedException extends Exception { }; + + public static synchronized PluginLoader getInstance() { + if (inst == null) { + inst = new PluginLoader(); + inst.initialise(); + } + return inst; + } + + public Plugin loadPlugin(String key, float inputSampleRate) + throws LoadFailedException { + long handle = loadPluginNative(key, inputSampleRate); + if (handle != 0) return new Plugin(handle); + else throw new LoadFailedException(); + } + + private PluginLoader() { initialise(); } + private native long loadPluginNative(String key, float inputSampleRate); + private native void initialise(); + private static PluginLoader inst; + private long nativeHandle; + + static { + System.loadLibrary("vamp-jni"); + } +} +