diff --git a/libs/ardour/ardour/delivery.h b/libs/ardour/ardour/delivery.h index 887da3b1da..36fd66fa50 100644 --- a/libs/ardour/ardour/delivery.h +++ b/libs/ardour/ardour/delivery.h @@ -29,6 +29,7 @@ #include "ardour/types.h" #include "ardour/chan_count.h" #include "ardour/io_processor.h" +#include "ardour/gain_control.h" namespace ARDOUR { @@ -100,6 +101,10 @@ public: boost::shared_ptr panner_shell() const { return _panshell; } boost::shared_ptr panner() const; + void add_gain (boost::shared_ptr gc) { + _gain_control = gc; + } + void unpan (); void reset_panner (); void defer_pan_reset (); @@ -116,14 +121,13 @@ protected: gain_t _current_gain; boost::shared_ptr _panshell; -#ifdef MIXBUS -public: /* expose target_gain to mixbus processor Route::process_output_buffers */ -#endif gain_t target_gain (); private: - bool _no_outs_cuz_we_no_monitor; - boost::shared_ptr _mute_master; + bool _no_outs_cuz_we_no_monitor; + + boost::shared_ptr _mute_master; + boost::shared_ptr _gain_control; static bool panners_legal; static PBD::Signal0 PannersLegal; diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 54a2c9f03d..5407f0e78b 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -571,6 +571,10 @@ Delivery::target_gain () gain_t desired_gain = _mute_master->mute_gain_at (mp); + if (_gain_control) { + desired_gain *= _gain_control->get_value(); + } + if (_role == Listen && _session.monitor_out() && !_session.listening()) { /* nobody is soloed, and this delivery is a listen-send to the diff --git a/libs/ardour/gain_control.cc b/libs/ardour/gain_control.cc index 370627b3ea..ab8ecf82ee 100644 --- a/libs/ardour/gain_control.cc +++ b/libs/ardour/gain_control.cc @@ -35,10 +35,49 @@ using namespace ARDOUR; using namespace std; +static std::string gain_control_name (Evoral::Parameter const& param) +{ + switch (param.type()) { + case GainAutomation: + /* fallthrough */ + case BusSendLevel: + return X_("gaincontrol"); + case TrimAutomation: + return X_("trimcontrol"); + case MainOutVolume: + return X_("mastervolume"); + default: + break; + } + /* default in AutomationControl c'tor uses + * EventTypeMap::instance().to_symbol(parameter) + */ + return ""; +} + +static boost::shared_ptr automation_list_new (Evoral::Parameter const& param) +{ + switch (param.type()) { + case GainAutomation: + /* fallthrough */ + case BusSendLevel: + /* fallthrough */ + case TrimAutomation: + return boost::shared_ptr (new AutomationList (param)); + case MainOutVolume: + /* not automatable */ + break; + default: + assert (0); + break; + } + return boost::shared_ptr (); +} + GainControl::GainControl (Session& session, const Evoral::Parameter ¶m, boost::shared_ptr al) : SlavableAutomationControl (session, param, ParameterDescriptor(param), - al ? al : boost::shared_ptr (new AutomationList (param)), - (param.type() == GainAutomation || param.type() == BusSendLevel) ? X_("gaincontrol") : X_("trimcontrol"), + al ? al : automation_list_new (param), + gain_control_name (param), Controllable::GainLike) { }