Tracks doesn't know how to handle Engine (JACK) sync
[ardour.git] / libs / ardour / plugin_insert.cc
index 599a929deaa3dcd62304ad96b9683392d69de629..8da0abb00fac440f58630e57eb383c7d96342449 100644 (file)
@@ -601,6 +601,69 @@ PluginInsert::default_parameter_value (const Evoral::Parameter& param)
        return _plugins[0]->default_value (param.id());
 }
 
+
+bool
+PluginInsert::can_reset_all_parameters ()
+{
+       bool all = true;
+       uint32_t params = 0;
+       for (uint32_t par = 0; par < _plugins[0]->parameter_count(); ++par) {
+               bool ok=false;
+               const uint32_t cid = _plugins[0]->nth_parameter (par, ok);
+
+               if (!ok || !_plugins[0]->parameter_is_input(cid)) {
+                       continue;
+               }
+
+               boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter(PluginAutomation, 0, cid));
+               if (!ac) {
+                       continue;
+               }
+
+               ++params;
+               if (ac->automation_state() & Play) {
+                       all = false;
+                       break;
+               }
+       }
+       return all && (params > 0);
+}
+
+bool
+PluginInsert::reset_parameters_to_default ()
+{
+       bool all = true;
+
+       for (uint32_t par = 0; par < _plugins[0]->parameter_count(); ++par) {
+               bool ok=false;
+               const uint32_t cid = _plugins[0]->nth_parameter (par, ok);
+
+               if (!ok || !_plugins[0]->parameter_is_input(cid)) {
+                       continue;
+               }
+
+               const float dflt = _plugins[0]->default_value (cid);
+               const float curr = _plugins[0]->get_parameter (cid);
+
+               if (dflt == curr) {
+                       continue;
+               }
+
+               boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter(PluginAutomation, 0, cid));
+               if (!ac) {
+                       continue;
+               }
+
+               if (ac->automation_state() & Play) {
+                       all = false;
+                       continue;
+               }
+
+               ac->set_value (dflt);
+       }
+       return all;
+}
+
 boost::shared_ptr<Plugin>
 PluginInsert::plugin_factory (boost::shared_ptr<Plugin> other)
 {
@@ -1126,7 +1189,7 @@ PluginInsert::set_parameter_state_2X (const XMLNode& node, int version)
                        boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(
                                        control(Evoral::Parameter(PluginAutomation, 0, port_id), true));
 
-                       if (c) {
+                       if (c && c->alist()) {
                                if (!child->children().empty()) {
                                        c->alist()->set_state (*child->children().front(), version);
 
@@ -1233,38 +1296,6 @@ PluginInsert::PluginControl::set_value (double user_val)
        AutomationControl::set_value (user_val);
 }
 
-double
-PluginInsert::PluginControl::internal_to_interface (double val) const
-{
-       val = Controllable::internal_to_interface(val);
-       
-       if (_desc.logarithmic) {
-               if (val > 0) {
-                       val = pow (val, 1/1.5);
-               } else {
-                       val = 0;
-               }
-       }
-
-       return val;
-}
-
-double
-PluginInsert::PluginControl::interface_to_internal (double val) const
-{
-       if (_desc.logarithmic) {
-               if (val <= 0) {
-                       val = 0;
-               } else {
-                       val = pow (val, 1.5);
-               }
-       }
-
-       val = Controllable::interface_to_internal(val);
-       
-       return val;
-}
-
 XMLNode&
 PluginInsert::PluginControl::get_state ()
 {