Mercurial > hg > jvamp
diff org/vamp_plugins/PluginLoader.java @ 29:7d1118b3860d
Add adapter flags
author | Chris Cannam |
---|---|
date | Thu, 22 Nov 2012 11:35:17 +0000 |
parents | cd430fbf6795 |
children | c9515589be7d |
line wrap: on
line diff
--- a/org/vamp_plugins/PluginLoader.java Mon Nov 19 15:12:44 2012 +0000 +++ b/org/vamp_plugins/PluginLoader.java Thu Nov 22 11:35:17 2012 +0000 @@ -36,6 +36,69 @@ public native String[] listPlugins(); /** + * AdapterFlags contains a set of values that may be OR'd together + * and passed to loadPlugin() to indicate which of the properties + * of a plugin the host would like PluginLoader to take care of + * for it, rather than having to handle itself. + * + * Use of these flags permits the host to cater more easily for + * plugins with varying requirements for their input formats, at + * some expense in flexibility. + */ + public class AdapterFlags { + + /** + * ADAPT_INPUT_DOMAIN - If the plugin expects frequency domain + * input, automatically convert it to one that expects + * time-domain input by interpolating an adapter that carries + * out the FFT conversion silently. + * + * This enables a host to accommodate time- and + * frequency-domain plugins without needing to do any + * conversion itself, but it means the host gets no control + * over the windowing and FFT methods used. A Hann window is + * used, and the FFT is unlikely to be the fastest native + * implementation available. + */ + public static final int ADAPT_INPUT_DOMAIN = 1; + + /** + * ADAPT_CHANNEL_COUNT - Automatically handle any discrepancy + * between the number of channels supported by the plugin and + * the number provided by the host when calling + * Plugin.initialise(). This enables a host to use plugins + * that may require the input to be mixed down to mono, etc., + * without having to worry about doing that itself. + */ + public static final int ADAPT_CHANNEL_COUNT = 2; + + /** + * ADAPT_BUFFER_SIZE - Permit the host to ignore the preferred + * step and block size reported by the plugin when calling + * initialise(), and to provide whatever step and block size + * are most convenient instead. + * + * This may require modifying the sample type and rate + * specifications for the plugin outputs and modifying the + * timestamps on the output features in order to obtain + * correct time stamping. + */ + public static final int ADAPT_BUFFER_SIZE = 3; + + /** + * ADAPT_ALL - Perform all available adaptations that are + * meaningful for the plugin. + */ + public static final int ADAPT_ALL = 255; + + /** + * ADAPT_NONE - If passed to loadPlugin as the adapterFlags + * value, causes no adaptations to be done. + */ + public static final int ADAPT_NONE = 0; + }; + + /** * Load a native Vamp plugin from the plugin path. If the plugin * cannot be loaded, throw LoadFailedException. * @@ -43,11 +106,15 @@ * name and its identifier, colon-separated; inputSampleRate is * the processing sample rate for input audio. * - *!!! todo: adapter flags + * adapterFlags should contain an OR of the desired AdapterFlags + * options for the plugin, or AdapterFlags.ADAPT_NONE if no + * automatic adaptations are to be made. */ - public Plugin loadPlugin(String key, float inputSampleRate) + public Plugin loadPlugin(String key, + float inputSampleRate, + int adapterFlags) throws LoadFailedException { - long handle = loadPluginNative(key, inputSampleRate); + long handle = loadPluginNative(key, inputSampleRate, adapterFlags); if (handle != 0) return new Plugin(handle); else throw new LoadFailedException(); } @@ -66,7 +133,8 @@ public native String[] getPluginCategory(String key); private PluginLoader() { initialise(); } - private native long loadPluginNative(String key, float inputSampleRate); + private native long loadPluginNative(String key, float inputSampleRate, + int adapterFlags); private native void initialise(); private static PluginLoader inst; private long nativeHandle;