From 598c3cc958a9ff90db68799adc2638b053219eef Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 28 Sep 2008 21:20:43 +0000 Subject: [PATCH] Fix shadowing problem with *Control::set_value. Fix nasty situation when setting value on a plugin automation control that's playing back. git-svn-id: svn://localhost/ardour2/branches/3.0@3823 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/automation_control.h | 6 ++++++ libs/ardour/ardour/parameter.h | 2 +- libs/ardour/automatable.cc | 2 +- libs/ardour/automation_control.cc | 6 ++---- libs/ardour/plugin_insert.cc | 12 +++++++++--- libs/evoral/evoral/Control.hpp | 6 +++--- libs/evoral/src/Control.cpp | 6 +++--- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 52fce1096c..7878077a98 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -68,7 +68,13 @@ public: return ((ARDOUR::AutomationList*)_list.get())->stop_touch(); } + /** Set the value and do the right thing based on automation state + * (e.g. record if necessary, etc.) + */ void set_value(float val); + + /** Get the current effective value based on automation state. + */ float get_value() const; protected: diff --git a/libs/ardour/ardour/parameter.h b/libs/ardour/ardour/parameter.h index 5ccbd4a6e3..edb157ed57 100644 --- a/libs/ardour/ardour/parameter.h +++ b/libs/ardour/ardour/parameter.h @@ -45,7 +45,7 @@ class Parameter : public Evoral::Parameter { public: Parameter(AutomationType type = NullAutomation, uint32_t id=0, uint8_t channel=0) - : Evoral::Parameter((uint32_t)type, id, channel) + : Evoral::Parameter((uint32_t)type, channel, id) { init_metadata(type); } diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index a54bad5f6f..ea14fa648b 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -361,7 +361,7 @@ Automatable::automation_snapshot (nframes_t now, bool force) boost::shared_ptr c = boost::dynamic_pointer_cast(i->second); if (c->automation_write()) { - c->list()->rt_add (now, i->second->user_value()); + c->list()->rt_add (now, i->second->user_float()); } } diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index afa14c3f98..769f111a23 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -41,13 +41,11 @@ AutomationControl::AutomationControl( } -/** Get the currently effective value (ie the one that corresponds to current output) - */ float AutomationControl::get_value() const { bool from_list = _list && ((AutomationList*)_list.get())->automation_playback(); - return Control::get_value(from_list, _session.transport_frame()); + return Control::get_float(from_list, _session.transport_frame()); } @@ -57,7 +55,7 @@ AutomationControl::set_value(float value) bool to_list = _list && _session.transport_stopped() && ((AutomationList*)_list.get())->automation_playback(); - Control::set_value(value, to_list, _session.transport_frame()); + Control::set_float(value, to_list, _session.transport_frame()); Changed(); /* EMIT SIGNAL */ } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index fde0281ed1..e9956836b5 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -368,9 +368,15 @@ PluginInsert::set_parameter (Parameter param, float val) _plugins[0]->set_parameter (param.id(), val); - boost::shared_ptr c = data().control (param); - if (c) - c->set_value(val); + boost::shared_ptr ac + = boost::dynamic_pointer_cast(data().control(param)); + + if (ac) { + ac->set_value(val); + } else { + warning << "set_parameter called for nonexistant parameter " + << param.symbol() << endmsg; + } _session.set_dirty(); } diff --git a/libs/evoral/evoral/Control.hpp b/libs/evoral/evoral/Control.hpp index 01dc2eebed..173356b60f 100644 --- a/libs/evoral/evoral/Control.hpp +++ b/libs/evoral/evoral/Control.hpp @@ -37,9 +37,9 @@ public: Control(const Parameter& parameter, boost::shared_ptr); virtual ~Control() {} - void set_value(float val, bool to_list=false, nframes_t frame=0); - float get_value(bool from_list=false, nframes_t frame=0) const; - float user_value() const; + virtual void set_float(float val, bool to_list=false, nframes_t frame=0); + virtual float get_float(bool from_list=false, nframes_t frame=0) const; + virtual float user_float() const; void set_list(boost::shared_ptr); diff --git a/libs/evoral/src/Control.cpp b/libs/evoral/src/Control.cpp index 75b038f1d4..e5301b833c 100644 --- a/libs/evoral/src/Control.cpp +++ b/libs/evoral/src/Control.cpp @@ -35,7 +35,7 @@ Control::Control(const Parameter& parameter, boost::shared_ptr list /** Get the currently effective value (ie the one that corresponds to current output) */ float -Control::get_value(bool from_list, nframes_t frame) const +Control::get_float(bool from_list, nframes_t frame) const { if (from_list) return _list->eval(frame); @@ -45,7 +45,7 @@ Control::get_value(bool from_list, nframes_t frame) const void -Control::set_value(float value, bool to_list, nframes_t frame) +Control::set_float(float value, bool to_list, nframes_t frame) { _user_value = value; @@ -61,7 +61,7 @@ Control::set_value(float value, bool to_list, nframes_t frame) * to the AutomationList. */ float -Control::user_value() const +Control::user_float() const { return _user_value; }