From 185bd62117b9728dc28d61fefdf31dcfc38451af Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 27 Jul 2020 22:00:08 +0200 Subject: [PATCH] Loudness Dialog: use MainOut-Volume instead of a-amp --- gtk2_ardour/loudness_dialog.cc | 158 ++------------------------------- gtk2_ardour/loudness_dialog.h | 10 +-- 2 files changed, 10 insertions(+), 158 deletions(-) diff --git a/gtk2_ardour/loudness_dialog.cc b/gtk2_ardour/loudness_dialog.cc index 6df055b2a4..0252034249 100644 --- a/gtk2_ardour/loudness_dialog.cc +++ b/gtk2_ardour/loudness_dialog.cc @@ -91,7 +91,7 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) , _rt_analysis_button (_("Realtime"), ArdourButton::led_default_elements, true) , _start_analysis_button (_("Analyze")) , _show_report_button (_("Show Detailed Report")) - , _use_amp_button (_("Use Amp Plugin"), ArdourButton::led_default_elements, true) + , _custom_pos_button (_("Custom Gain Processor Position"), ArdourButton::led_default_elements, true) , _dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2) , _dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2) , _lufs_i_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0) @@ -103,21 +103,18 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) , _lufs_s_spinbutton (_lufs_s_adjustment, 0.1, 1) , _lufs_m_spinbutton (_lufs_m_adjustment, 0.1, 1) , _gain_out (0) - , _gain_amp (0) , _gain_norm (0) , _ignore_change (false) { /* query initial gain */ - _session->master_out()->foreach_processor (sigc::mem_fun (*this, &LoudnessDialog::find_amp_cb)); - _gain_amp = amp_gain (); _gain_out = accurate_coefficient_to_dB (_session->master_volume()->get_value()); _start_analysis_button.set_name ("generic button"); _rt_analysis_button.set_name ("generic button"); _show_report_button.set_name ("generic button"); - _use_amp_button.set_name ("generic button"); + _custom_pos_button.set_name ("generic button"); - _use_amp_button.set_active (_amp ? true : false); + _custom_pos_button.set_active (!_session->master_out()->volume_applies_to_output ()); GtkRequisition req = _start_analysis_button.size_request (); _start_analysis_button.set_size_request (-1, req.height * 1.1); @@ -148,7 +145,6 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) _delta_lufs_m_label.modify_font (UIConfiguration::instance().get_NormalMonospaceFont()); _gain_out_label.modify_font (UIConfiguration::instance().get_NormalMonospaceFont()); - _gain_amp_label.modify_font (UIConfiguration::instance().get_NormalMonospaceFont()); _gain_norm_label.modify_font (UIConfiguration::instance().get_NormalMonospaceFont()); _gain_total_label.modify_font (UIConfiguration::instance().get_NormalMonospaceFont()); _gain_exceeds_label.modify_font (UIConfiguration::instance().get_NormalFont()); @@ -193,19 +189,8 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) l = manage (new Label (_("Previous output gain:"), ALIGN_LEFT)); t->attach (*l, 0, 1, ROW); ++row; - if (_amp) { - l = manage (new Label (_("Previous a-amp gain:"), ALIGN_LEFT)); - t->attach (*l, 0, 1, ROW); ++row; - } - l = manage (new Label (_("Total gain:"), ALIGN_LEFT)); t->attach (*l, 0, 1, ROW); ++row; - if (_amp) { - l = manage (new Label (_("Update a-Amplifier's Gain:"), ALIGN_LEFT)); - } else { - l = manage (new Label (_("Add a-Amplifier Plugin:"), ALIGN_LEFT)); - } - t->attach (*l, 0, 1, ROW); ++row; row = 3; t->attach (_dbfs_spinbutton, 1, 2, ROW, EXPAND|FILL, EXPAND|FILL, 8, 0); ++row; @@ -232,16 +217,12 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) t->attach (*spc, 2, 4, ROW); ++row; t->attach (_gain_norm_label, 3, 4, ROW); ++row; t->attach (_gain_out_label, 3, 4, ROW); ++row; - if (_amp) { - t->attach (_gain_amp_label, 3, 4, ROW); ++row; - } t->attach (_gain_exceeds_label, 2, 3, ROW); t->attach (_gain_total_label, 3, 4, ROW); ++row; + t->attach (_custom_pos_button, 1, 4, ROW); ++row; - t->attach (_use_amp_button, 2, 4, ROW); ++row; - - set_tooltip (_use_amp_button, - _("When enabled a amplifier plugin is used to apply the gain. " + set_tooltip (_custom_pos_button, + _("When enabled an amplifier processor is used to apply the gain. " "This allows for custom positons of the gain-stage in the master-bus' signal flow, potentially followed by a limiter. " "Depending on limiter settings or DSP after the gain-stage, repeat loudness measurements may produce different results.\n" "When disabled, the gain is applied diretcly to the output of the master-bus. This results in an efficient and reliable volume adjustment." @@ -261,7 +242,6 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) _gain_norm_label.set_alignment (ALIGN_RIGHT); _gain_out_label.set_alignment (ALIGN_RIGHT); - _gain_amp_label.set_alignment (ALIGN_RIGHT); _gain_total_label.set_alignment (ALIGN_RIGHT); _gain_exceeds_label.set_alignment (ALIGN_RIGHT); @@ -319,7 +299,6 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) apply_preset (); _gain_out_label.set_text (string_compose (_("%1 dB"), std::setprecision (2), std::showpos, std::fixed, _gain_out)); - _gain_amp_label.set_text (string_compose (_("%1 dB"), std::setprecision (2), std::showpos, std::fixed, _gain_amp)); _cancel_button->signal_clicked().connect (sigc::mem_fun (this, &LoudnessDialog::cancel_analysis)); _dbfs_spinbutton.signal_value_changed().connect (mem_fun (*this, &LoudnessDialog::update_settings)); @@ -335,8 +314,6 @@ LoudnessDialog::LoudnessDialog (Session* s, AudioRange const& ar, bool as) _lufs_s_btn.signal_clicked.connect (mem_fun (*this, &LoudnessDialog::update_settings)); _lufs_m_btn.signal_clicked.connect (mem_fun (*this, &LoudnessDialog::update_settings)); - _use_amp_button.signal_clicked.connect (mem_fun (*this, &LoudnessDialog::calculate_gain)); - _conformity_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &LoudnessDialog::toggle_conformity_display)); _ok_button->set_sensitive (false); @@ -389,18 +366,8 @@ LoudnessDialog::run () cancel_analysis (); if (r == RESPONSE_APPLY) { - - if (!_use_amp_button.get_active ()) { - _session->master_volume ()->set_value (dB_to_coefficient (gain_db ()), PBD::Controllable::NoGroup); - set_amp_gain (0); - } else { - instantiate_amp (); - if (set_amp_gain (gain_db ())) { - _session->master_volume ()->set_value (dB_to_coefficient (0), PBD::Controllable::NoGroup); - } else { - _session->master_volume ()->set_value (dB_to_coefficient (gain_db ()), PBD::Controllable::NoGroup); - } - } + _session->master_volume ()->set_value (dB_to_coefficient (gain_db ()), PBD::Controllable::NoGroup); + _session->master_out()->set_volume_applies_to_output (!_custom_pos_button.get_active ()); _preset.level[0] = _dbfs_spinbutton.get_value(); _preset.level[1] = _dbtp_spinbutton.get_value(); @@ -420,108 +387,6 @@ LoudnessDialog::run () return r; } -bool -LoudnessDialog::instantiate_amp () -{ - if (_amp) { - return true; - } - PluginPtr p; - PluginManager& pm = PluginManager::instance (); - const PluginInfoList& plugs = pm.lua_plugin_info(); - for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) { - if ((*i)->name == "a-Amplifier") { - p = (*i)->load (*_session); - break; - } - } - if (!p) { - // this cannot really happen a-amp (Lua script) is bundled with Ardour - ArdourMessageDialog (*this, _("a-Amplifier plugin was not found\nMaster-bus output volume is used instead")).run (); - return false; - } - boost::shared_ptr proc (new PluginInsert (*_session, p)); - _amp = boost::dynamic_pointer_cast (proc); - if (!_amp) { - return false; - } - return 0 == _session->master_out()->add_processor_by_index (proc, -1, NULL, true); -} - -bool -LoudnessDialog::set_amp_gain (float db) -{ - if (!_amp) { - return false; - } - /* compare ARDOUR::LuaAPI::set_processor_param */ - uint32_t which = 0; - - boost::shared_ptr ac = _amp->automation_control (Evoral::Parameter (PluginAutomation, 0, which)); - assert (ac); - if (ac) { - ac->set_automation_state (ARDOUR::Off); - } - - boost::shared_ptr plugin = _amp->plugin (); - - bool ok = false; - uint32_t controlid = plugin->nth_parameter (which, ok); - if (!ok || !plugin->parameter_is_input (controlid)) { - return false; - } - - ParameterDescriptor pd; - if (0 != plugin->get_parameter_descriptor (controlid, pd)) { - return false; - } - - db = std::max (db, pd.lower); - db = std::min (db, pd.upper); - - boost::shared_ptr c = _amp->automation_control (Evoral::Parameter (PluginAutomation, 0, controlid)); - if (!c) { - return false; - } - c->set_value (db, PBD::Controllable::NoGroup); - return true; -} - -float -LoudnessDialog::amp_gain () const -{ - const uint32_t which = 0; - - if (!_amp) { - return 0; - } - - bool ok = false; - boost::shared_ptr plugin = _amp->plugin (); - uint32_t controlid = plugin->nth_parameter (which, ok); - if (!ok || !plugin->parameter_is_input (controlid)) { - return 0; - } - - return plugin->get_parameter (controlid); -} - -void -LoudnessDialog::find_amp_cb (boost::weak_ptr p) -{ - boost::shared_ptr proc = p.lock (); - if (!proc || !proc->display_to_user ()) { - return; - } - boost::shared_ptr pi = boost::dynamic_pointer_cast (proc); - if (!pi) { - return; - } - if (pi->display_name () == "a-Amplifier") { - _amp = pi; - } -} - gint LoudnessDialog::progress_timeout () { @@ -665,12 +530,7 @@ LoudnessDialog::update_settings () float LoudnessDialog::gain_db () const { -#if 0 // option to set output gain only instead of zeroing plugin - if (_amp && ! _use_amp_button.get_active ()) { - return _gain_norm + _gain_out; - } -#endif - return _gain_norm + _gain_out + _gain_amp; + return _gain_norm + _gain_out; } void diff --git a/gtk2_ardour/loudness_dialog.h b/gtk2_ardour/loudness_dialog.h index 223ac074dc..6ddbd4677b 100644 --- a/gtk2_ardour/loudness_dialog.h +++ b/gtk2_ardour/loudness_dialog.h @@ -65,13 +65,6 @@ private: void test_conformity (); void toggle_conformity_display (); - bool instantiate_amp (); - bool set_amp_gain (float db); - float amp_gain () const; - void find_amp_cb (boost::weak_ptr p); - - boost::shared_ptr _amp; - struct LoudnessPreset { std::string name; @@ -123,7 +116,7 @@ private: ArdourWidgets::ArdourButton _rt_analysis_button; ArdourWidgets::ArdourButton _start_analysis_button; ArdourWidgets::ArdourButton _show_report_button; - ArdourWidgets::ArdourButton _use_amp_button; + ArdourWidgets::ArdourButton _custom_pos_button; ArdourWidgets::ArdourDropdown _preset_dropdown; std::string _initial_preset_name; @@ -147,7 +140,6 @@ private: float _lufs_m; float _gain_out; - float _gain_amp; float _gain_norm; bool _ignore_change; };