Refactor and consolidate setting and copying plugin state
This commit is contained in:
parent
f5b53a6d14
commit
5216a6d987
|
@ -136,7 +136,7 @@ protected:
|
|||
bool parse_plugin_type (XMLNode const&, PluginType&, std::string&) const;
|
||||
std::shared_ptr<Plugin> find_and_load_plugin (Session&, XMLNode const&, PluginType&, std::string const&, bool& any_vst);
|
||||
|
||||
void set_control_ids (const XMLNode&, int version);
|
||||
void set_control_ids (const XMLNode&, int version, bool by_value = false);
|
||||
void preset_load_set_value (uint32_t, float);
|
||||
};
|
||||
|
||||
|
|
|
@ -367,7 +367,6 @@ private:
|
|||
void create_automatable_parameters ();
|
||||
void control_list_automation_state_changed (Evoral::Parameter, AutoState);
|
||||
void set_parameter_state_2X (const XMLNode& node, int version);
|
||||
void update_control_values (const XMLNode&, int version);
|
||||
|
||||
void enable_changed ();
|
||||
void bypassable_changed ();
|
||||
|
|
|
@ -166,7 +166,7 @@ PlugInsertBase::find_and_load_plugin (Session& s, XMLNode const& node, PluginTyp
|
|||
}
|
||||
|
||||
void
|
||||
PlugInsertBase::set_control_ids (const XMLNode& node, int version)
|
||||
PlugInsertBase::set_control_ids (const XMLNode& node, int version, bool by_value)
|
||||
{
|
||||
const XMLNodeList& nlist = node.children();
|
||||
for (XMLNodeConstIterator iter = nlist.begin(); iter != nlist.end(); ++iter) {
|
||||
|
@ -190,14 +190,21 @@ PlugInsertBase::set_control_ids (const XMLNode& node, int version)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* this may create the new controllable */
|
||||
std::shared_ptr<Evoral::Control> c = control (Evoral::Parameter (PluginAutomation, 0, p));
|
||||
|
||||
if (!c) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<AutomationControl> ac = std::dynamic_pointer_cast<AutomationControl> (c);
|
||||
if (ac) {
|
||||
if (!ac) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (by_value) {
|
||||
float val;
|
||||
if ((*iter)->get_property (X_("value"), val)) {
|
||||
ac->set_value (val, Controllable::NoGroup);
|
||||
}
|
||||
} else {
|
||||
ac->set_state (**iter, version);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2631,50 +2631,6 @@ PluginInsert::state () const
|
|||
return node;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
std::string str;
|
||||
if ((*iter)->get_property (X_("symbol"), str)) {
|
||||
std::shared_ptr<LV2Plugin> lv2plugin = std::dynamic_pointer_cast<LV2Plugin> (_plugins[0]);
|
||||
if (lv2plugin) {
|
||||
p = lv2plugin->port_index(str.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (p == (uint32_t)-1) {
|
||||
(*iter)->get_property (X_("parameter"), p);
|
||||
}
|
||||
|
||||
if (p == (uint32_t)-1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* lookup controllable */
|
||||
std::shared_ptr<Evoral::Control> c = control (Evoral::Parameter (PluginAutomation, 0, p), false);
|
||||
if (!c) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<AutomationControl> ac = std::dynamic_pointer_cast<AutomationControl> (c);
|
||||
if (ac) {
|
||||
ac->set_value (val, Controllable::NoGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
PluginInsert::set_state(const XMLNode& node, int version)
|
||||
{
|
||||
|
@ -2725,7 +2681,7 @@ PluginInsert::set_state(const XMLNode& node, int version)
|
|||
assert (_plugins[0]->unique_id() == unique_id);
|
||||
/* update controllable value only (copy plugin state) */
|
||||
set_id (node);
|
||||
update_control_values (node, version);
|
||||
set_control_ids (node, version, true);
|
||||
}
|
||||
|
||||
Processor::set_state (node, version);
|
||||
|
|
Loading…
Reference in New Issue