summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-05-04 20:22:50 +0200
committerRobin Gareus <robin@gareus.org>2015-05-04 20:35:23 +0200
commitfbea6c254268e9780afd22fbb191569df4120463 (patch)
treeac33fa3041a849e8da15723c46b773971ab183f6 /libs
parent54fe093371a7bdb880fe4157b3cd78f7e4bb87fe (diff)
API to reset plugin parameters to default
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/plugin_insert.h3
-rw-r--r--libs/ardour/plugin_insert.cc63
2 files changed, 66 insertions, 0 deletions
diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h
index dfc7c1415a..c1bf0f18e5 100644
--- a/libs/ardour/ardour/plugin_insert.h
+++ b/libs/ardour/ardour/plugin_insert.h
@@ -61,6 +61,9 @@ class LIBARDOUR_API PluginInsert : public Processor
void deactivate ();
void flush ();
+ bool reset_parameters_to_default ();
+ bool can_reset_all_parameters ();
+
int set_block_size (pframes_t nframes);
ChanCount output_streams() const;
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc
index 599a929dea..f6457453b8 100644
--- a/libs/ardour/plugin_insert.cc
+++ b/libs/ardour/plugin_insert.cc
@@ -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)
{