Mute automation via normal mute button.
authorDavid Robillard <d@drobilla.net>
Thu, 18 Dec 2014 07:25:17 +0000 (02:25 -0500)
committerDavid Robillard <d@drobilla.net>
Thu, 18 Dec 2014 07:26:51 +0000 (02:26 -0500)
libs/ardour/ardour/route.h
libs/ardour/route.cc
libs/ardour/session_rtevents.cc
libs/evoral/evoral/Control.hpp

index 6dbdda496cefbb7590d2406fc7312518ec78079a..5d52fc0c52493e5436f87b34843bd520bdb01aa4 100644 (file)
@@ -394,15 +394,18 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
                void set_value (double);
                double get_value () const;
 
+               /* Pretend to change value, but do not affect actual route mute. */
+               void set_superficial_value(bool muted);
+
        private:
                boost::weak_ptr<Route> _route;
        };
 
-       boost::shared_ptr<AutomationControl> solo_control() const {
+       boost::shared_ptr<SoloControllable> solo_control() const {
                return _solo_control;
        }
 
-       boost::shared_ptr<AutomationControl> mute_control() const {
+       boost::shared_ptr<MuteControllable> mute_control() const {
                return _mute_control;
        }
 
index a93a6a1bf8b81488f525975c58c1e36bc293a571..b9acae45eb13ab804ed2d83bfd2014d49fe254a7 100644 (file)
@@ -3409,7 +3409,7 @@ Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<R
 void
 Route::SoloControllable::set_value (double val)
 {
-       bool bval = ((val >= 0.5f) ? true: false);
+       const bool bval = ((val >= 0.5) ? true : false);
 
        boost::shared_ptr<RouteList> rl (new RouteList);
 
@@ -3456,37 +3456,51 @@ Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr<R
 }
 
 void
-Route::MuteControllable::set_value (double val)
+Route::MuteControllable::set_superficial_value(bool muted)
 {
-       bool bval = ((val >= 0.5f) ? true: false);
+       /* Note we can not use AutomationControl::set_value here since it will emit
+          Changed(), but the value will not be correct to the observer. */
+
+       bool to_list = _list && ((AutomationList*)_list.get())->automation_write();
+
+       Control::set_double (muted, _session.transport_frame(), to_list);
+}
 
-       // boost::shared_ptr<RouteList> rl (new RouteList);
+void
+Route::MuteControllable::set_value (double val)
+{
+       const bool bval = ((val >= 0.5) ? true : false);
 
        boost::shared_ptr<Route> r = _route.lock ();
        if (!r) {
                return;
        }
 
-       /* I don't know why this apparently "should" be done via the RT event
-          system, but doing so causes a ton of annoying errors... */
-       // rl->push_back (r);
-       // _session.set_mute (rl, bval);
-
-       /* ... but this seems to work. */
-       r->set_mute (bval, this);
+       if (_list && ((AutomationList*)_list.get())->automation_playback()) {
+               // Playing back automation, set route mute directly
+               r->set_mute (bval, this);
+       } else {
+               // Set from user, queue mute event
+               boost::shared_ptr<RouteList> rl (new RouteList);
+               rl->push_back (r);
+               _session.set_mute (rl, bval, Session::rt_cleanup);
+       }
 
-       AutomationControl::set_value(bval);
+       // Set superficial/automation value to drive controller (and possibly record)
+       set_superficial_value(bval);
 }
 
 double
 Route::MuteControllable::get_value () const
 {
-       boost::shared_ptr<Route> r = _route.lock ();
-       if (!r) {
-               return 0;
+       if (_list && ((AutomationList*)_list.get())->automation_playback()) {
+               // Playing back automation, get the value from the list
+               return AutomationControl::get_value();
        }
 
-       return r->muted() ? 1.0f : 0.0f;
+       // Not playing back automation, get the actual route mute value
+       boost::shared_ptr<Route> r = _route.lock ();
+       return (r && r->muted()) ? 1.0 : 0.0;
 }
 
 void
index 6328607eec7dcc6148c5920e84a29783da7fdb40..4bd7c2da9a03ac27d45a31b15b856345a4d6ca5c 100644 (file)
@@ -143,6 +143,12 @@ Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_o
 void
 Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
 {
+       /* Set superficial value of mute controls for automation. */
+       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+               boost::shared_ptr<Route::MuteControllable> mc = (*i)->mute_control();
+               mc->set_superficial_value(yn);
+       }
+
        queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
 }
 
index d91c89bb744b63438e180796dd6f83b9bc02d201..490abf00b6f5341ae2e915043dac845177f00f1f 100644 (file)
@@ -50,7 +50,7 @@ public:
 
        virtual ~Control() {}
 
-        virtual void   set_double (double val, double frame=0, bool to_list=false);
+       virtual void   set_double (double val, double frame=0, bool to_list=false);
        virtual double get_double (bool from_list=false, double frame=0) const;
 
        /** Get the latest user-set value