UI: Add editor_mixer route pointer to session so all UIs can know the same current_st...
[ardour.git] / libs / ardour / ardour / vca.h
index 82e0e7acd244234c9cb6542761715dedc87030fa..de0117ae8c4c74c074a3ccaff0379a499ad07f8b 100644 (file)
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
 
+#include <glibmm/threads.h>
+
 #include "pbd/controllable.h"
 #include "pbd/statefuldestructible.h"
 
 #include "ardour/automatable.h"
+#include "ardour/muteable.h"
+#include "ardour/monitorable.h"
+#include "ardour/recordable.h"
+#include "ardour/soloable.h"
+#include "ardour/slavable.h"
 #include "ardour/stripable.h"
 
 namespace ARDOUR {
 
-class GainControl;
 class Route;
-
-class LIBARDOUR_API VCA : public Stripable, public Automatable, public boost::enable_shared_from_this<VCA> {
+class GainControl;
+class SoloControl;
+class MuteControl;
+class MonitorControl;
+
+class LIBARDOUR_API VCA : public Stripable,
+                          public Soloable,
+                          public Muteable,
+                          public Automatable,
+                          public Recordable,
+                          public Monitorable,
+                          public boost::enable_shared_from_this<VCA> {
   public:
        VCA (Session& session,  uint32_t num, const std::string& name);
        ~VCA();
 
        uint32_t number () const { return _number; }
-       uint32_t remote_control_id() const;
 
        int init ();
        XMLNode& get_state();
        int set_state (XMLNode const&, int version);
 
-       void add_solo_target (boost::shared_ptr<Route>);
-       void remove_solo_target (boost::shared_ptr<Route>);
-       void add_mute_target (boost::shared_ptr<Route>);
-       void remove_mute_target (boost::shared_ptr<Route>);
+       PBD::Signal0<void> Drop; /* signal to slaves to drop control by this VCA */
+
+       /* Slavable API */
+
+        bool slaved_to (boost::shared_ptr<VCA>) const;
+        bool slaved () const;
+
+       /* Soloable API */
+
+       void clear_all_solo_state ();
 
        bool soloed () const;
-       bool muted () const;
+       void push_solo_upstream (int32_t) {}
+       void push_solo_isolate_upstream (int32_t) {}
+       bool can_solo() const { return true; }
+       bool is_safe () const { return false; }
+
+       /* Muteable API */
+
+       bool can_be_muted_by_others () const { return true; }
+       bool muted_by_others_soloing() const { return false; }
+
+       /* Recordable API */
+
+       int prep_record_enabled (bool yn) { return 0; }
+       bool can_be_record_enabled() { return true; }
+       bool can_be_record_safe() { return true; }
+
+       /* Monitorable API */
+
+       MonitorState monitoring_state() const;
 
        static std::string default_name_template ();
-       static int next_vca_number ();
+       static uint32_t next_vca_number ();
        static std::string xml_node_name;
 
        /* used by Session to save/restore the atomic counter */
        static uint32_t get_next_vca_number ();
        static void set_next_vca_number (uint32_t);
 
-       virtual boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
-       virtual boost::shared_ptr<AutomationControl> solo_control() const { return _solo_control; }
-       virtual boost::shared_ptr<AutomationControl> mute_control() const { return _mute_control; }
+       boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
+       boost::shared_ptr<SoloControl> solo_control() const { return _solo_control; }
+       boost::shared_ptr<MuteControl> mute_control() const { return _mute_control; }
 
        /* null Stripable API, because VCAs don't have any of this */
 
-       virtual boost::shared_ptr<PeakMeter>       peak_meter() { return boost::shared_ptr<PeakMeter>(); }
-       virtual boost::shared_ptr<const PeakMeter> peak_meter() const { return boost::shared_ptr<PeakMeter>(); }
-       virtual boost::shared_ptr<AutomationControl> phase_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> trim_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> monitoring_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> recenable_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_azimuth_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_elevation_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_width_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_frontback_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_lfe_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual uint32_t eq_band_cnt () const { return 0; }
-       virtual std::string eq_band_name (uint32_t) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_hpf_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_threshold_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_speed_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_mode_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_makeup_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_redux_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual std::string comp_mode_name (uint32_t mode) const { return std::string(); }
-       virtual std::string comp_speed_name (uint32_t mode) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual std::string send_name (uint32_t n) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<SoloIsolateControl> solo_isolate_control() const { return boost::shared_ptr<SoloIsolateControl>(); }
+       boost::shared_ptr<SoloSafeControl> solo_safe_control() const { return boost::shared_ptr<SoloSafeControl>(); }
+       boost::shared_ptr<PeakMeter>         peak_meter() { return boost::shared_ptr<PeakMeter>(); }
+       boost::shared_ptr<const PeakMeter>   peak_meter() const { return boost::shared_ptr<PeakMeter>(); }
+       boost::shared_ptr<PhaseControl>      phase_control() const { return boost::shared_ptr<PhaseControl>(); }
+       boost::shared_ptr<GainControl>       trim_control() const { return boost::shared_ptr<GainControl>(); }
+       boost::shared_ptr<AutomationControl> pan_azimuth_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_elevation_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_width_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_frontback_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_lfe_control() const { return boost::shared_ptr<AutomationControl>(); }
+       uint32_t eq_band_cnt () const { return 0; }
+       std::string eq_band_name (uint32_t) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_hpf_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_threshold_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_speed_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_mode_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_makeup_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_redux_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       std::string comp_mode_name (uint32_t mode) const { return std::string(); }
+       std::string comp_speed_name (uint32_t mode) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
+       std::string send_name (uint32_t n) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<MonitorProcessor> monitor_control() const { return boost::shared_ptr<MonitorProcessor>(); }
+       boost::shared_ptr<MonitorControl> monitoring_control() const { return boost::shared_ptr<MonitorControl>(); }
 
   private:
-       class VCASoloControllable : public AutomationControl {
-          public:
-               VCASoloControllable (std::string const & name, boost::shared_ptr<VCA> vca);
-               void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
-               void set_value_unchecked (double);
-               double get_value () const;
-         private:
-               void _set_value (double, PBD::Controllable::GroupControlDisposition group_override);
-               boost::weak_ptr<VCA> _vca;
-       };
-
-       class VCAMuteControllable : public AutomationControl {
-          public:
-               VCAMuteControllable (std::string const & name, boost::shared_ptr<VCA> vca);
-               void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
-               void set_value_unchecked (double);
-               double get_value () const;
-         private:
-               void _set_value (double, PBD::Controllable::GroupControlDisposition group_override);
-               boost::weak_ptr<VCA> _vca;
-       };
-
-       friend class VCASoloControllable;
-       friend class VCAMuteControllable;
-
-       uint32_t    _number;
-
-       RouteList solo_targets;
-       PBD::ScopedConnectionList solo_connections;
-       mutable Glib::Threads::RWLock solo_lock;
-
-       RouteList mute_targets;
-       PBD::ScopedConnectionList mute_connections;
-       mutable Glib::Threads::RWLock mute_lock;
+       uint32_t _number;
 
        boost::shared_ptr<GainControl> _gain_control;
-       boost::shared_ptr<VCASoloControllable> _solo_control;
-       boost::shared_ptr<VCAMuteControllable> _mute_control;
-       bool _solo_requested;
-       bool _mute_requested;
+       boost::shared_ptr<SoloControl> _solo_control;
+       boost::shared_ptr<MuteControl> _mute_control;
+
 
-       static gint next_number;
+       static uint32_t next_number;
+       static Glib::Threads::Mutex number_lock;
 
        void solo_target_going_away (boost::weak_ptr<Route>);
        void mute_target_going_away (boost::weak_ptr<Route>);
        bool soloed_locked () const;
        bool muted_locked () const;
-
-       void set_solo (bool yn);
-       void set_mute (bool yn);
-
 };
 
 } /* namespace */