fix mute & solo behaviour mostly ; remove some verbose debugging output
[ardour.git] / libs / ardour / mute_master.cc
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 #include <iostream>
21
22 #include "ardour/mute_master.h"
23 #include "ardour/rc_configuration.h"
24
25 #include "i18n.h"
26
27 using namespace ARDOUR;
28
29 MuteMaster::MuteMaster (Session& s, const std::string& name)
30         : AutomationControl (s, Evoral::Parameter (MuteAutomation), boost::shared_ptr<AutomationList>(), name)
31         , _mute_point (MutePoint (0))
32 {
33         // default range for parameter is fine
34
35         _automation = new AutomationList (MuteAutomation);
36         set_list (boost::shared_ptr<AutomationList>(_automation));
37 }
38
39 void
40 MuteMaster::clear_mute ()
41 {
42         if (_mute_point != MutePoint (0)) {
43                 _mute_point = MutePoint (0);
44                 MutePointChanged (); // EMIT SIGNAL
45         }
46 }
47
48 void
49 MuteMaster::mute_at (MutePoint mp)
50 {
51         if ((_mute_point & mp) != mp) {
52                 _mute_point = MutePoint (_mute_point | mp);
53                 MutePointChanged (); // EMIT SIGNAL
54         }
55 }
56
57 void
58 MuteMaster::unmute_at (MutePoint mp)
59 {
60         if ((_mute_point & mp) == mp) {
61                 _mute_point = MutePoint (_mute_point & ~mp);
62                 MutePointChanged (); // EMIT SIGNAL
63         }
64 }
65
66 void
67 MuteMaster::mute (bool yn)
68 {
69         /* convenience wrapper around AutomationControl method */
70
71         if (yn) {
72                 set_value ((float) 0xffff);
73         } else {
74                 set_value (0.0f);
75         }
76 }
77
78 gain_t
79 MuteMaster::mute_gain_at (MutePoint mp) const
80 {
81         if (_mute_point & mp) {
82                 return Config->get_solo_mute_gain ();
83         } else {
84                 return 1.0;
85         }
86 }
87
88 void
89 MuteMaster::set_value (float f)
90 {
91         MutePoint old = _mute_point;
92         _mute_point = (MutePoint) (rint (f));
93         if (old != _mute_point) {
94                 MutePointChanged (); // EMIT SIGNAL
95         }
96 }
97
98 float
99 MuteMaster::get_value () const
100 {
101         return (float) _mute_point;
102 }
103
104 int
105 MuteMaster::set_state (const XMLNode& node)
106 {
107         return 0;
108 }
109
110 XMLNode&
111 MuteMaster::get_state()
112 {
113         return *(new XMLNode (X_("MuteMaster")));
114 }