From e69aca28426dd17a0f82ea01c7c98e217b4fdcc3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 6 Apr 2010 16:57:35 +0000 Subject: MIDI/Controllables for monitor section, and related fixes git-svn-id: svn://localhost/ardour2/branches/3.0@6863 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/monitor_processor.h | 158 ++++++++++++++++++++++++++++++--- 1 file changed, 145 insertions(+), 13 deletions(-) (limited to 'libs/ardour/ardour/monitor_processor.h') 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 #include #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 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 Changed; + + boost::shared_ptr channel_cut_control (uint32_t) const; + boost::shared_ptr channel_dim_control (uint32_t) const; + boost::shared_ptr channel_polarity_control (uint32_t) const; + boost::shared_ptr channel_solo_control (uint32_t) const; + boost::shared_ptr dim_control () const { return _dim_all_control; } + boost::shared_ptr cut_control () const { return _cut_all_control; } + boost::shared_ptr mono_control () const { return _mono_control; } + boost::shared_ptr dim_level_control () const { return _dim_level_control; } + boost::shared_ptr 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* cut_ptr; + MPControl* dim_ptr; + MPControl* polarity_ptr; + MPControl* soloed_ptr; + + /* shared ptr access and lifetime management, for external users */ + + boost::shared_ptr cut_control; + boost::shared_ptr dim_control; + boost::shared_ptr polarity_control; + boost::shared_ptr soloed_control; + + /* typed controllables for internal use */ + + MPControl& cut; + MPControl& dim; + MPControl& polarity; + MPControl& soloed; + + ChannelRecord (uint32_t chn) : current_gain(1.0) + , cut_ptr (new MPControl (1.0, string_compose (_("cut control %1"), chn), PBD::Controllable::GainLike)) + , dim_ptr (new MPControl (false, string_compose (_("dim control"), chn), PBD::Controllable::Toggle)) + , polarity_ptr (new MPControl (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle)) + , soloed_ptr (new MPControl (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 _channels; + + std::vector _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* _dim_all_ptr; + MPControl* _cut_all_ptr; + MPControl* _mono_ptr; + MPControl* _dim_level_ptr; + MPControl* _solo_boost_level_ptr; + + /* shared ptr access and lifetime management, for external users */ + + boost::shared_ptr _dim_all_control; + boost::shared_ptr _cut_all_control; + boost::shared_ptr _mono_control; + boost::shared_ptr _dim_level_control; + boost::shared_ptr _solo_boost_level_control; + + /* typed controllables for internal use */ + + MPControl& _dim_all; + MPControl& _cut_all; + MPControl& _mono; + MPControl& _dim_level; + MPControl& _solo_boost_level; void allocate_channels (uint32_t); }; -- cgit v1.2.3