summaryrefslogtreecommitdiffstats
path: root/src/server/LV2Block.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-19 09:44:41 +0000
committerDavid Robillard <d@drobilla.net>2015-02-19 09:44:41 +0000
commitaef939ff10362285ce1ebd872518627e524917bc (patch)
treec3bf4fac85ff91f63748432fd7d668116efe97a0 /src/server/LV2Block.cpp
parent5c035574e0fabf961aa3275e366f295dcf0716f2 (diff)
downloadingen-aef939ff10362285ce1ebd872518627e524917bc.tar.gz
ingen-aef939ff10362285ce1ebd872518627e524917bc.tar.bz2
ingen-aef939ff10362285ce1ebd872518627e524917bc.zip
Server side presets.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5587 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/LV2Block.cpp')
-rw-r--r--src/server/LV2Block.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index 3f6f4be1..64c80764 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -20,6 +20,7 @@
#include <cmath>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/presets/presets.h"
#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
@@ -541,6 +542,32 @@ LV2Block::post_process(ProcessContext& context)
}
}
+LilvState*
+LV2Block::load_preset(const Raul::URI& uri)
+{
+ World* world = &_lv2_plugin->lv2_info()->world();
+ LilvWorld* lworld = _lv2_plugin->lv2_info()->lv2_world();
+ LilvNode* preset = lilv_new_uri(lworld, uri.c_str());
+
+ // Load preset into world if necessary
+ lilv_world_load_resource(lworld, preset);
+
+ // Load preset from world
+ LV2_URID_Map* map = &world->uri_map().urid_map_feature()->urid_map;
+ LilvState* state = lilv_state_new_from_world(lworld, map, preset);
+
+ lilv_node_free(preset);
+ return state;
+}
+
+void
+LV2Block::apply_state(LilvState* state)
+{
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ lilv_state_restore(state, instance(v), NULL, NULL, 0, NULL);
+ }
+}
+
void
LV2Block::set_port_buffer(uint32_t voice,
uint32_t port_num,