2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "pbd/enumwriter.h"
21 #include "pbd/xml++.h"
22 #include "pbd/enum_convert.h"
24 #include "ardour/types.h"
25 #include "ardour/mute_master.h"
26 #include "ardour/session.h"
31 DEFINE_ENUM_CONVERT(ARDOUR::MuteMaster::MutePoint);
34 using namespace ARDOUR;
37 const string MuteMaster::xml_node_name (X_("MuteMaster"));
39 const MuteMaster::MutePoint MuteMaster::AllPoints = MuteMaster::MutePoint(
40 PreFader|PostFader|Listen|Main);
42 MuteMaster::MuteMaster (Session& s, Muteable& m, const std::string&)
43 : SessionHandleRef (s)
45 , _mute_point (MutePoint (0))
46 , _muted_by_self (false)
47 , _soloed_by_self (false)
48 , _soloed_by_others (false)
49 , _muted_by_masters (0)
52 if (Config->get_mute_affects_pre_fader ()) {
53 _mute_point = MutePoint (_mute_point | PreFader);
56 if (Config->get_mute_affects_post_fader ()) {
57 _mute_point = MutePoint (_mute_point | PostFader);
60 if (Config->get_mute_affects_control_outs ()) {
61 _mute_point = MutePoint (_mute_point | Listen);
64 if (Config->get_mute_affects_main_outs ()) {
65 _mute_point = MutePoint (_mute_point | Main);
70 MuteMaster::mute_at (MutePoint mp)
72 if ((_mute_point & mp) != mp) {
73 _mute_point = MutePoint (_mute_point | mp);
74 MutePointChanged (); // EMIT SIGNAL
79 MuteMaster::unmute_at (MutePoint mp)
81 if ((_mute_point & mp) == mp) {
82 _mute_point = MutePoint (_mute_point & ~mp);
83 MutePointChanged (); // EMIT SIGNAL
88 MuteMaster::mute_gain_at (MutePoint mp) const
92 if (Config->get_solo_mute_override()) {
93 if (_soloed_by_self) {
94 gain = GAIN_COEFF_UNITY;
95 } else if (muted_by_self_at (mp) || muted_by_masters_at (mp)) {
96 gain = GAIN_COEFF_ZERO;
98 if (!_soloed_by_others && muted_by_others_soloing_at (mp)) {
99 gain = Config->get_solo_mute_gain ();
101 gain = GAIN_COEFF_UNITY;
105 if (muted_by_self_at (mp) || muted_by_masters_at (mp)) {
106 gain = GAIN_COEFF_ZERO;
107 } else if (_soloed_by_self || _soloed_by_others) {
108 gain = GAIN_COEFF_UNITY;
110 if (muted_by_others_soloing_at (mp)) {
111 gain = Config->get_solo_mute_gain ();
113 gain = GAIN_COEFF_UNITY;
122 MuteMaster::set_mute_points (const std::string& mute_point)
124 MutePoint old = _mute_point;
126 _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
128 if (old != _mute_point) {
129 MutePointChanged(); /* EMIT SIGNAL */
134 MuteMaster::set_mute_points (MutePoint mp)
136 if (_mute_point != mp) {
138 MutePointChanged (); /* EMIT SIGNAL */
143 MuteMaster::set_state (const XMLNode& node, int /*version*/)
145 node.get_property ("mute-point", _mute_point);
147 if (!node.get_property ("muted", _muted_by_self)) {
148 _muted_by_self = (_mute_point != MutePoint (0));
155 MuteMaster::get_state()
157 XMLNode* node = new XMLNode (xml_node_name);
158 node->set_property ("mute-point", _mute_point);
159 node->set_property ("muted", _muted_by_self);
164 MuteMaster::muted_by_others_soloing_at (MutePoint mp) const
166 return _muteable->muted_by_others_soloing() && (_mute_point & mp);
170 MuteMaster::set_muted_by_masters (bool yn)
172 _muted_by_masters = yn;