4ddb7075dab00aed9ccda6098860c1bd790a0477
[ardour.git] / libs / ardour / ardour / mute_master.h
1 /*
2     Copyright (C) 2009 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_mute_master_h__
21 #define __ardour_mute_master_h__
22
23 #include "evoral/Parameter.hpp"
24 #include "pbd/signals.h"
25 #include "pbd/stateful.h"
26 #include <string>
27
28 namespace ARDOUR {
29
30 class Session;
31
32 class MuteMaster : public PBD::Stateful
33 {
34   public:
35         enum MutePoint {
36                 PreFader  = 0x1,
37                 PostFader = 0x2,
38                 Listen    = 0x4,
39                 Main      = 0x8
40         };
41
42         static const MutePoint AllPoints;
43
44         MuteMaster (Session& s, const std::string& name);
45         ~MuteMaster() {}
46
47         bool self_muted() const { return _self_muted && (_mute_point != MutePoint (0)); }
48         bool muted_by_others() const { return _muted_by_others && (_mute_point != MutePoint (0)); }
49         bool muted() const { return (_self_muted || (_muted_by_others > 0)) && (_mute_point != MutePoint (0)); }
50         bool muted_at (MutePoint mp) const { return (_self_muted || (_muted_by_others > 0)) && (_mute_point & mp); }
51         bool self_muted_at (MutePoint mp) const { return _self_muted && (_mute_point & mp); }
52         bool muted_by_others_at (MutePoint mp) const { return (_muted_by_others > 0) && (_mute_point & mp); }
53
54         bool muted_pre_fader() const  { return muted_at (PreFader); }
55         bool muted_post_fader() const { return muted_at (PostFader); }
56         bool muted_listen() const     { return muted_at (Listen); }
57         bool muted_main () const      { return muted_at (Main); }
58
59         gain_t mute_gain_at (MutePoint) const;
60
61         void set_self_muted (bool yn) { _self_muted = yn; }
62         void mod_muted_by_others (int delta);
63         void clear_muted_by_others ();
64
65         void mute_at (MutePoint);
66         void unmute_at (MutePoint);
67
68         void set_mute_points (const std::string& mute_point);
69         void set_mute_points (MutePoint);
70         MutePoint mute_points() const { return _mute_point; }
71
72         void set_solo_level (int32_t);
73
74         PBD::Signal0<void> MutePointChanged;
75
76         XMLNode& get_state();
77         int set_state(const XMLNode&, int version);
78
79   private:
80         volatile MutePoint _mute_point;
81         volatile bool      _self_muted;
82         volatile uint32_t  _muted_by_others;
83         volatile int32_t   _solo_level;
84 };
85
86 } // namespace ARDOUR
87
88 #endif /*__ardour_mute_master_h__ */