Mercurial > hg > jvamp
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 |
Chris@0 | 2 package org.vamp_plugins; |
Chris@0 | 3 |
Chris@0 | 4 public class PluginLoader |
Chris@0 | 5 { |
Chris@0 | 6 public class LoadFailedException extends Exception { }; |
Chris@0 | 7 |
Chris@0 | 8 public static synchronized PluginLoader getInstance() { |
Chris@0 | 9 if (inst == null) { |
Chris@0 | 10 inst = new PluginLoader(); |
Chris@0 | 11 inst.initialise(); |
Chris@0 | 12 } |
Chris@0 | 13 return inst; |
Chris@0 | 14 } |
Chris@0 | 15 |
Chris@0 | 16 public Plugin loadPlugin(String key, float inputSampleRate) |
Chris@0 | 17 throws LoadFailedException { |
Chris@0 | 18 long handle = loadPluginNative(key, inputSampleRate); |
Chris@0 | 19 if (handle != 0) return new Plugin(handle); |
Chris@0 | 20 else throw new LoadFailedException(); |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 private PluginLoader() { initialise(); } |
Chris@0 | 24 private native long loadPluginNative(String key, float inputSampleRate); |
Chris@0 | 25 private native void initialise(); |
Chris@0 | 26 private static PluginLoader inst; |
Chris@0 | 27 private long nativeHandle; |
Chris@0 | 28 |
Chris@0 | 29 static { |
Chris@0 | 30 System.loadLibrary("vamp-jni"); |
Chris@0 | 31 } |
Chris@0 | 32 } |
Chris@0 | 33 |