3 Copyright (C) 2009 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "pbd/enumwriter.h"
22 #include "pbd/xml++.h"
23 #include "pbd/convert.h"
25 #include "ardour/types.h"
26 #include "ardour/mute_master.h"
27 #include "ardour/session.h"
31 using namespace ARDOUR;
34 const MuteMaster::MutePoint MuteMaster::AllPoints = MuteMaster::MutePoint(
35 PreFader|PostFader|Listen|Main);
37 MuteMaster::MuteMaster (Session& s, const std::string&)
38 : SessionHandleRef (s)
39 , _mute_point (MutePoint (0))
40 , _muted_by_self (false)
41 , _soloed_by_self (false)
42 , _soloed_by_others (false)
43 , _solo_ignore (false)
44 , _muted_by_others (0)
47 if (Config->get_mute_affects_pre_fader ()) {
48 _mute_point = MutePoint (_mute_point | PreFader);
51 if (Config->get_mute_affects_post_fader ()) {
52 _mute_point = MutePoint (_mute_point | PostFader);
55 if (Config->get_mute_affects_control_outs ()) {
56 _mute_point = MutePoint (_mute_point | Listen);
59 if (Config->get_mute_affects_main_outs ()) {
60 _mute_point = MutePoint (_mute_point | Main);
65 MuteMaster::mute_at (MutePoint mp)
67 if ((_mute_point & mp) != mp) {
68 _mute_point = MutePoint (_mute_point | mp);
69 MutePointChanged (); // EMIT SIGNAL
74 MuteMaster::unmute_at (MutePoint mp)
76 if ((_mute_point & mp) == mp) {
77 _mute_point = MutePoint (_mute_point & ~mp);
78 MutePointChanged (); // EMIT SIGNAL
83 MuteMaster::mute_gain_at (MutePoint mp) const
87 if (Config->get_solo_mute_override()) {
88 if (_soloed_by_self) {
89 gain = GAIN_COEFF_UNITY;
90 } else if (muted_by_self_at (mp)) {
91 gain = GAIN_COEFF_ZERO;
93 if (muted_by_others_at (mp) && !_soloed_by_others) {
94 gain = Config->get_solo_mute_gain ();
96 gain = GAIN_COEFF_UNITY;
100 if (muted_by_self_at (mp)) {
101 gain = GAIN_COEFF_ZERO;
102 } else if (_soloed_by_self || _soloed_by_others) {
103 gain = GAIN_COEFF_UNITY;
105 if (muted_by_others_at (mp)) {
106 gain = Config->get_solo_mute_gain ();
108 gain = GAIN_COEFF_UNITY;
117 MuteMaster::set_mute_points (const std::string& mute_point)
119 MutePoint old = _mute_point;
121 _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
123 if (old != _mute_point) {
124 MutePointChanged(); /* EMIT SIGNAL */
129 MuteMaster::set_mute_points (MutePoint mp)
131 if (_mute_point != mp) {
133 MutePointChanged (); /* EMIT SIGNAL */
138 MuteMaster::set_state (const XMLNode& node, int /*version*/)
140 XMLProperty const * prop;
142 if ((prop = node.property ("mute-point")) != 0) {
143 _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
146 if ((prop = node.property ("muted")) != 0) {
147 _muted_by_self = PBD::string_is_affirmative (prop->value());
149 _muted_by_self = (_mute_point != MutePoint (0));
156 MuteMaster::get_state()
158 XMLNode* node = new XMLNode (X_("MuteMaster"));
159 node->add_property ("mute-point", enum_2_string (_mute_point));
160 node->add_property ("muted", (_muted_by_self ? X_("yes") : X_("no")));
165 MuteMaster::muted_by_others_at (MutePoint mp) const
167 return (!_solo_ignore && (_muted_by_others || _session.soloing()) && (_mute_point & mp));
171 MuteMaster::mod_muted_by_others (int32_t delta)
173 _muted_by_others = max (0, _muted_by_others + delta);