ardour
mute_master.cc
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2009 Paul Davis
4 
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.
9 
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.
14 
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.
18 
19 */
20 
21 #include "pbd/enumwriter.h"
22 #include "pbd/xml++.h"
23 #include "pbd/convert.h"
24 
25 #include "ardour/types.h"
26 #include "ardour/mute_master.h"
27 #include "ardour/session.h"
28 
29 #include "i18n.h"
30 
31 using namespace ARDOUR;
32 using namespace std;
33 
35  PreFader|PostFader|Listen|Main);
36 
37 MuteMaster::MuteMaster (Session& s, const std::string&)
38  : SessionHandleRef (s)
39  , _mute_point (MutePoint (0))
40  , _muted_by_self (false)
41  , _soloed (false)
42  , _solo_ignore (false)
43 {
44 
45  if (Config->get_mute_affects_pre_fader ()) {
47  }
48 
49  if (Config->get_mute_affects_post_fader ()) {
51  }
52 
53  if (Config->get_mute_affects_control_outs ()) {
55  }
56 
57  if (Config->get_mute_affects_main_outs ()) {
59  }
60 }
61 
62 void
64 {
65  if ((_mute_point & mp) != mp) {
67  MutePointChanged (); // EMIT SIGNAL
68  }
69 }
70 
71 void
73 {
74  if ((_mute_point & mp) == mp) {
76  MutePointChanged (); // EMIT SIGNAL
77  }
78 }
79 
80 void
82 {
83  _soloed = yn;
84 }
85 
86 gain_t
88 {
89  gain_t gain;
90 
91  if (Config->get_solo_mute_override()) {
92  if (_soloed) {
93  gain = GAIN_COEFF_UNITY;
94  } else if (muted_by_self_at (mp)) {
95  gain = GAIN_COEFF_ZERO;
96  } else {
97  if (muted_by_others_at (mp)) {
98  gain = Config->get_solo_mute_gain ();
99  } else {
100  gain = GAIN_COEFF_UNITY;
101  }
102  }
103  } else {
104  if (muted_by_self_at (mp)) {
105  gain = GAIN_COEFF_ZERO;
106  } else if (_soloed) {
107  gain = GAIN_COEFF_UNITY;
108  } else {
109  if (muted_by_others_at (mp)) {
110  gain = Config->get_solo_mute_gain ();
111  } else {
112  gain = GAIN_COEFF_UNITY;
113  }
114  }
115  }
116 
117  return gain;
118 }
119 
120 void
121 MuteMaster::set_mute_points (const std::string& mute_point)
122 {
123  MutePoint old = _mute_point;
124 
126 
127  if (old != _mute_point) {
128  MutePointChanged(); /* EMIT SIGNAL */
129  }
130 }
131 
132 void
134 {
135  if (_mute_point != mp) {
136  _mute_point = mp;
137  MutePointChanged (); /* EMIT SIGNAL */
138  }
139 }
140 
141 int
142 MuteMaster::set_state (const XMLNode& node, int /*version*/)
143 {
144  const XMLProperty* prop;
145 
146  if ((prop = node.property ("mute-point")) != 0) {
148  }
149 
150  if ((prop = node.property ("muted")) != 0) {
152  } else {
154  }
155 
156  return 0;
157 }
158 
159 XMLNode&
161 {
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")));
165  return *node;
166 }
167 
168 bool
170 {
171  return (!_solo_ignore && _session.soloing() && (_mute_point & mp));
172 }
173 
ARDOUR::Session & _session
bool soloing() const
Definition: session.h:691
void set_soloed(bool)
Definition: mute_master.cc:81
const std::string & value() const
Definition: xml++.h:159
#define enum_2_string(e)
Definition: enumwriter.h:97
mute all pre-fader sends
Definition: mute_master.h:39
PBD::Signal0< void > MutePointChanged
Definition: mute_master.h:68
static const MutePoint AllPoints
Definition: mute_master.h:45
volatile bool _solo_ignore
Definition: mute_master.h:77
Definition: Beats.hpp:239
volatile bool _soloed
Definition: mute_master.h:76
LIBARDOUR_API PBD::PropertyDescriptor< bool > gain
Definition: route_group.cc:44
float gain_t
Definition: types.h:58
XMLNode & get_state()
Definition: mute_master.cc:160
#define GAIN_COEFF_ZERO
Definition: dB.h:26
bool muted_by_others_at(MutePoint mp) const
Definition: mute_master.cc:169
#define X_(Text)
Definition: i18n.h:13
void unmute_at(MutePoint)
Definition: mute_master.cc:72
XMLProperty * property(const char *)
Definition: xml++.cc:413
int set_state(const XMLNode &, int version)
Definition: mute_master.cc:142
LIBARDOUR_API RCConfiguration * Config
Definition: globals.cc:119
#define string_2_enum(str, e)
Definition: enumwriter.h:98
bool string_is_affirmative(const std::string &str)
Definition: convert.cc:282
Definition: amp.h:29
bool muted_by_self_at(MutePoint mp) const
Definition: mute_master.h:51
mute all post-fader sends
Definition: mute_master.h:40
XMLProperty * add_property(const char *name, const std::string &value)
Definition: xml++.h:95
gain_t mute_gain_at(MutePoint) const
Definition: mute_master.cc:87
volatile bool _muted_by_self
Definition: mute_master.h:75
void set_mute_points(const std::string &mute_point)
Definition: mute_master.cc:121
#define GAIN_COEFF_UNITY
Definition: dB.h:28
volatile MutePoint _mute_point
Definition: mute_master.h:74
void mute_at(MutePoint)
Definition: mute_master.cc:63
mute listen out
Definition: mute_master.h:41
MuteMaster(Session &s, const std::string &name)
Definition: mute_master.cc:37