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"
28 using namespace ARDOUR;
30 const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFader|
31 MuteMaster::PostFader|
35 MuteMaster::MuteMaster (Session& s, const std::string& name)
36 : AutomationControl (s, Evoral::Parameter (MuteAutomation), boost::shared_ptr<AutomationList>(), name)
37 , _mute_point (MutePoint (0))
39 // default range for parameter is fine
41 _automation = new AutomationList (MuteAutomation);
42 set_list (boost::shared_ptr<AutomationList>(_automation));
46 MuteMaster::clear_mute ()
48 if (_mute_point != MutePoint (0)) {
49 _mute_point = MutePoint (0);
50 MutePointChanged (); // EMIT SIGNAL
55 MuteMaster::mute_at (MutePoint mp)
57 if ((_mute_point & mp) != mp) {
58 _mute_point = MutePoint (_mute_point | mp);
59 MutePointChanged (); // EMIT SIGNAL
64 MuteMaster::unmute_at (MutePoint mp)
66 if ((_mute_point & mp) == mp) {
67 _mute_point = MutePoint (_mute_point & ~mp);
68 MutePointChanged (); // EMIT SIGNAL
73 MuteMaster::mute (bool yn)
75 /* convenience wrapper around AutomationControl method */
78 set_value ((float) 0xffff);
85 MuteMaster::mute_gain_at (MutePoint mp) const
87 if (_mute_point & mp) {
88 return Config->get_solo_mute_gain ();
95 MuteMaster::set_value (float f)
97 MutePoint old = _mute_point;
98 _mute_point = (MutePoint) (rint (f));
99 if (old != _mute_point) {
100 MutePointChanged (); // EMIT SIGNAL
105 MuteMaster::get_value () const
107 return (float) _mute_point;
111 MuteMaster::set_state (const XMLNode& node, int /*version*/)
113 const XMLProperty* prop;
115 if ((prop = node.property ("mute-point")) != 0) {
116 _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
123 MuteMaster::get_state()
125 XMLNode* node = new XMLNode (X_("MuteMaster"));
126 node->add_property ("mute-point", enum_2_string (_mute_point));