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)
42 , _solo_ignore (false)
45 if (Config->get_mute_affects_pre_fader ()) {
46 _mute_point = MutePoint (_mute_point | PreFader);
49 if (Config->get_mute_affects_post_fader ()) {
50 _mute_point = MutePoint (_mute_point | PostFader);
53 if (Config->get_mute_affects_control_outs ()) {
54 _mute_point = MutePoint (_mute_point | Listen);
57 if (Config->get_mute_affects_main_outs ()) {
58 _mute_point = MutePoint (_mute_point | Main);
63 MuteMaster::mute_at (MutePoint mp)
65 if ((_mute_point & mp) != mp) {
66 _mute_point = MutePoint (_mute_point | mp);
67 MutePointChanged (); // EMIT SIGNAL
72 MuteMaster::unmute_at (MutePoint mp)
74 if ((_mute_point & mp) == mp) {
75 _mute_point = MutePoint (_mute_point & ~mp);
76 MutePointChanged (); // EMIT SIGNAL
81 MuteMaster::set_soloed (bool yn)
87 MuteMaster::mute_gain_at (MutePoint mp) const
91 if (Config->get_solo_mute_override()) {
93 gain = GAIN_COEFF_UNITY;
94 } else if (muted_by_self_at (mp)) {
95 gain = GAIN_COEFF_ZERO;
97 if (muted_by_others_at (mp)) {
98 gain = Config->get_solo_mute_gain ();
100 gain = GAIN_COEFF_UNITY;
104 if (muted_by_self_at (mp)) {
105 gain = GAIN_COEFF_ZERO;
106 } else if (_soloed) {
107 gain = GAIN_COEFF_UNITY;
109 if (muted_by_others_at (mp)) {
110 gain = Config->get_solo_mute_gain ();
112 gain = GAIN_COEFF_UNITY;
121 MuteMaster::set_mute_points (const std::string& mute_point)
123 MutePoint old = _mute_point;
125 _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
127 if (old != _mute_point) {
128 MutePointChanged(); /* EMIT SIGNAL */
133 MuteMaster::set_mute_points (MutePoint mp)
135 if (_mute_point != mp) {
137 MutePointChanged (); /* EMIT SIGNAL */
142 MuteMaster::set_state (const XMLNode& node, int /*version*/)
144 const XMLProperty* prop;
146 if ((prop = node.property ("mute-point")) != 0) {
147 _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
150 if ((prop = node.property ("muted")) != 0) {
151 _muted_by_self = PBD::string_is_affirmative (prop->value());
153 _muted_by_self = (_mute_point != MutePoint (0));
160 MuteMaster::get_state()
162 XMLNode* node = new XMLNode (X_("MuteMaster"));
163 node->add_property ("mute-point", enum_2_string (_mute_point));
164 node->add_property ("muted", (_muted_by_self ? X_("yes") : X_("no")));
169 MuteMaster::muted_by_others_at (MutePoint mp) const
171 return (!_solo_ignore && _session.soloing() && (_mute_point & mp));