comparison org/vamp_plugins/PluginLoader.java @ 23:cc9c503535d1

add listPlugins, some docs
author Chris Cannam
date Wed, 14 Nov 2012 17:53:03 +0000
parents f718b0961713
children cd430fbf6795
comparison
equal deleted inserted replaced
22:6385a6caaa7c 23:cc9c503535d1
1 1
2 package org.vamp_plugins; 2 package org.vamp_plugins;
3 3
4 /**
5 * PluginLoader loads a Vamp plugin by searching the standard Vamp
6 * installation path, and returns a Plugin object wrapping the native
7 * plugin.
8 *
9 * To load a plugin call PluginLoader.getInstance().loadPlugin(key,
10 * rate), where rate is the processing sample rate and key is the
11 * plugin key consisting of the plugin's library base name and its
12 * identifier, colon-separated. For example,
13 *
14 * Plugin p = PluginLoader.getInstance().loadPlugin("vamp-example-plugins:percussiononsets", 44100);
15 */
4 public class PluginLoader 16 public class PluginLoader
5 { 17 {
6 public class LoadFailedException extends Exception { }; 18 public class LoadFailedException extends Exception { };
7 19
20 /**
21 * PluginLoader is a singleton. Return the instance of it.
22 */
8 public static synchronized PluginLoader getInstance() { 23 public static synchronized PluginLoader getInstance() {
9 if (inst == null) { 24 if (inst == null) {
10 inst = new PluginLoader(); 25 inst = new PluginLoader();
11 inst.initialise(); 26 inst.initialise();
12 } 27 }
13 return inst; 28 return inst;
14 } 29 }
15 30
31 /**
32 * Search for all available Vamp plugins, and return a list of
33 * their plugin keys (suitable for passing to loadPlugin) in the
34 * order in which they were found.
35 */
36 public native ArrayList<String> listPlugins();
37
38 /**
39 * Load a native Vamp plugin from the plugin path. If the plugin
40 * cannot be loaded, throw LoadFailedException.
41 *
42 * key is the plugin key consisting of the plugin's library base
43 * name and its identifier, colon-separated; inputSampleRate is
44 * the processing sample rate for input audio.
45 *
46 *!!! todo: adapter flags
47 */
16 public Plugin loadPlugin(String key, float inputSampleRate) 48 public Plugin loadPlugin(String key, float inputSampleRate)
17 throws LoadFailedException { 49 throws LoadFailedException {
18 long handle = loadPluginNative(key, inputSampleRate); 50 long handle = loadPluginNative(key, inputSampleRate);
19 if (handle != 0) return new Plugin(handle); 51 if (handle != 0) return new Plugin(handle);
20 else throw new LoadFailedException(); 52 else throw new LoadFailedException();
21 } 53 }
54
55 /**
56 * Return the category hierarchy for a Vamp plugin, given its
57 * identifying key. The hierarchy is a sequence of category names
58 * giving the location of a plugin within a category forest,
59 * containing the human-readable names of the plugin's category
60 * tree root, followed by each of the nodes down to the leaf
61 * containing the plugin.
62 *
63 * If the plugin has no category information, return an empty
64 * list.
65 */
66 public native ArrayList<String> getPluginCategory(String key);
22 67
23 private PluginLoader() { initialise(); } 68 private PluginLoader() { initialise(); }
24 private native long loadPluginNative(String key, float inputSampleRate); 69 private native long loadPluginNative(String key, float inputSampleRate);
25 private native void initialise(); 70 private native void initialise();
26 private static PluginLoader inst; 71 private static PluginLoader inst;