2 Copyright (C) 2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "evoral/ControlList.hpp"
21 #include "ardour/mute_master.h"
22 #include "ardour/session.h"
23 #include "ardour/mute_control.h"
27 using namespace ARDOUR;
31 MuteControl::MuteControl (Session& session, std::string const & name, Muteable& m)
32 : SlavableAutomationControl (session, MuteAutomation, ParameterDescriptor (MuteAutomation),
33 boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (MuteAutomation))),
37 _list->set_interpolation (Evoral::ControlList::Discrete);
38 /* mute changes must be synchronized by the process cycle */
39 set_flags (Controllable::Flag (flags() | Controllable::RealTime));
43 MuteControl::master_changed (bool from_self, PBD::Controllable::GroupControlDisposition gcd)
48 Glib::Threads::RWLock::ReaderLock lm (master_lock);
49 master_muted = (bool) get_masters_value_locked ();
52 _muteable.mute_master()->mod_muted_by_others (master_muted ? 1 : -1);
54 SlavableAutomationControl::master_changed (false, gcd);
58 MuteControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd)
60 if (muted() != bool (val)) {
61 _muteable.mute_master()->set_muted_by_self (val);
63 /* allow the Muteable to respond to the mute change
64 before anybody else knows about it.
66 _muteable.act_on_mute ();
69 AutomationControl::actually_set_value (val, gcd);
73 MuteControl::get_value () const
76 Glib::Threads::RWLock::ReaderLock lm (master_lock);
77 return get_masters_value_locked () ? 1.0 : 0.0;
80 if (_list && boost::dynamic_pointer_cast<AutomationList>(_list)->automation_playback()) {
81 // Playing back automation, get the value from the list
82 return AutomationControl::get_value();
85 return muted() ? 1.0 : 0.0;
89 MuteControl::set_mute_points (MuteMaster::MutePoint mp)
91 _muteable.mute_master()->set_mute_points (mp);
92 _muteable.mute_points_changed (); /* EMIT SIGNAL */
94 if (_muteable.mute_master()->muted_by_self()) {
95 Changed (true, Controllable::UseGroup); /* EMIT SIGNAL */
100 MuteControl::mute_points () const
102 return _muteable.mute_master()->mute_points ();
106 MuteControl::muted () const
108 return _muteable.mute_master()->muted_by_self();
112 MuteControl::muted_by_others () const
114 return _muteable.mute_master()->muted_by_others ();