rearrange inheritance so that Automatable IS-A Slavable
[ardour.git] / libs / ardour / ardour / vca.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_vca_h__
20 #define __ardour_vca_h__
21
22 #include <string>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/enable_shared_from_this.hpp>
25
26 #include "pbd/controllable.h"
27 #include "pbd/statefuldestructible.h"
28
29 #include "ardour/automatable.h"
30 #include "ardour/muteable.h"
31 #include "ardour/monitorable.h"
32 #include "ardour/recordable.h"
33 #include "ardour/soloable.h"
34 #include "ardour/slavable.h"
35 #include "ardour/stripable.h"
36
37 namespace ARDOUR {
38
39 class Route;
40 class GainControl;
41 class SoloControl;
42 class MuteControl;
43 class MonitorControl;
44
45 class LIBARDOUR_API VCA : public Stripable,
46                           public Soloable,
47                           public Muteable,
48                           public Automatable,
49                           public Recordable,
50                           public Monitorable,
51                           public boost::enable_shared_from_this<VCA> {
52   public:
53         VCA (Session& session,  uint32_t num, const std::string& name);
54         ~VCA();
55
56         uint32_t number () const { return _number; }
57         uint32_t remote_control_id() const;
58
59         int init ();
60         XMLNode& get_state();
61         int set_state (XMLNode const&, int version);
62
63         /* Soloable API */
64
65         void clear_all_solo_state ();
66
67         bool soloed () const;
68         void push_solo_upstream (int32_t) {}
69         void push_solo_isolate_upstream (int32_t) {}
70         bool can_solo() const { return true; }
71         bool is_safe () const { return false; }
72
73         /* Muteable API */
74
75         bool can_be_muted_by_others () const { return true; }
76         bool muted_by_others_soloing() const { return false; }
77
78         /* Recordable API */
79
80         int prep_record_enabled (bool yn) { return 0; }
81         bool can_be_record_enabled() { return true; }
82         bool can_be_record_safe() { return true; }
83
84         /* Monitorable API */
85
86         MonitorState monitoring_state() const;
87
88         static std::string default_name_template ();
89         static int next_vca_number ();
90         static std::string xml_node_name;
91
92         /* used by Session to save/restore the atomic counter */
93         static uint32_t get_next_vca_number ();
94         static void set_next_vca_number (uint32_t);
95
96         virtual boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
97         virtual boost::shared_ptr<SoloControl> solo_control() const { return _solo_control; }
98         virtual boost::shared_ptr<MuteControl> mute_control() const { return _mute_control; }
99         virtual boost::shared_ptr<AutomationControl> recenable_control() const { return _recenable_control; }
100         virtual boost::shared_ptr<MonitorControl>    monitoring_control() const { return _monitor_control; }
101
102         /* null Stripable API, because VCAs don't have any of this */
103
104         virtual boost::shared_ptr<PeakMeter>         peak_meter() { return boost::shared_ptr<PeakMeter>(); }
105         virtual boost::shared_ptr<const PeakMeter>   peak_meter() const { return boost::shared_ptr<PeakMeter>(); }
106         virtual boost::shared_ptr<PhaseControl>      phase_control() const { return boost::shared_ptr<PhaseControl>(); }
107         virtual boost::shared_ptr<GainControl>       trim_control() const { return boost::shared_ptr<GainControl>(); }
108         virtual boost::shared_ptr<AutomationControl> pan_azimuth_control() const { return boost::shared_ptr<AutomationControl>(); }
109         virtual boost::shared_ptr<AutomationControl> pan_elevation_control() const { return boost::shared_ptr<AutomationControl>(); }
110         virtual boost::shared_ptr<AutomationControl> pan_width_control() const { return boost::shared_ptr<AutomationControl>(); }
111         virtual boost::shared_ptr<AutomationControl> pan_frontback_control() const { return boost::shared_ptr<AutomationControl>(); }
112         virtual boost::shared_ptr<AutomationControl> pan_lfe_control() const { return boost::shared_ptr<AutomationControl>(); }
113         virtual uint32_t eq_band_cnt () const { return 0; }
114         virtual std::string eq_band_name (uint32_t) const { return std::string(); }
115         virtual boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
116         virtual boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
117         virtual boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
118         virtual boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
119         virtual boost::shared_ptr<AutomationControl> eq_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
120         virtual boost::shared_ptr<AutomationControl> eq_hpf_controllable () const { return boost::shared_ptr<AutomationControl>(); }
121         virtual boost::shared_ptr<AutomationControl> comp_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
122         virtual boost::shared_ptr<AutomationControl> comp_threshold_controllable () const { return boost::shared_ptr<AutomationControl>(); }
123         virtual boost::shared_ptr<AutomationControl> comp_speed_controllable () const { return boost::shared_ptr<AutomationControl>(); }
124         virtual boost::shared_ptr<AutomationControl> comp_mode_controllable () const { return boost::shared_ptr<AutomationControl>(); }
125         virtual boost::shared_ptr<AutomationControl> comp_makeup_controllable () const { return boost::shared_ptr<AutomationControl>(); }
126         virtual boost::shared_ptr<AutomationControl> comp_redux_controllable () const { return boost::shared_ptr<AutomationControl>(); }
127         virtual std::string comp_mode_name (uint32_t mode) const { return std::string(); }
128         virtual std::string comp_speed_name (uint32_t mode) const { return std::string(); }
129         virtual boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
130         virtual boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
131         virtual std::string send_name (uint32_t n) const { return std::string(); }
132         virtual boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
133
134   private:
135         uint32_t    _number;
136
137         boost::shared_ptr<GainControl> _gain_control;
138         boost::shared_ptr<SoloControl> _solo_control;
139         boost::shared_ptr<MuteControl> _mute_control;
140         boost::shared_ptr<AutomationControl> _recenable_control;
141         // boost::shared_ptr<AutomationControl> _record_safe_control;
142         boost::shared_ptr<MonitorControl> _monitor_control;
143
144         static gint next_number;
145
146         void solo_target_going_away (boost::weak_ptr<Route>);
147         void mute_target_going_away (boost::weak_ptr<Route>);
148         bool soloed_locked () const;
149         bool muted_locked () const;
150 };
151
152 } /* namespace */
153
154 #endif /* __ardour_vca_h__ */