diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-25 09:25:03 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-25 09:25:03 -0400 |
commit | f9c7603bdb2cd9720c17146387b39c433d757327 (patch) | |
tree | f21033baeb07c3286fe87d233be1d1edaa024198 | |
parent | 936362abc20e1b813ba81955ae9251bdae8a07ad (diff) | |
parent | fe29965980a9d84e4991f8eb3083084ca108ac08 (diff) |
Merge branch 'master' of git.ardour.org:ardour/ardour
-rw-r--r-- | libs/ardour/lv2_plugin.cc | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 69efa2eeef..29af02c696 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -962,38 +962,38 @@ LV2Plugin::find_presets() lilv_node_free(lv2_appliesTo); } -bool -LV2Plugin::load_preset(PresetRecord r) +static void +set_port_value(const char* port_symbol, + void* user_data, + const void* value, + uint32_t /*size*/, + uint32_t type) { - std::map<std::string,uint32_t>::iterator it; - - LilvNode* lv2_port = lilv_new_uri(_world.world, LILV_NS_LV2 "port"); - LilvNode* lv2_symbol = lilv_new_uri(_world.world, LILV_NS_LV2 "symbol"); - LilvNode* preset = lilv_new_uri(_world.world, r.uri.c_str()); - LilvNode* pset_value = lilv_new_uri(_world.world, LV2_PRESETS__value); - - LilvNodes* ports = lilv_world_find_nodes(_world.world, preset, lv2_port, NULL); - LILV_FOREACH(nodes, i, ports) { - const LilvNode* port = lilv_nodes_get(ports, i); - const LilvNode* symbol = get_value(_world.world, port, lv2_symbol); - const LilvNode* value = get_value(_world.world, port, pset_value); - if (value && lilv_node_is_float(value)) { - it = _port_indices.find(lilv_node_as_string(symbol)); - if (it != _port_indices.end()) { - set_parameter(it->second,lilv_node_as_float(value)); - } - } + LV2Plugin* self = (LV2Plugin*)user_data; + if (type != 0 && type != self->_uri_map.uri_to_id(LV2_ATOM__Float)) { + return; // TODO: Support non-float ports } - lilv_nodes_free(ports); - lilv_node_free(pset_value); - lilv_node_free(preset); - lilv_node_free(lv2_symbol); - lilv_node_free(lv2_port); + const uint32_t port_index = self->port_index(port_symbol); + if (port_index != (uint32_t)-1) { + self->set_parameter(port_index, *(const float*)value); + } +} - Plugin::load_preset(r); +bool +LV2Plugin::load_preset(PresetRecord r) +{ + LilvWorld* world = _world.world; + LilvNode* pset = lilv_new_uri(world, r.uri.c_str()); + LilvState* state = lilv_state_new_from_world(world, _uri_map.urid_map(), pset); - return true; + if (state) { + lilv_state_restore(state, _impl->instance, set_port_value, this, 0, NULL); + lilv_state_free(state); + } + + lilv_node_free(pset); + return state; } const void* |