Mercurial > hg > vampy-host
changeset 144:c64295f1cc33
Add get_parameters_of at module level
author | Chris Cannam |
---|---|
date | Tue, 21 Jul 2015 17:20:49 +0100 |
parents | 79b050ca2fc2 |
children | 61834f9c4e46 |
files | test/test_plugin_metadata.py vamp/__init__.py vamp/load.py |
diffstat | 3 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test/test_plugin_metadata.py Wed Jul 08 15:02:53 2015 +0100 +++ b/test/test_plugin_metadata.py Tue Jul 21 17:20:49 2015 +0100 @@ -1,5 +1,6 @@ import vampyhost as vh +import vamp plugin_key = "vamp-test-plugin:vamp-test-plugin" @@ -17,6 +18,9 @@ print("Test plugin version " + str(plug.info["pluginVersion"]) + " does not match expected version " + str(expectedVersion)) assert plug.info["pluginVersion"] == expectedVersion +def test_plugin_exists_module(): + assert plugin_key in vamp.list_plugins() + def test_plugin_exists_in_freq_version(): assert plugin_key_freq in vh.list_plugins() @@ -25,6 +29,11 @@ assert len(outputs) == 10 assert "input-summary" in outputs +def test_getoutputlist_module(): + outputs = vamp.get_outputs_of(plugin_key) + assert len(outputs) == 10 + assert "input-summary" in outputs + def test_getoutputlist_2(): plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) outputs = plug.get_outputs() @@ -80,6 +89,11 @@ plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) assert plug.parameters[0]["identifier"] == "produce_output" +def test_getparameters_module(): + params = vamp.get_parameters_of(plugin_key) + assert len(params) == 1 + assert params[0]["identifier"] == "produce_output" + def test_timestamp_method_fail(): plug = vh.load_plugin(plugin_key, rate, vh.ADAPT_NONE) try:
--- a/vamp/__init__.py Wed Jul 08 15:02:53 2015 +0100 +++ b/vamp/__init__.py Tue Jul 21 17:20:49 2015 +0100 @@ -96,6 +96,7 @@ * ``vamp.list_plugins`` * ``vamp.get_outputs_of`` + * ``vamp.get_parameters_of`` * ``vamp.get_category_of`` These retrieve the installed plugin keys and get basic information @@ -162,7 +163,7 @@ import vampyhost -from vamp.load import list_plugins, get_outputs_of, get_category_of +from vamp.load import list_plugins, get_outputs_of, get_parameters_of, get_category_of from vamp.process import process_audio, process_frames, process_audio_multiple_outputs, process_frames_multiple_outputs from vamp.collect import collect
--- a/vamp/load.py Wed Jul 08 15:02:53 2015 +0100 +++ b/vamp/load.py Tue Jul 21 17:20:49 2015 +0100 @@ -64,6 +64,14 @@ """ return vampyhost.get_category_of(plugin_key) +def get_parameters_of(plugin_key): + """Obtain the parameter descriptors, if any, for the given plugin key. + """ + plug = vampyhost.load_plugin(plugin_key, 44100, vampyhost.ADAPT_NONE) + params = plug.parameters + plug.unload() + return params + def load_and_configure(data, sample_rate, plugin_key, parameters, **kwargs): """Load the plugin with the given plugin key, at a given sample rate, configure it with the parameter keys and values in the given