Fix angle bracket project-local include paths.
[ardour2.git] / libs / ardour / mute_master.cc
blob224eccdd515b55dc2975f6136a7b8550234ac905
1 /*
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"
23 #include "ardour/mute_master.h"
24 #include "ardour/rc_configuration.h"
26 #include "i18n.h"
28 using namespace ARDOUR;
30 MuteMaster::MuteMaster (Session& s, const std::string& name)
31 : AutomationControl (s, Evoral::Parameter (MuteAutomation), boost::shared_ptr<AutomationList>(), name)
32 , _mute_point (MutePoint (0))
34 // default range for parameter is fine
36 _automation = new AutomationList (MuteAutomation);
37 set_list (boost::shared_ptr<AutomationList>(_automation));
40 void
41 MuteMaster::clear_mute ()
43 if (_mute_point != MutePoint (0)) {
44 _mute_point = MutePoint (0);
45 MutePointChanged (); // EMIT SIGNAL
49 void
50 MuteMaster::mute_at (MutePoint mp)
52 if ((_mute_point & mp) != mp) {
53 _mute_point = MutePoint (_mute_point | mp);
54 MutePointChanged (); // EMIT SIGNAL
58 void
59 MuteMaster::unmute_at (MutePoint mp)
61 if ((_mute_point & mp) == mp) {
62 _mute_point = MutePoint (_mute_point & ~mp);
63 MutePointChanged (); // EMIT SIGNAL
67 void
68 MuteMaster::mute (bool yn)
70 /* convenience wrapper around AutomationControl method */
72 if (yn) {
73 set_value ((float) 0xffff);
74 } else {
75 set_value (0.0f);
79 gain_t
80 MuteMaster::mute_gain_at (MutePoint mp) const
82 if (_mute_point & mp) {
83 return Config->get_solo_mute_gain ();
84 } else {
85 return 1.0;
89 void
90 MuteMaster::set_value (float f)
92 MutePoint old = _mute_point;
93 _mute_point = (MutePoint) (rint (f));
94 if (old != _mute_point) {
95 MutePointChanged (); // EMIT SIGNAL
99 float
100 MuteMaster::get_value () const
102 return (float) _mute_point;
106 MuteMaster::set_state (const XMLNode& node, int /*version*/)
108 const XMLProperty* prop;
110 if ((prop = node.property ("mute-point")) != 0) {
111 _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
114 return 0;
117 XMLNode&
118 MuteMaster::get_state()
120 XMLNode* node = new XMLNode (X_("MuteMaster"));
121 node->add_property ("mute-point", enum_2_string (_mute_point));
122 return *node;