diff options
author | David Robillard <d@drobilla.net> | 2015-08-12 04:46:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-08-12 04:46:29 +0000 |
commit | dd79e76e41446833088482588456afed37231bff (patch) | |
tree | c0f3c5c2fc74b286d529df69ad2206e2fddd96f9 /src/server/LV2Plugin.cpp | |
parent | 44af7b7b66e2083819103c760ab3bf4980469f86 (diff) | |
download | ingen-dd79e76e41446833088482588456afed37231bff.tar.gz ingen-dd79e76e41446833088482588456afed37231bff.tar.bz2 ingen-dd79e76e41446833088482588456afed37231bff.zip |
Server-side presets.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5703 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/LV2Plugin.cpp')
-rw-r--r-- | src/server/LV2Plugin.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 58491f4c..d88689ca 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -16,7 +16,9 @@ #include <string> +#include "ingen/Log.hpp" #include "ingen/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/presets/presets.h" #include "Driver.hpp" #include "Engine.hpp" @@ -29,7 +31,9 @@ namespace Ingen { namespace Server { LV2Plugin::LV2Plugin(SPtr<LV2Info> lv2_info, const Raul::URI& uri) - : PluginImpl(lv2_info->world().uris(), Plugin::LV2, uri) + : PluginImpl(lv2_info->world().uris(), + lv2_info->world().uris().lv2_Plugin, + uri) , _lilv_plugin(NULL) , _lv2_info(lv2_info) { @@ -80,5 +84,43 @@ LV2Plugin::lilv_plugin(const LilvPlugin* p) _lilv_plugin = p; } +void +LV2Plugin::load_presets() +{ + LilvWorld* lworld = _lv2_info->world().lilv_world(); + LilvNode* pset_Preset = lilv_new_uri(lworld, LV2_PRESETS__Preset); + LilvNode* rdfs_label = lilv_new_uri(lworld, LILV_NS_RDFS "label"); + LilvNodes* presets = lilv_plugin_get_related(_lilv_plugin, pset_Preset); + + if (presets) { + LILV_FOREACH(nodes, i, presets) { + const LilvNode* preset = lilv_nodes_get(presets, i); + lilv_world_load_resource(lworld, preset); + + LilvNodes* labels = lilv_world_find_nodes( + lworld, preset, rdfs_label, NULL); + if (labels) { + const LilvNode* label = lilv_nodes_get_first(labels); + + _presets.emplace(Raul::URI(lilv_node_as_uri(preset)), + lilv_node_as_string(label)); + + lilv_nodes_free(labels); + } else { + _lv2_info->world().log().error( + fmt("Preset <%1%> has no rdfs:label\n") + % lilv_node_as_string(lilv_nodes_get(presets, i))); + } + } + + lilv_nodes_free(presets); + } + + lilv_node_free(rdfs_label); + lilv_node_free(pset_Preset); + + PluginImpl::load_presets(); +} + } // namespace Server } // namespace Ingen |