first vaguely working version using PresentationInfo
[ardour.git] / libs / ardour / ardour / stripable.h
1 /*
2   Copyright (C) 2016 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 __libardour_stripable_h__
21 #define __libardour_stripable_h__
22
23 #include <stdint.h>
24
25 #include <string>
26 #include <boost/utility.hpp>
27 #include <boost/shared_ptr.hpp>
28
29 #include "pbd/signals.h"
30
31 #include "ardour/presentation_info.h"
32 #include "ardour/session_object.h"
33 #include "ardour/libardour_visibility.h"
34
35 namespace ARDOUR {
36
37 class AutomationControl;
38 class GainControl;
39 class PeakMeter;
40 class SoloControl;
41 class MuteControl;
42 class PhaseControl;
43 class SoloIsolateControl;
44 class SoloSafeControl;
45 class MonitorControl;
46
47 /* This is a virtual base class for any object that needs to be potentially
48  * represented by a control-centric user interface using the general model of a
49  * mixing console "strip" - a collection of controls that determine the state
50  * and behaviour of the object.
51  */
52
53 class LIBARDOUR_API Stripable : public SessionObject {
54    public:
55         Stripable (Session& session, std::string const & name, PresentationInfo const &);
56         virtual ~Stripable () {}
57
58         /* XXX
59            midi on/off
60          */
61
62         bool is_auditioner() const { return _presentation_info.flags() & PresentationInfo::Auditioner; }
63         bool is_master() const { return _presentation_info.flags() & PresentationInfo::MasterOut; }
64         bool is_monitor() const { return _presentation_info.flags() & PresentationInfo::MonitorOut; }
65
66         int set_state (XMLNode const&, int);
67
68         bool is_hidden() const { return _presentation_info.flags() & PresentationInfo::Hidden; }
69         bool is_selected() const { return _presentation_info.flags() & PresentationInfo::Selected; }
70
71         PresentationInfo const & presentation_info () const { return _presentation_info; }
72         PresentationInfo& presentation_info () { return _presentation_info; }
73
74         /* set just the order */
75
76         void  set_presentation_group_order (PresentationInfo::order_t, bool notify_class_listeners = true);
77         void  set_presentation_group_order_explicit (PresentationInfo::order_t);
78
79         /* for things concerned about *this* route's RID */
80
81         PBD::Signal0<void> PresentationInfoChanged;
82
83         /* for things concerned about *any* route's RID changes */
84
85         static PBD::Signal0<void> PresentationInfoChange;
86
87         /***************************************************************
88          * Pure interface begins here
89          ***************************************************************/
90
91
92         virtual boost::shared_ptr<PeakMeter>       peak_meter() = 0;
93         virtual boost::shared_ptr<const PeakMeter> peak_meter() const = 0;
94
95         virtual boost::shared_ptr<GainControl> gain_control() const = 0;
96
97         virtual boost::shared_ptr<SoloControl> solo_control() const = 0;
98         virtual boost::shared_ptr<MuteControl> mute_control() const = 0;
99
100         virtual boost::shared_ptr<PhaseControl> phase_control() const = 0;
101         virtual boost::shared_ptr<GainControl> trim_control() const = 0;
102
103         virtual boost::shared_ptr<MonitorControl> monitoring_control() const = 0;
104         virtual boost::shared_ptr<AutomationControl> recenable_control() const { return boost::shared_ptr<AutomationControl>(); }
105
106         /* "well-known" controls for panning. Any or all of these may return
107          * null.
108          */
109
110         virtual boost::shared_ptr<AutomationControl> pan_azimuth_control() const = 0;
111         virtual boost::shared_ptr<AutomationControl> pan_elevation_control() const = 0;
112         virtual boost::shared_ptr<AutomationControl> pan_width_control() const = 0;
113         virtual boost::shared_ptr<AutomationControl> pan_frontback_control() const = 0;
114         virtual boost::shared_ptr<AutomationControl> pan_lfe_control() const = 0;
115
116         /* "well-known" controls for an EQ in this route. Any or all may
117          * be null. eq_band_cnt() must return 0 if there is no EQ present.
118          * Passing an @param band value >= eq_band_cnt() will guarantee the
119          * return of a null ptr (or an empty string for eq_band_name()).
120          */
121         virtual uint32_t eq_band_cnt () const = 0;
122         virtual std::string eq_band_name (uint32_t) const = 0;
123         virtual boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const = 0;
124         virtual boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const = 0;
125         virtual boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const = 0;
126         virtual boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const = 0;
127         virtual boost::shared_ptr<AutomationControl> eq_enable_controllable () const = 0;
128         virtual boost::shared_ptr<AutomationControl> eq_hpf_controllable () const = 0;
129
130         /* "well-known" controls for a compressor in this route. Any or all may
131          * be null.
132          */
133         virtual boost::shared_ptr<AutomationControl> comp_enable_controllable () const = 0;
134         virtual boost::shared_ptr<AutomationControl> comp_threshold_controllable () const = 0;
135         virtual boost::shared_ptr<AutomationControl> comp_speed_controllable () const = 0;
136         virtual boost::shared_ptr<AutomationControl> comp_mode_controllable () const = 0;
137         virtual boost::shared_ptr<AutomationControl> comp_makeup_controllable () const = 0;
138         virtual boost::shared_ptr<AutomationControl> comp_redux_controllable () const = 0;
139
140         /* @param mode must be supplied by the comp_mode_controllable(). All other values
141          * result in undefined behaviour
142          */
143         virtual std::string comp_mode_name (uint32_t mode) const = 0;
144         /* @param mode - as for comp mode name. This returns the name for the
145          * parameter/control accessed via comp_speed_controllable(), which can
146          * be mode dependent.
147          */
148         virtual std::string comp_speed_name (uint32_t mode) const = 0;
149
150         /* "well-known" controls for sends to well-known busses in this route. Any or all may
151          * be null.
152          *
153          * In Mixbus, these are the sends that connect to the mixbusses.
154          * In Ardour, these are user-created sends that connect to user-created
155          * Aux busses.
156          */
157         virtual boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const = 0;
158         virtual boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const = 0;
159         /* for the same value of @param n, this returns the name of the send
160          * associated with the pair of controllables returned by the above two methods.
161          */
162         virtual std::string send_name (uint32_t n) const = 0;
163
164         /* well known control that enables/disables sending to the master bus.
165          *
166          * In Ardour, this returns null.
167          * In Mixbus, it will return a suitable control, or null depending on
168          * the route.
169          */
170         virtual boost::shared_ptr<AutomationControl> master_send_enable_controllable () const = 0;
171
172         virtual bool muted_by_others_soloing () const = 0;
173
174    protected:
175         PresentationInfo _presentation_info;
176
177         /* set the entire info. This should only be used in cases where the
178          * derived could not supply the correct Flag and/or order information
179          * in its constructor.
180          */
181
182         void set_presentation_info (PresentationInfo id, bool notify_class_listeners = true);
183         void set_presentation_info_explicit (PresentationInfo);
184
185         void add_state (XMLNode&) const;
186
187   private:
188         void set_presentation_info_internal (PresentationInfo id, bool notify_class_listeners = true);
189 };
190
191 struct PresentationInfoSorter {
192         bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
193                 return a->presentation_info() < b->presentation_info();
194         }
195 };
196
197
198 }
199
200 #endif /* __libardour_stripable_h__ */