diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-06 16:57:35 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-06 16:57:35 +0000 |
commit | e69aca28426dd17a0f82ea01c7c98e217b4fdcc3 (patch) | |
tree | 32854686f9de3cd61f07a5e801886b0f2d5a7012 /libs/ardour/ardour/monitor_processor.h | |
parent | 3a7487d3fa6887c846bc02d2764e376f7f209a03 (diff) |
MIDI/Controllables for monitor section, and related fixes
git-svn-id: svn://localhost/ardour2/branches/3.0@6863 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/monitor_processor.h')
-rw-r--r-- | libs/ardour/ardour/monitor_processor.h | 158 |
1 files changed, 145 insertions, 13 deletions
diff --git a/libs/ardour/ardour/monitor_processor.h b/libs/ardour/ardour/monitor_processor.h index 18c50e5104..8b8e90573d 100644 --- a/libs/ardour/ardour/monitor_processor.h +++ b/libs/ardour/ardour/monitor_processor.h @@ -20,9 +20,12 @@ #ifndef __ardour_monitor_processor_h__ #define __ardour_monitor_processor_h__ +#include <iostream> #include <vector> #include "pbd/signals.h" +#include "pbd/compose.h" +#include "pbd/controllable.h" #include "ardour/types.h" #include "ardour/processor.h" @@ -33,10 +36,77 @@ namespace ARDOUR { class Session; +template<typename T> class MPControl : public PBD::Controllable { + public: + MPControl (T initial, const std::string& name, PBD::Controllable::Flag flag, + float lower = 0.0f, float upper = 1.0f) + : PBD::Controllable (name, flag) + , _value (initial) + , _lower (lower) + , _upper (upper) + {} + + /* Controllable API */ + + void set_value (float v) { + T newval = (T) v; + if (newval != _value) { + _value = newval; + Changed(); /* EMIT SIGNAL */ + } + } + + float get_value () const { + return (float) _value; + } + + float lower () const { return _lower; } + float upper () const { return _upper; } + + /* "access as T" API */ + + MPControl& operator=(const T& v) { + if (v != _value) { + _value = v; + Changed (); /* EMIT SIGNAL */ + } + return *this; + } + + bool operator==(const T& v) const { + return _value == v; + } + + bool operator<(const T& v) const { + return _value < v; + } + + bool operator<=(const T& v) const { + return _value <= v; + } + + bool operator>(const T& v) const { + return _value > v; + } + + bool operator>=(const T& v) const { + return _value >= v; + } + + operator T() const { return _value; } + T val() const { return _value; } + + protected: + T _value; + T _lower; + T _upper; +}; + class MonitorProcessor : public Processor { public: MonitorProcessor (Session&); + ~MonitorProcessor (); bool display_to_user() const; @@ -71,27 +141,89 @@ class MonitorProcessor : public Processor bool mono () const; PBD::Signal0<void> Changed; + + boost::shared_ptr<PBD::Controllable> channel_cut_control (uint32_t) const; + boost::shared_ptr<PBD::Controllable> channel_dim_control (uint32_t) const; + boost::shared_ptr<PBD::Controllable> channel_polarity_control (uint32_t) const; + boost::shared_ptr<PBD::Controllable> channel_solo_control (uint32_t) const; + boost::shared_ptr<PBD::Controllable> dim_control () const { return _dim_all_control; } + boost::shared_ptr<PBD::Controllable> cut_control () const { return _cut_all_control; } + boost::shared_ptr<PBD::Controllable> mono_control () const { return _mono_control; } + boost::shared_ptr<PBD::Controllable> dim_level_control () const { return _dim_level_control; } + boost::shared_ptr<PBD::Controllable> solo_boost_control () const { return _solo_boost_level_control; } + private: struct ChannelRecord { gain_t current_gain; - gain_t cut; - bool dim; - gain_t polarity; - bool soloed; - ChannelRecord () - : current_gain(1.0), cut(1.0), dim(false), polarity(1.0), soloed (false) {} + /* pointers - created first, but managed by boost::shared_ptr<> */ + + MPControl<gain_t>* cut_ptr; + MPControl<bool>* dim_ptr; + MPControl<gain_t>* polarity_ptr; + MPControl<bool>* soloed_ptr; + + /* shared ptr access and lifetime management, for external users */ + + boost::shared_ptr<PBD::Controllable> cut_control; + boost::shared_ptr<PBD::Controllable> dim_control; + boost::shared_ptr<PBD::Controllable> polarity_control; + boost::shared_ptr<PBD::Controllable> soloed_control; + + /* typed controllables for internal use */ + + MPControl<gain_t>& cut; + MPControl<bool>& dim; + MPControl<gain_t>& polarity; + MPControl<bool>& soloed; + + ChannelRecord (uint32_t chn) : current_gain(1.0) + , cut_ptr (new MPControl<gain_t> (1.0, string_compose (_("cut control %1"), chn), PBD::Controllable::GainLike)) + , dim_ptr (new MPControl<bool> (false, string_compose (_("dim control"), chn), PBD::Controllable::Toggle)) + , polarity_ptr (new MPControl<gain_t> (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle)) + , soloed_ptr (new MPControl<bool> (false, string_compose (_("solo control"), chn), PBD::Controllable::Toggle)) + + , cut_control (cut_ptr) + , dim_control (dim_ptr) + , polarity_control (polarity_ptr) + , soloed_control (soloed_ptr) + + , cut (*cut_ptr) + , dim (*dim_ptr) + , polarity (*polarity_ptr) + , soloed (*soloed_ptr) + + {} }; - - std::vector<ChannelRecord> _channels; + + std::vector<ChannelRecord*> _channels; uint32_t solo_cnt; - bool _dim_all; - bool _cut_all; - bool _mono; - volatile gain_t _dim_level; - volatile gain_t _solo_boost_level; + + /* pointers - created first, but managed by boost::shared_ptr<> */ + + MPControl<bool>* _dim_all_ptr; + MPControl<bool>* _cut_all_ptr; + MPControl<bool>* _mono_ptr; + MPControl<volatile gain_t>* _dim_level_ptr; + MPControl<volatile gain_t>* _solo_boost_level_ptr; + + /* shared ptr access and lifetime management, for external users */ + + boost::shared_ptr<PBD::Controllable> _dim_all_control; + boost::shared_ptr<PBD::Controllable> _cut_all_control; + boost::shared_ptr<PBD::Controllable> _mono_control; + boost::shared_ptr<PBD::Controllable> _dim_level_control; + boost::shared_ptr<PBD::Controllable> _solo_boost_level_control; + + /* typed controllables for internal use */ + + MPControl<bool>& _dim_all; + MPControl<bool>& _cut_all; + MPControl<bool>& _mono; + MPControl<volatile gain_t>& _dim_level; + MPControl<volatile gain_t>& _solo_boost_level; void allocate_channels (uint32_t); }; |