Only show user-presets in favorite sidebar
[ardour.git] / libs / ardour / ardour / mute_control.h
1 /*
2     Copyright (C) 2016 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     for more details.
13
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_mute_control_h__
20 #define __ardour_mute_control_h__
21
22 #include <string>
23
24 #include <boost/shared_ptr.hpp>
25
26 #include "ardour/slavable_automation_control.h"
27
28 #include "ardour/mute_master.h"
29 #include "ardour/libardour_visibility.h"
30
31 namespace ARDOUR {
32
33 class Session;
34 class Muteable;
35
36 class LIBARDOUR_API MuteControl : public SlavableAutomationControl
37 {
38 public:
39         MuteControl (Session& session, std::string const& name, Muteable&);
40
41         double get_value () const;
42         double get_save_value() const { return muted_by_self(); }
43
44         /* Export additional API so that objects that only get access
45          * to a Controllable/AutomationControl can do more fine-grained
46          * operations with respect to mute. Obviously, they would need
47          * to dynamic_cast<MuteControl> first.
48          *
49          * Mute state is not representable by a single scalar value,
50          * so set_value() and get_value() is not enough.
51          *
52          * This means that the Controllable is technically
53          * asymmetric. It is possible to call ::set_value (0.0) to
54          * turn off mute, and then call ::get_value() and get a
55          * return of 1.0 because the control is affected by
56          * upstream/downstream or a master.
57          */
58
59         bool muted () const;
60         bool muted_by_self () const;
61         bool muted_by_masters () const;
62         bool muted_by_self_or_masters () const {
63                 return muted_by_self() || muted_by_masters ();
64         }
65
66         bool muted_by_others_soloing () const;
67
68         void set_mute_points (MuteMaster::MutePoint);
69         MuteMaster::MutePoint mute_points () const;
70
71         void automation_run (samplepos_t start, pframes_t nframes);
72
73 protected:
74         bool handle_master_change (boost::shared_ptr<AutomationControl>);
75         void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override);
76
77         void pre_remove_master (boost::shared_ptr<AutomationControl>);
78         void post_add_master (boost::shared_ptr<AutomationControl>);
79
80 private:
81         Muteable& _muteable;
82 };
83
84 } /* namespace */
85
86 #endif /* __libardour_mute_control_h__ */