Mute automation via normal mute button.

This commit is contained in:
David Robillard 2014-12-18 02:25:17 -05:00
parent d36b5c78bd
commit e584ae0bf9
4 changed files with 42 additions and 19 deletions

View file

@ -394,15 +394,18 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
void set_value (double); void set_value (double);
double get_value () const; double get_value () const;
/* Pretend to change value, but do not affect actual route mute. */
void set_superficial_value(bool muted);
private: private:
boost::weak_ptr<Route> _route; boost::weak_ptr<Route> _route;
}; };
boost::shared_ptr<AutomationControl> solo_control() const { boost::shared_ptr<SoloControllable> solo_control() const {
return _solo_control; return _solo_control;
} }
boost::shared_ptr<AutomationControl> mute_control() const { boost::shared_ptr<MuteControllable> mute_control() const {
return _mute_control; return _mute_control;
} }

View file

@ -3409,7 +3409,7 @@ Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<R
void void
Route::SoloControllable::set_value (double val) 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); boost::shared_ptr<RouteList> rl (new RouteList);
@ -3455,38 +3455,52 @@ Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr<R
set_list (gl); set_list (gl);
} }
void
Route::MuteControllable::set_superficial_value(bool muted)
{
/* 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);
}
void void
Route::MuteControllable::set_value (double val) Route::MuteControllable::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);
boost::shared_ptr<Route> r = _route.lock (); boost::shared_ptr<Route> r = _route.lock ();
if (!r) { if (!r) {
return; return;
} }
/* I don't know why this apparently "should" be done via the RT event if (_list && ((AutomationList*)_list.get())->automation_playback()) {
system, but doing so causes a ton of annoying errors... */ // Playing back automation, set route mute directly
// rl->push_back (r);
// _session.set_mute (rl, bval);
/* ... but this seems to work. */
r->set_mute (bval, this); 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 double
Route::MuteControllable::get_value () const Route::MuteControllable::get_value () const
{ {
boost::shared_ptr<Route> r = _route.lock (); if (_list && ((AutomationList*)_list.get())->automation_playback()) {
if (!r) { // Playing back automation, get the value from the list
return 0; 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 void

View file

@ -143,6 +143,12 @@ Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_o
void void
Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override) 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)); queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
} }