2 Copyright (C) 2010 Paul Davis
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.
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.
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.
20 #ifndef __ardour_monitor_processor_h__
21 #define __ardour_monitor_processor_h__
26 #include "pbd/signals.h"
27 #include "pbd/compose.h"
28 #include "pbd/controllable.h"
30 #include "ardour/types.h"
31 #include "ardour/processor.h"
39 template<typename T> class MPControl : public PBD::Controllable {
41 MPControl (T initial, const std::string& name, PBD::Controllable::Flag flag,
42 float lower = 0.0f, float upper = 1.0f)
43 : PBD::Controllable (name, flag)
49 /* Controllable API */
51 void set_value (double v) {
53 if (newval != _value) {
55 Changed(); /* EMIT SIGNAL */
59 double get_value () const {
60 return (float) _value;
63 double lower () const { return _lower; }
64 double upper () const { return _upper; }
66 /* "access as T" API */
68 MPControl& operator=(const T& v) {
71 Changed (); /* EMIT SIGNAL */
76 bool operator==(const T& v) const {
80 bool operator<(const T& v) const {
84 bool operator<=(const T& v) const {
88 bool operator>(const T& v) const {
92 bool operator>=(const T& v) const {
96 operator T() const { return _value; }
97 T val() const { return _value; }
105 class MonitorProcessor : public Processor
108 MonitorProcessor (Session&);
109 ~MonitorProcessor ();
111 bool display_to_user() const;
113 void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t /*nframes*/, bool /*result_required*/);
115 XMLNode& state (bool full);
116 int set_state (const XMLNode&, int /* version */);
118 bool configure_io (ChanCount in, ChanCount out);
119 bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
121 void set_cut_all (bool);
122 void set_dim_all (bool);
123 void set_polarity (uint32_t, bool invert);
124 void set_cut (uint32_t, bool cut);
125 void set_dim (uint32_t, bool dim);
126 void set_solo (uint32_t, bool);
127 void set_mono (bool);
129 gain_t dim_level() const { return _dim_level; }
130 gain_t solo_boost_level() const { return _solo_boost_level; }
132 bool dimmed (uint32_t chn) const;
133 bool soloed (uint32_t chn) const;
134 bool inverted (uint32_t chn) const;
135 bool cut (uint32_t chn) const;
136 bool cut_all () const;
137 bool dim_all () const;
140 PBD::Signal0<void> Changed;
142 boost::shared_ptr<PBD::Controllable> channel_cut_control (uint32_t) const;
143 boost::shared_ptr<PBD::Controllable> channel_dim_control (uint32_t) const;
144 boost::shared_ptr<PBD::Controllable> channel_polarity_control (uint32_t) const;
145 boost::shared_ptr<PBD::Controllable> channel_solo_control (uint32_t) const;
147 boost::shared_ptr<PBD::Controllable> dim_control () const { return _dim_all_control; }
148 boost::shared_ptr<PBD::Controllable> cut_control () const { return _cut_all_control; }
149 boost::shared_ptr<PBD::Controllable> mono_control () const { return _mono_control; }
150 boost::shared_ptr<PBD::Controllable> dim_level_control () const { return _dim_level_control; }
151 boost::shared_ptr<PBD::Controllable> solo_boost_control () const { return _solo_boost_level_control; }
154 struct ChannelRecord {
157 /* pointers - created first, but managed by boost::shared_ptr<> */
159 MPControl<gain_t>* cut_ptr;
160 MPControl<bool>* dim_ptr;
161 MPControl<gain_t>* polarity_ptr;
162 MPControl<bool>* soloed_ptr;
164 /* shared ptr access and lifetime management, for external users */
166 boost::shared_ptr<PBD::Controllable> cut_control;
167 boost::shared_ptr<PBD::Controllable> dim_control;
168 boost::shared_ptr<PBD::Controllable> polarity_control;
169 boost::shared_ptr<PBD::Controllable> soloed_control;
171 /* typed controllables for internal use */
173 MPControl<gain_t>& cut;
174 MPControl<bool>& dim;
175 MPControl<gain_t>& polarity;
176 MPControl<bool>& soloed;
178 ChannelRecord (uint32_t);
181 std::vector<ChannelRecord*> _channels;
185 /* pointers - created first, but managed by boost::shared_ptr<> */
187 MPControl<bool>* _dim_all_ptr;
188 MPControl<bool>* _cut_all_ptr;
189 MPControl<bool>* _mono_ptr;
190 MPControl<volatile gain_t>* _dim_level_ptr;
191 MPControl<volatile gain_t>* _solo_boost_level_ptr;
193 /* shared ptr access and lifetime management, for external users */
195 boost::shared_ptr<PBD::Controllable> _dim_all_control;
196 boost::shared_ptr<PBD::Controllable> _cut_all_control;
197 boost::shared_ptr<PBD::Controllable> _mono_control;
198 boost::shared_ptr<PBD::Controllable> _dim_level_control;
199 boost::shared_ptr<PBD::Controllable> _solo_boost_level_control;
201 /* typed controllables for internal use */
203 MPControl<bool>& _dim_all;
204 MPControl<bool>& _cut_all;
205 MPControl<bool>& _mono;
206 MPControl<volatile gain_t>& _dim_level;
207 MPControl<volatile gain_t>& _solo_boost_level;
209 void allocate_channels (uint32_t);
214 #endif /* __ardour_monitor_processor_h__ */