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 MuteMaster::MuteMaster (Session& s, const std::string&)
35 : SessionHandleRef (s)
36 , _mute_point (MutePoint (0))
37 , _muted_by_self (false)
39 , _solo_ignore (false)
42 if (Config->get_mute_affects_pre_fader ()) {
43 _mute_point = MutePoint (_mute_point | PreFader);
46 if (Config->get_mute_affects_post_fader ()) {
47 _mute_point = MutePoint (_mute_point | PostFader);
50 if (Config->get_mute_affects_control_outs ()) {
51 _mute_point = MutePoint (_mute_point | Listen);
54 if (Config->get_mute_affects_main_outs ()) {
55 _mute_point = MutePoint (_mute_point | Main);
60 MuteMaster::mute_at (MutePoint mp)
62 if ((_mute_point & mp) != mp) {
63 _mute_point = MutePoint (_mute_point | mp);
64 MutePointChanged (); // EMIT SIGNAL
69 MuteMaster::unmute_at (MutePoint mp)
71 if ((_mute_point & mp) == mp) {
72 _mute_point = MutePoint (_mute_point & ~mp);
73 MutePointChanged (); // EMIT SIGNAL
78 MuteMaster::set_soloed (bool yn)
84 MuteMaster::mute_gain_at (MutePoint mp) const
88 if (Config->get_solo_mute_override()) {
91 } else if (muted_by_self_at (mp)) {
94 if (muted_by_others_at (mp)) {
95 gain = Config->get_solo_mute_gain ();
101 if (muted_by_self_at (mp)) {
103 } else if (_soloed) {
106 if (muted_by_others_at (mp)) {
107 gain = Config->get_solo_mute_gain ();
118 MuteMaster::set_mute_points (const std::string& mute_point)
120 MutePoint old = _mute_point;
122 _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
124 if (old != _mute_point) {
125 MutePointChanged(); /* EMIT SIGNAL */
130 MuteMaster::set_mute_points (MutePoint mp)
132 if (_mute_point != mp) {
134 MutePointChanged (); /* EMIT SIGNAL */
139 MuteMaster::set_state (const XMLNode& node, int /*version*/)
141 const XMLProperty* prop;
143 if ((prop = node.property ("mute-point")) != 0) {
144 _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
147 if ((prop = node.property ("muted")) != 0) {
148 _muted_by_self = PBD::string_is_affirmative (prop->value());
150 _muted_by_self = (_mute_point != MutePoint (0));
157 MuteMaster::get_state()
159 XMLNode* node = new XMLNode (X_("MuteMaster"));
160 node->add_property ("mute-point", enum_2_string (_mute_point));
161 node->add_property ("muted", (_muted_by_self ? X_("yes") : X_("no")));
166 MuteMaster::muted_by_others_at (MutePoint mp) const
168 return (!_solo_ignore && _session.soloing() && (_mute_point & mp));