diff options
-rw-r--r-- | lilv/lilv.h | 12 | ||||
-rw-r--r-- | src/lilv_internal.h | 2 | ||||
-rw-r--r-- | src/plugin.c | 15 | ||||
-rw-r--r-- | src/world.c | 4 | ||||
-rw-r--r-- | test/lilv_test.c | 6 | ||||
-rw-r--r-- | utils/lv2info.c | 10 |
6 files changed, 32 insertions, 17 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h index fb9a7d9..6e0a392 100644 --- a/lilv/lilv.h +++ b/lilv/lilv.h @@ -899,14 +899,16 @@ lilv_plugin_get_port_by_symbol(const LilvPlugin* plugin, const LilvNode* symbol); /** - Get a port on @c plugin by the lv2:relation it represents. - If the plugin has multiple ports with the same relation (which it should - not), the one with the lowest index will be returned. + Get a port on @c plugin by the parameter it represents. + If found, the port with matching @a port_class and @a parameter is be + returned, otherwise NULL is returned. The @a port_class can be used to + distinguish the input and output ports for a parameter. */ LILV_API LilvPort* -lilv_plugin_get_port_by_relation(const LilvPlugin* plugin, - const LilvNode* relation); +lilv_plugin_get_port_by_parameter(const LilvPlugin* plugin, + const LilvNode* port_class, + const LilvNode* parameter); /** Get the full name of the plugin's author. diff --git a/src/lilv_internal.h b/src/lilv_internal.h index a6d53f7..f292d2a 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -150,11 +150,11 @@ struct LilvWorldImpl { SordNode* lv2_Plugin; SordNode* lv2_port; SordNode* lv2_portProperty; - SordNode* lv2_relation; SordNode* lv2_reportsLatency; SordNode* lv2_requiredFeature; SordNode* lv2_Specification; SordNode* lv2_symbol; + SordNode* lv2_isParameter; SordNode* pset_value; SordNode* rdf_a; SordNode* rdf_value; diff --git a/src/plugin.c b/src/plugin.c index df113a0..fb396df 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -611,19 +611,22 @@ lilv_plugin_get_port_by_property(const LilvPlugin* plugin, LILV_API LilvPort* -lilv_plugin_get_port_by_relation(const LilvPlugin* plugin, - const LilvNode* relation) +lilv_plugin_get_port_by_parameter(const LilvPlugin* plugin, + const LilvNode* port_class, + const LilvNode* parameter) { + LilvWorld* world = plugin->world; lilv_plugin_load_ports_if_necessary(plugin); for (uint32_t i = 0; i < plugin->num_ports; ++i) { LilvPort* port = plugin->ports[i]; SordIter* iter = lilv_world_query_internal( - plugin->world, + world, port->node, - plugin->world->uris.lv2_relation, - relation->val.uri_val); + world->uris.lv2_isParameter, + parameter->val.uri_val); - const bool found = !lilv_matches_end(iter); + const bool found = !lilv_matches_end(iter) && + lilv_port_is_a(plugin, port, port_class); lilv_match_end(iter); if (found) { diff --git a/src/world.c b/src/world.c index 198a02a..0dc8dee 100644 --- a/src/world.c +++ b/src/world.c @@ -45,7 +45,7 @@ lilv_world_new(void) #define NS_DYNMAN "http://lv2plug.in/ns/ext/dynmanifest#" #define NS_PSET "http://lv2plug.in/ns/ext/presets#" -#define NEW_URI(uri) sord_new_uri(world->world, (const uint8_t*)uri) +#define NEW_URI(uri) sord_new_uri(world->world, (const uint8_t*)uri) world->uris.dc_replaces = NEW_URI(NS_DCTERMS "replaces"); world->uris.doap_name = NEW_URI(LILV_NS_DOAP "name"); @@ -62,11 +62,11 @@ lilv_world_new(void) world->uris.lv2_Plugin = NEW_URI(LILV_NS_LV2 "Plugin"); world->uris.lv2_port = NEW_URI(LILV_NS_LV2 "port"); world->uris.lv2_portProperty = NEW_URI(LILV_NS_LV2 "portProperty"); - world->uris.lv2_relation = NEW_URI(LILV_NS_LV2 "relation"); world->uris.lv2_reportsLatency = NEW_URI(LILV_NS_LV2 "reportsLatency"); world->uris.lv2_requiredFeature = NEW_URI(LILV_NS_LV2 "requiredFeature"); world->uris.lv2_Specification = NEW_URI(LILV_NS_LV2 "Specification"); world->uris.lv2_symbol = NEW_URI(LILV_NS_LV2 "symbol"); + world->uris.lv2_isParameter = NEW_URI(LILV_NS_LV2 "isParameter"); world->uris.pset_value = NEW_URI(NS_PSET "value"); world->uris.rdf_a = NEW_URI(LILV_NS_RDF "type"); world->uris.rdf_value = NEW_URI(LILV_NS_RDF "value"); diff --git a/test/lilv_test.c b/test/lilv_test.c index b73d9e6..7b9c175 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -545,7 +545,7 @@ test_plugin(void) " a lv2:ControlPort ; a lv2:OutputPort ; " " lv2:index 2 ; lv2:symbol \"latency\" ; lv2:name \"Latency\" ; " " lv2:portProperty lv2:reportsLatency ; " - " lv2:relation lv2:latency " + " lv2:isParameter lv2:latency " "] . \n" ":thing doap:name \"Something else\" .\n")) return 0; @@ -615,8 +615,8 @@ test_plugin(void) LilvNode* lv2_latency = lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#latency"); - LilvPort* latency_port = lilv_plugin_get_port_by_relation( - plug, lv2_latency); + LilvPort* latency_port = lilv_plugin_get_port_by_parameter( + plug, out_class, lv2_latency); TEST_ASSERT(latency_port); TEST_ASSERT(lilv_port_get_index(plug, latency_port) == 2); diff --git a/utils/lv2info.c b/utils/lv2info.c index 02aee10..b6955ba 100644 --- a/utils/lv2info.c +++ b/utils/lv2info.c @@ -32,6 +32,7 @@ LilvNode* applies_to_pred = NULL; LilvNode* control_class = NULL; LilvNode* event_class = NULL; LilvNode* in_group_pred = NULL; +LilvNode* is_parameter_pred = NULL; LilvNode* label_pred = NULL; LilvNode* preset_class = NULL; LilvNode* role_pred = NULL; @@ -108,6 +109,13 @@ print_port(const LilvPlugin* p, printf("\t\tName: %s\n", lilv_node_as_string(name)); lilv_node_free(name); + LilvNodes* parameters = lilv_port_get_value(p, port, is_parameter_pred); + if (lilv_nodes_size(parameters) > 0) + printf("\t\tParameter: %s\n", + lilv_node_as_string( + lilv_nodes_get(parameters, lilv_nodes_begin(parameters)))); + lilv_nodes_free(parameters); + LilvNodes* groups = lilv_port_get_value(p, port, in_group_pred); if (lilv_nodes_size(groups) > 0) printf("\t\tGroup: %s\n", @@ -394,6 +402,7 @@ main(int argc, char** argv) control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT); event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT); in_group_pred = lilv_new_uri(world, NS_PG "inGroup"); + is_parameter_pred = lilv_new_uri(world, LILV_NS_LV2 "isParameter"); label_pred = lilv_new_uri(world, LILV_NS_RDFS "label"); preset_class = lilv_new_uri(world, NS_PSET "Preset"); role_pred = lilv_new_uri(world, NS_PG "role"); @@ -431,6 +440,7 @@ main(int argc, char** argv) lilv_node_free(role_pred); lilv_node_free(preset_class); lilv_node_free(label_pred); + lilv_node_free(is_parameter_pred); lilv_node_free(in_group_pred); lilv_node_free(event_class); lilv_node_free(control_class); |