summaryrefslogtreecommitdiff
path: root/libs/ardour/plugin_insert.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-03-22 14:12:30 +0100
committerRobin Gareus <robin@gareus.org>2019-03-22 14:12:30 +0100
commit430e51065cbae15ec67ddf78c3b44785d4fd3a9b (patch)
tree8217c95b5b70a88b954ae653b55d2fe7908d01cd /libs/ardour/plugin_insert.cc
parente398656940fdc931f58a9a502134bbe3574b4f2a (diff)
Update cAutomationControl values when copying state
This fixes a bug that can result in inconsistent session-state when copying plugin state from one plugin to another (via drag/drop ProcessorBox::object_drop, LINK). The underlying plugin state and settings are copied, port _shadow_data is updated, and ::get_parameter() shows the correct new value. However the Controllable was not updated. On Session save/restore the value may have be lost or was inconsistently restored.
Diffstat (limited to 'libs/ardour/plugin_insert.cc')
-rw-r--r--libs/ardour/plugin_insert.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc
index 72fbae606b..8d34c4f1e4 100644
--- a/libs/ardour/plugin_insert.cc
+++ b/libs/ardour/plugin_insert.cc
@@ -2498,7 +2498,6 @@ void
PluginInsert::set_control_ids (const XMLNode& node, int version)
{
const XMLNodeList& nlist = node.children();
-
for (XMLNodeConstIterator iter = nlist.begin(); iter != nlist.end(); ++iter) {
if ((*iter)->name() != Controllable::xml_node_name) {
continue;
@@ -2534,8 +2533,50 @@ PluginInsert::set_control_ids (const XMLNode& node, int version)
ac->set_state (**iter, version);
}
#endif
+ }
+}
+
+void
+PluginInsert::update_control_values (const XMLNode& node, int version)
+{
+ const XMLNodeList& nlist = node.children();
+ for (XMLNodeConstIterator iter = nlist.begin(); iter != nlist.end(); ++iter) {
+ if ((*iter)->name() != Controllable::xml_node_name) {
+ continue;
+ }
+
+ float val;
+ if (!(*iter)->get_property (X_("value"), val)) {
+ continue;
+ }
+
+ uint32_t p = (uint32_t)-1;
+#ifdef LV2_SUPPORT
+ std::string str;
+ if ((*iter)->get_property (X_("symbol"), str)) {
+ boost::shared_ptr<LV2Plugin> lv2plugin = boost::dynamic_pointer_cast<LV2Plugin> (_plugins[0]);
+ if (lv2plugin) {
+ p = lv2plugin->port_index(str.c_str());
}
}
+#endif
+ if (p == (uint32_t)-1) {
+ (*iter)->get_property (X_("parameter"), p);
+ }
+
+ if (p == (uint32_t)-1) {
+ continue;
+ }
+
+ /* lookup controllable */
+ boost::shared_ptr<Evoral::Control> c = control (Evoral::Parameter (PluginAutomation, 0, p), false);
+ if (!c) {
+ continue;
+ }
+ boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (c);
+ if (ac) {
+ ac->set_value (val, Controllable::NoGroup);
+ }
}
}
@@ -2667,6 +2708,9 @@ PluginInsert::set_state(const XMLNode& node, int version)
add_plugin (plugin);
create_automatable_parameters ();
set_control_ids (node, version);
+ } else {
+ /* update controllable value only (copy plugin state) */
+ update_control_values (node, version);
}
node.get_property ("count", count);