Fix shadowing problem with *Control::set_value.
authorDavid Robillard <d@drobilla.net>
Sun, 28 Sep 2008 21:20:43 +0000 (21:20 +0000)
committerDavid Robillard <d@drobilla.net>
Sun, 28 Sep 2008 21:20:43 +0000 (21:20 +0000)
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
libs/ardour/ardour/parameter.h
libs/ardour/automatable.cc
libs/ardour/automation_control.cc
libs/ardour/plugin_insert.cc
libs/evoral/evoral/Control.hpp
libs/evoral/src/Control.cpp

index 52fce1096cb19b84afec58871e6e114a211aea39..7878077a98348da392382873b9bf34aea96e2f46 100644 (file)
@@ -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:
index 5ccbd4a6e3850d9d319d10eb3c4be99ba3fee74d..edb157ed57907b73a2b3a06fa52e30a37147256b 100644 (file)
@@ -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);
        }
index a54bad5f6fba2d32413daf0283200591db69860f..ea14fa648bdd9b628bdcb699928631e252459286 100644 (file)
@@ -361,7 +361,7 @@ Automatable::automation_snapshot (nframes_t now, bool force)
                        boost::shared_ptr<AutomationControl> c
                                        = boost::dynamic_pointer_cast<AutomationControl>(i->second);
                        if (c->automation_write()) {
-                               c->list()->rt_add (now, i->second->user_value());
+                               c->list()->rt_add (now, i->second->user_float());
                        }
                }
                
index afa14c3f98ec937237dfef08832f4d5684bad343..769f111a235505ab26a2cd40acc404b692fdc168 100644 (file)
@@ -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 */
 }
index fde0281ed13fbe3df52fb1072c735fbb798b38ec..e9956836b51630f2a6659a8ac1b546b87ba17cfe 100644 (file)
@@ -368,9 +368,15 @@ PluginInsert::set_parameter (Parameter param, float val)
 
        _plugins[0]->set_parameter (param.id(), val);
        
-       boost::shared_ptr<Evoral::Control> c = data().control (param);
-       if (c)
-               c->set_value(val);
+       boost::shared_ptr<AutomationControl> ac
+                       = boost::dynamic_pointer_cast<AutomationControl>(data().control(param));
+       
+       if (ac) {
+               ac->set_value(val);
+       } else {
+               warning << "set_parameter called for nonexistant parameter "
+                       << param.symbol() << endmsg;
+       }
 
        _session.set_dirty();
 }
index 01dc2eebed2aaba3b39eebc4b76e12c77d6decb3..173356b60fa6bfed3b3b6a27297ad7edb5899e57 100644 (file)
@@ -37,9 +37,9 @@ public:
        Control(const Parameter& parameter, boost::shared_ptr<ControlList>);
        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<ControlList>);
 
index 75b038f1d41325bcf04dc759c641891422aef851..e5301b833c838414b265abafb3968047ea98205b 100644 (file)
@@ -35,7 +35,7 @@ Control::Control(const Parameter& parameter, boost::shared_ptr<ControlList> 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;
 }