diff --git a/libs/ardour/ardour/io_plug.h b/libs/ardour/ardour/io_plug.h index 4cb44cc13d..a4a2da63dc 100644 --- a/libs/ardour/ardour/io_plug.h +++ b/libs/ardour/ardour/io_plug.h @@ -88,8 +88,8 @@ public: std::shared_ptr control_output (uint32_t) const; - bool reset_parameters_to_default () { return false;} - bool can_reset_all_parameters () { return false; } + bool reset_parameters_to_default (); + bool can_reset_all_parameters (); virtual bool provides_stats () const { return true; } virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const; diff --git a/libs/ardour/io_plug.cc b/libs/ardour/io_plug.cc index 46896b8c5d..bfa7957a19 100644 --- a/libs/ardour/io_plug.cc +++ b/libs/ardour/io_plug.cc @@ -598,6 +598,56 @@ IOPlug::direct_feeds_according_to_reality (std::shared_ptr node, bool /* ****************************************************************************/ +bool +IOPlug::can_reset_all_parameters () +{ + bool all = true; + uint32_t params = 0; + for (uint32_t par = 0; par < _plugin->parameter_count(); ++par) { + bool ok=false; + const uint32_t cid = _plugin->nth_parameter (par, ok); + + if (!ok || !_plugin->parameter_is_input(cid)) { + continue; + } + + ++params; + } + return all && (params > 0); +} + +bool +IOPlug::reset_parameters_to_default () +{ + bool all = true; + + for (uint32_t par = 0; par < _plugin->parameter_count(); ++par) { + bool ok=false; + const uint32_t cid = _plugin->nth_parameter (par, ok); + + if (!ok || !_plugin->parameter_is_input(cid)) { + continue; + } + + const float dflt = _plugin->default_value (cid); + const float curr = _plugin->get_parameter (cid); + + if (dflt == curr) { + continue; + } + + std::shared_ptr ac = std::dynamic_pointer_cast(control (Evoral::Parameter(PluginAutomation, 0, cid))); + if (!ac) { + continue; + } + + ac->set_value (dflt, Controllable::NoGroup); + } + return all; +} + +/* ****************************************************************************/ + IOPlug::PluginControl::PluginControl (IOPlug* p, Evoral::Parameter const& param, ParameterDescriptor const& desc)