From 2e00638761d08ae764bb6a7bd619640850d456ea Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 30 Jan 2024 23:03:12 +0100 Subject: [PATCH] Vapor: add AutomationControl to en/disable surround send This is in preparation to allow grouping send-enable. --- libs/ardour/ardour/surround_send.h | 16 +++++++++----- libs/ardour/surround_send.cc | 34 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/surround_send.h b/libs/ardour/ardour/surround_send.h index 9539f109ca..e7746fe35c 100644 --- a/libs/ardour/ardour/surround_send.h +++ b/libs/ardour/ardour/surround_send.h @@ -67,6 +67,7 @@ public: BufferSet const& bufs () const { return _mixbufs; } std::shared_ptr const& pan_param (size_t chn, timepos_t& s, timepos_t& e) const; + std::shared_ptr send_enable_control () const { return _send_enable_control; } protected: int set_state (const XMLNode&, int version); @@ -78,20 +79,25 @@ private: void cycle_start (pframes_t); void add_pannable (); + void send_enable_changed (); + void proc_active_changed (); + BufferSet _mixbufs; int32_t _surround_id; timepos_t _cycle_start; timepos_t _cycle_end; gain_t _current_gain; bool _has_state; + bool _ignore_enable_change; std::vector> _pannable; - std::shared_ptr _gain_control; - std::shared_ptr _amp; - std::shared_ptr _mute_master; - std::shared_ptr _send_delay; - std::shared_ptr _thru_delay; + std::shared_ptr _send_enable_control; + std::shared_ptr _gain_control; + std::shared_ptr _amp; + std::shared_ptr _mute_master; + std::shared_ptr _send_delay; + std::shared_ptr _thru_delay; PBD::ScopedConnectionList _change_connections; }; diff --git a/libs/ardour/surround_send.cc b/libs/ardour/surround_send.cc index d3201c01e5..0fa2a2ab88 100644 --- a/libs/ardour/surround_send.cc +++ b/libs/ardour/surround_send.cc @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "pbd/unwind.h" + #include "ardour/surround_send.h" #include "ardour/amp.h" #include "ardour/audioengine.h" @@ -37,6 +39,7 @@ SurroundSend::SurroundSend (Session& s, std::shared_ptr mm) , _surround_id (s.next_surround_send_id ()) , _current_gain (GAIN_COEFF_ZERO) , _has_state (false) + , _ignore_enable_change (false) , _mute_master (mm) { @@ -53,11 +56,18 @@ SurroundSend::SurroundSend (Session& s, std::shared_ptr mm) add_control (_gain_control); + _send_enable_control = std::shared_ptr (new AutomationControl (_session, BusSendEnable, ParameterDescriptor(BusSendEnable))); + _send_enable_control->Changed.connect_same_thread (*this, boost::bind (&SurroundSend::send_enable_changed, this)); + _send_enable_control->clear_flag (PBD::Controllable::RealTime); + + ActiveChanged.connect_same_thread (*this, boost::bind (&SurroundSend::proc_active_changed, this)); + InternalSend::CycleStart.connect_same_thread (*this, boost::bind (&SurroundSend::cycle_start, this, _1)); } SurroundSend::~SurroundSend () { + _send_enable_control->drop_references (); } std::shared_ptr @@ -396,6 +406,30 @@ SurroundSend::describe_parameter (Evoral::Parameter param) return Automatable::describe_parameter (param); } +void +SurroundSend::send_enable_changed () +{ + if (_ignore_enable_change) { + return; + } + PBD::Unwinder uw (_ignore_enable_change, true); + if (_send_enable_control->get_value () > 0) { + activate (); + } else { + deactivate (); + } +} + +void +SurroundSend::proc_active_changed () +{ + if (_ignore_enable_change) { + return; + } + PBD::Unwinder uw (_ignore_enable_change, true); + _send_enable_control->set_value (_pending_active ? 1 : 0, PBD::Controllable::UseGroup); +} + int SurroundSend::set_state (const XMLNode& node, int version) {