2 * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2015 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "pbd/enumwriter.h"
23 #include "pbd/xml++.h"
24 #include "pbd/enum_convert.h"
26 #include "ardour/types.h"
27 #include "ardour/mute_master.h"
28 #include "ardour/session.h"
33 DEFINE_ENUM_CONVERT(ARDOUR::MuteMaster::MutePoint);
36 using namespace ARDOUR;
39 const string MuteMaster::xml_node_name (X_("MuteMaster"));
41 const MuteMaster::MutePoint MuteMaster::AllPoints = MuteMaster::MutePoint(
42 PreFader|PostFader|Listen|Main);
44 MuteMaster::MuteMaster (Session& s, Muteable& m, const std::string&)
45 : SessionHandleRef (s)
47 , _mute_point (MutePoint (0))
48 , _muted_by_self (false)
49 , _soloed_by_self (false)
50 , _soloed_by_others (false)
51 , _muted_by_masters (0)
54 if (Config->get_mute_affects_pre_fader ()) {
55 _mute_point = MutePoint (_mute_point | PreFader);
58 if (Config->get_mute_affects_post_fader ()) {
59 _mute_point = MutePoint (_mute_point | PostFader);
62 if (Config->get_mute_affects_control_outs ()) {
63 _mute_point = MutePoint (_mute_point | Listen);
66 if (Config->get_mute_affects_main_outs ()) {
67 _mute_point = MutePoint (_mute_point | Main);
72 MuteMaster::mute_at (MutePoint mp)
74 if ((_mute_point & mp) != mp) {
75 _mute_point = MutePoint (_mute_point | mp);
76 MutePointChanged (); // EMIT SIGNAL
81 MuteMaster::unmute_at (MutePoint mp)
83 if ((_mute_point & mp) == mp) {
84 _mute_point = MutePoint (_mute_point & ~mp);
85 MutePointChanged (); // EMIT SIGNAL
90 MuteMaster::mute_gain_at (MutePoint mp) const
94 if (Config->get_solo_mute_override()) {
95 if (_soloed_by_self) {
96 gain = GAIN_COEFF_UNITY;
97 } else if (muted_by_self_at (mp) || muted_by_masters_at (mp)) {
98 gain = GAIN_COEFF_ZERO;
100 if (!_soloed_by_others && muted_by_others_soloing_at (mp)) {
101 gain = Config->get_solo_mute_gain ();
103 gain = GAIN_COEFF_UNITY;
107 if (muted_by_self_at (mp) || muted_by_masters_at (mp)) {
108 gain = GAIN_COEFF_ZERO;
109 } else if (_soloed_by_self || _soloed_by_others) {
110 gain = GAIN_COEFF_UNITY;
112 if (muted_by_others_soloing_at (mp)) {
113 gain = Config->get_solo_mute_gain ();
115 gain = GAIN_COEFF_UNITY;
124 MuteMaster::set_mute_points (const std::string& mute_point)
126 MutePoint old = _mute_point;
128 _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
130 if (old != _mute_point) {
131 MutePointChanged(); /* EMIT SIGNAL */
136 MuteMaster::set_mute_points (MutePoint mp)
138 if (_mute_point != mp) {
140 MutePointChanged (); /* EMIT SIGNAL */
145 MuteMaster::set_state (const XMLNode& node, int /*version*/)
147 node.get_property ("mute-point", _mute_point);
149 if (!node.get_property ("muted", _muted_by_self)) {
150 _muted_by_self = (_mute_point != MutePoint (0));
157 MuteMaster::get_state()
159 XMLNode* node = new XMLNode (xml_node_name);
160 node->set_property ("mute-point", _mute_point);
161 node->set_property ("muted", _muted_by_self);
166 MuteMaster::muted_by_others_soloing_at (MutePoint mp) const
168 return _muteable->muted_by_others_soloing() && (_mute_point & mp);
172 MuteMaster::set_muted_by_masters (bool yn)
174 _muted_by_masters = yn;