summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ingen/URIs.hpp1
-rw-r--r--src/URIs.cpp2
-rw-r--r--src/server/Engine.cpp4
-rw-r--r--src/server/LV2Block.cpp16
-rw-r--r--src/server/LV2Block.hpp2
5 files changed, 25 insertions, 0 deletions
diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp
index 00549593..290f8c94 100644
--- a/ingen/URIs.hpp
+++ b/ingen/URIs.hpp
@@ -191,6 +191,7 @@ public:
const Quark rdfs_label;
const Quark rdfs_seeAlso;
const Quark rsz_minimumSize;
+ const Quark state_loadDefaultState;
const Quark time_Position;
const Quark time_bar;
const Quark time_barBeat;
diff --git a/src/URIs.cpp b/src/URIs.cpp
index 2cc59aaa..1771ee8a 100644
--- a/src/URIs.cpp
+++ b/src/URIs.cpp
@@ -28,6 +28,7 @@
#include "lv2/lv2plug.in/ns/ext/port-props/port-props.h"
#include "lv2/lv2plug.in/ns/ext/presets/presets.h"
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
+#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/time/time.h"
#include "lv2/lv2plug.in/ns/ext/worker/worker.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
@@ -173,6 +174,7 @@ URIs::URIs(Forge& f, URIMap* map, LilvWorld* lworld)
, rdfs_label (forge, map, lworld, NS_RDFS "label")
, rdfs_seeAlso (forge, map, lworld, NS_RDFS "seeAlso")
, rsz_minimumSize (forge, map, lworld, LV2_RESIZE_PORT__minimumSize)
+ , state_loadDefaultState(forge, map, lworld, LV2_STATE__loadDefaultState)
, time_Position (forge, map, lworld, LV2_TIME__Position)
, time_bar (forge, map, lworld, LV2_TIME__bar)
, time_barBeat (forge, map, lworld, LV2_TIME__barBeat)
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 90a2c200..7ab7e315 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -21,6 +21,7 @@
#include <limits>
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
+#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "events/CreateGraph.hpp"
#include "ingen/Configuration.hpp"
@@ -96,6 +97,9 @@ Engine::Engine(Ingen::World* world)
_world->lv2_features().add_feature(
SPtr<LV2Features::Feature>(
new LV2Features::EmptyFeature(LV2_BUF_SIZE__boundedBlockLength)));
+ _world->lv2_features().add_feature(
+ SPtr<LV2Features::Feature>(
+ new LV2Features::EmptyFeature(LV2_STATE__loadDefaultState)));
}
Engine::~Engine()
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index f7627416..e1f67897 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -74,6 +74,20 @@ LV2Block::~LV2Block()
delete _instances;
}
+void
+LV2Block::load_default_state()
+{
+ const LilvPlugin* lplug = _lv2_plugin->lilv_plugin();
+ const LilvNode* uri_node = lilv_plugin_get_uri(lplug);
+ const Raul::URI uri(lilv_node_as_string(uri_node));
+
+ LilvState* default_state = load_preset(_lv2_plugin->uri());
+ if (default_state) {
+ apply_state(default_state);
+ lilv_state_free(default_state);
+ }
+}
+
SPtr<LilvInstance>
LV2Block::make_instance(URIs& uris,
SampleRate rate,
@@ -431,6 +445,8 @@ LV2Block::instantiate(BufferFactory& bufs)
}
}
+ load_default_state();
+
// FIXME: Polyphony + worker?
if (lilv_plugin_has_feature(plug, uris.work_schedule)) {
_worker_iface = (const LV2_Worker_Interface*)
diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp
index e5d41006..6483f8b0 100644
--- a/src/server/LV2Block.hpp
+++ b/src/server/LV2Block.hpp
@@ -83,6 +83,8 @@ protected:
uint32_t voice,
bool preparing);
+ void load_default_state();
+
inline LilvInstance* instance(uint32_t voice) {
return (LilvInstance*)(*_instances)[voice].get();
}