From ba0dac92f2ac707d0ed4565ef197eed1079bb68d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 20 Jul 2020 22:54:54 +0200 Subject: [PATCH] Add a main-outs volume control and dedicated master-volume This is intended for loudness normalization - #8318 to add additional gain as last step. --- libs/ardour/ardour/route.h | 2 ++ libs/ardour/ardour/session.h | 1 + libs/ardour/route.cc | 19 +++++++++++++++++++ libs/ardour/session.cc | 9 +++++++++ 4 files changed, 31 insertions(+) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 7f71e35156..1d309d0970 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -500,6 +500,7 @@ public: boost::shared_ptr gain_control() const; boost::shared_ptr trim_control() const; + boost::shared_ptr volume_control() const; boost::shared_ptr phase_control() const; /** @@ -682,6 +683,7 @@ protected: boost::shared_ptr _gain_control; boost::shared_ptr _trim_control; + boost::shared_ptr _volume_control; boost::shared_ptr _phase_control; boost::shared_ptr _amp; boost::shared_ptr _trim; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f0e0709839..19e1b87bf4 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -957,6 +957,7 @@ public: boost::shared_ptr monitor_out() const { return _monitor_out; } boost::shared_ptr master_out() const { return _master_out; } + boost::shared_ptr master_volume () const; PresentationInfo::order_t master_order_key () const { return _master_out ? _master_out->presentation_info ().order () : -1; } bool ensure_stripable_sort_order (); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 1822889b91..370caa46c5 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -252,6 +252,13 @@ Route::init () } _main_outs.reset (new Delivery (_session, _output, _pannable, _mute_master, _name, Delivery::Main)); + /* master outut volume */ + if (is_master()) { + _volume_control.reset (new GainControl (_session, MainOutVolume)); + _volume_control->set_flag (Controllable::NotAutomatable); + //add_control (_volume_control); + _main_outs->add_gain (_volume_control); + } _main_outs->activate (); if (is_monitor()) { @@ -2524,6 +2531,10 @@ Route::state (bool save_template) node->add_child_nocopy (_mute_control->get_state ()); node->add_child_nocopy (_phase_control->get_state ()); + if (_volume_control) { + node->add_child_nocopy (_volume_control->get_state ()); + } + if (!skip_saving_automation) { node->add_child_nocopy (Automatable::get_automation_xml_state ()); } @@ -2761,6 +2772,8 @@ Route::set_state (const XMLNode& node, int version) _solo_isolate_control->set_state (*child, version); } else if (control_name == _mute_control->name()) { _mute_control->set_state (*child, version); + } else if (_volume_control && control_name == _volume_control->name()) { + _volume_control->set_state (*child, version); } else if (control_name == _phase_control->name()) { _phase_control->set_state (*child, version); } else { @@ -4612,6 +4625,12 @@ Route::trim_control() const return _trim_control; } +boost::shared_ptr +Route::volume_control() const +{ + return _volume_control; +} + boost::shared_ptr Route::phase_control() const { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 8dc7ad20cc..ca6d3a0cfa 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -925,6 +925,15 @@ Session::auto_connect_master_bus () } } +boost::shared_ptr +Session::master_volume () const +{ + if (_master_out) { + return _master_out->volume_control (); + } + return boost::shared_ptr (); +} + void Session::remove_monitor_section () {