diff options
author | David Robillard <d@drobilla.net> | 2016-03-14 20:42:36 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-03-14 20:42:36 -0400 |
commit | 9da2840ce1fc9de08d3bd052fc535c925416c45a (patch) | |
tree | ed29b9dcde19b064dae9ff482b236525ef688ff0 /src/server | |
parent | 4ee3f2666d79256a69ed66d511cbe64b83e4de5f (diff) | |
download | ingen-9da2840ce1fc9de08d3bd052fc535c925416c45a.tar.gz ingen-9da2840ce1fc9de08d3bd052fc535c925416c45a.tar.bz2 ingen-9da2840ce1fc9de08d3bd052fc535c925416c45a.zip |
Load default plugin state
Based on a patch from Hanspeter Portner.
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/Engine.cpp | 4 | ||||
-rw-r--r-- | src/server/LV2Block.cpp | 16 | ||||
-rw-r--r-- | src/server/LV2Block.hpp | 2 |
3 files changed, 22 insertions, 0 deletions
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(); } |