From e584ae0bf94673bf719e661c49e8a2f2d2dd0346 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Dec 2014 02:25:17 -0500 Subject: Mute automation via normal mute button. --- libs/ardour/ardour/route.h | 7 +++++-- libs/ardour/route.cc | 46 +++++++++++++++++++++++++++-------------- libs/ardour/session_rtevents.cc | 6 ++++++ 3 files changed, 41 insertions(+), 18 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 6dbdda496c..5d52fc0c52 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -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; }; - boost::shared_ptr solo_control() const { + boost::shared_ptr solo_control() const { return _solo_control; } - boost::shared_ptr mute_control() const { + boost::shared_ptr mute_control() const { return _mute_control; } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a93a6a1bf8..b9acae45eb 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3409,7 +3409,7 @@ Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr= 0.5f) ? true: false); + const bool bval = ((val >= 0.5) ? true : false); boost::shared_ptr rl (new RouteList); @@ -3456,37 +3456,51 @@ Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr= 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 rl (new RouteList); +void +Route::MuteControllable::set_value (double val) +{ + const bool bval = ((val >= 0.5) ? true : false); boost::shared_ptr 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 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 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 r = _route.lock (); + return (r && r->muted()) ? 1.0 : 0.0; } void diff --git a/libs/ardour/session_rtevents.cc b/libs/ardour/session_rtevents.cc index 6328607eec..4bd7c2da9a 100644 --- a/libs/ardour/session_rtevents.cc +++ b/libs/ardour/session_rtevents.cc @@ -143,6 +143,12 @@ Session::rt_set_listen (boost::shared_ptr rl, bool yn, bool /*group_o void Session::set_mute (boost::shared_ptr 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 mc = (*i)->mute_control(); + mc->set_superficial_value(yn); + } + queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute)); } -- cgit v1.2.3