From 723aa8461b812248277559da6fb53c5ad24e1a7a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 8 Nov 2024 01:33:27 +0100 Subject: [PATCH] Transfer from ardour_ui (PDC controls) --- gtk2_ardour/application_bar.cc | 95 +++++++++++++++++++++++++++++--- gtk2_ardour/application_bar.h | 12 +++- gtk2_ardour/ardour_ui.cc | 5 -- gtk2_ardour/ardour_ui.h | 11 ---- gtk2_ardour/ardour_ui2.cc | 75 ------------------------- gtk2_ardour/ardour_ui_dialogs.cc | 3 - 6 files changed, 97 insertions(+), 104 deletions(-) diff --git a/gtk2_ardour/application_bar.cc b/gtk2_ardour/application_bar.cc index 4e1a4f20b0..2459f32361 100644 --- a/gtk2_ardour/application_bar.cc +++ b/gtk2_ardour/application_bar.cc @@ -114,6 +114,7 @@ static const gchar *_record_mode_strings_[] = { ApplicationBar::ApplicationBar () : _have_layout (false) , _basic_ui (0) + , _latency_disable_button (ArdourButton::led_default_elements) { _record_mode_strings = I18N (_record_mode_strings_); } @@ -161,6 +162,15 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) act = ActionManager::get_action ("Transport", "TogglePunchOut"); _punch_out_button.set_related_action (act); + act = ActionManager::get_action ("Main", "ToggleLatencyCompensation"); + _latency_disable_button.set_related_action (act); + + _latency_disable_button.set_text (_("Disable PDC")); + _io_latency_label.set_text (_("I/O Latency:")); + + set_size_request_to_display_given_text (_route_latency_value, "1000 spl", 0, 0); + set_size_request_to_display_given_text (_io_latency_value, "888.88 ms", 0, 0); + int vpadding = 1; int hpadding = 2; int col = 0; @@ -183,6 +193,22 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) _table.attach (_record_mode_selector, col, col + 3, 1, 2 , FILL, SHRINK, hpadding, vpadding); col += 3; + _table.attach (_recpunch_spacer, TCOL, 0, 2 , SHRINK, EXPAND|FILL, 3, 0); + ++col; + + _table.attach (_latency_disable_button, TCOL, 0, 1 , FILL, SHRINK, hpadding, vpadding); + _table.attach (_io_latency_label, TCOL, 1, 2 , SHRINK, EXPAND|FILL, hpadding, 0); + ++col; + _table.attach (_route_latency_value, TCOL, 0, 1 , SHRINK, EXPAND|FILL, hpadding, 0); + _table.attach (_io_latency_value, TCOL, 1, 2 , SHRINK, EXPAND|FILL, hpadding, 0); + ++col; + + _route_latency_value.set_alignment (Gtk::ALIGN_END, Gtk::ALIGN_CENTER); + _io_latency_value.set_alignment (Gtk::ALIGN_END, Gtk::ALIGN_CENTER); + + _table.attach (_latency_spacer, TCOL, 0, 2 , SHRINK, EXPAND|FILL, 3, 0); + ++col; + _table.set_spacings (0); _table.set_row_spacings (4); _table.set_border_width (1); @@ -197,6 +223,7 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) button_height_size_group->add_widget (_punch_in_button); button_height_size_group->add_widget (_punch_out_button); button_height_size_group->add_widget (_record_mode_selector); + button_height_size_group->add_widget (_latency_disable_button); Glib::RefPtr punch_button_size_group = SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL); punch_button_size_group->add_widget (_punch_in_button); @@ -206,15 +233,22 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) Gtkmm2ext::UI::instance()->set_tip (_punch_in_button, _("Start recording at auto-punch start")); Gtkmm2ext::UI::instance()->set_tip (_punch_out_button, _("Stop recording at auto-punch end")); Gtkmm2ext::UI::instance()->set_tip (_record_mode_selector, _("Layered, new recordings will be added as regions on a layer atop existing regions.\nSoundOnSound, behaves like Layered, except underlying regions will be audible.\nNon Layered, the underlying region will be spliced and replaced with the newly recorded region.")); + Gtkmm2ext::UI::instance()->set_tip (_latency_disable_button, _("Disable all Plugin Delay Compensation. This results in the shortest delay from live input to output, but any paths with delay-causing plugins will sound later than those without.")); /* theming */ _sync_button.set_name ("transport active option button"); _punch_in_button.set_name ("punch button"); _punch_out_button.set_name ("punch button"); _record_mode_selector.set_name ("record mode button"); + _latency_disable_button.set_name ("latency button"); + + /* indicate global latency compensation en/disable */ + ARDOUR::Latent::DisableSwitchChanged.connect (_forever_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::latency_switch_changed, this), gui_context ()); /* initialize */ set_transport_sensitivity (false); + latency_switch_changed (); + session_latency_updated (true); if (_session) { repack_transport_hbox (); @@ -223,7 +257,6 @@ ApplicationBar::on_parent_changed (Gtk::Widget*) #undef PX_SCALE #undef TCOL - void ApplicationBar::repack_transport_hbox () { @@ -290,16 +323,16 @@ ApplicationBar::repack_transport_hbox () bool show_pdc = UIConfiguration::instance().get_show_toolbar_latency (); if (show_pdc) { latency_disable_button.show (); - route_latency_value.show (); - io_latency_label.show (); - io_latency_value.show (); - latency_spacer.show (); + _route_latency_value.show (); + _io_latency_label.show (); + _io_latency_value.show (); + _latency_spacer.show (); } else { latency_disable_button.hide (); - route_latency_value.hide (); - io_latency_label.hide (); - io_latency_value.hide (); - latency_spacer.hide (); + _route_latency_value.hide (); + _io_latency_label.hide (); + _io_latency_value.hide (); + _latency_spacer.hide (); } bool show_cue = UIConfiguration::instance().get_show_toolbar_cuectrl (); @@ -353,11 +386,15 @@ ApplicationBar::set_session (Session *s) _session->AuditionActive.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::auditioning_changed, this, _1), gui_context()); _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::map_transport_state, this), gui_context()); _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::parameter_changed, this, _1), gui_context()); + _session->LatencyUpdated.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ApplicationBar::session_latency_updated, this, _1), gui_context()); //initialize all session config settings std::function pc (std::bind (&ApplicationBar::parameter_changed, this, _1)); _session->config.map_parameters (pc); + /* initialize */ + session_latency_updated (true); + _blink_connection = Timers::blink_connect (sigc::mem_fun(*this, &ApplicationBar::blink_handler)); } @@ -368,6 +405,46 @@ ApplicationBar::set_transport_sensitivity (bool yn) _shuttle_box.set_sensitive (yn); } +void +ApplicationBar::latency_switch_changed () +{ + bool pdc_off = ARDOUR::Latent::zero_latency (); + if (_latency_disable_button.get_active() != pdc_off) { + _latency_disable_button.set_active (pdc_off); + } +} + +void +ApplicationBar::session_latency_updated (bool for_playback) +{ + if (!for_playback) { + /* latency updates happen in pairs, in the following order: + * - for capture + * - for playback + */ + return; + } + + if (!_session) { + _route_latency_value.set_text ("--"); + _io_latency_value.set_text ("--"); + } else { + samplecnt_t wrl = _session->worst_route_latency (); + samplecnt_t iol = _session->io_latency (); + float rate = _session->nominal_sample_rate (); + + _route_latency_value.set_text (samples_as_time_string (wrl, rate)); + + if (_session->engine().check_for_ambiguous_latency (true)) { +// _ambiguous_latency = true; + _io_latency_value.set_markup ("ambiguous"); + } else { +// _ambiguous_latency = false; + _io_latency_value.set_text (samples_as_time_string (iol, rate)); + } + } +} + void ApplicationBar::_auditioning_changed (bool onoff) diff --git a/gtk2_ardour/application_bar.h b/gtk2_ardour/application_bar.h index fd5bc7468b..9fa76264b4 100644 --- a/gtk2_ardour/application_bar.h +++ b/gtk2_ardour/application_bar.h @@ -75,6 +75,9 @@ private: void set_record_mode (ARDOUR::RecordMode); + void latency_switch_changed (); + void session_latency_updated (bool); + /* blinking alerts */ void sync_blink (bool); void blink_handler (bool); @@ -91,8 +94,15 @@ private: ArdourWidgets::ArdourButton _punch_in_button; ArdourWidgets::ArdourButton _punch_out_button; ArdourWidgets::ArdourDropdown _record_mode_selector; + ArdourWidgets::ArdourVSpacer _recpunch_spacer; + ArdourWidgets::ArdourVSpacer _latency_spacer; + ArdourWidgets::ArdourButton _latency_disable_button; + Gtk::Label _route_latency_value; + Gtk::Label _io_latency_label; + Gtk::Label _io_latency_value; std::vector _record_mode_strings; - sigc::connection _blink_connection; + sigc::connection _blink_connection; + PBD::ScopedConnectionList _forever_connections; }; diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index a2972562ca..f2e39c8c12 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -299,7 +299,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , _basic_ui (0) , startup_fsm (0) , secondary_clock_spacer (0) - , latency_disable_button (ArdourButton::led_default_elements) , _cue_rec_enable (_("Rec Cues"), ArdourButton::led_default_elements) , _cue_play_enable (_("Play Cues"), ArdourButton::led_default_elements) , time_info_box (0) @@ -351,7 +350,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , have_disk_speed_dialog_displayed (false) , _status_bar_visibility (X_("status-bar")) , _feedback_exists (false) - , _ambiguous_latency (false) , _log_not_acknowledged (LogLevelNone) , duplicate_routes_dialog (0) , editor_visibility_button (S_("Window|Edit")) @@ -464,9 +462,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) ARDOUR::Session::FeedbackDetected.connect (forever_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::feedback_detected, this), gui_context ()); ARDOUR::Session::SuccessfulGraphSort.connect (forever_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::successful_graph_sort, this), gui_context ()); - /* indicate global latency compensation en/disable */ - ARDOUR::Latent::DisableSwitchChanged.connect (forever_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::latency_switch_changed, this), gui_context ()); - /* handle requests to deal with missing files */ ARDOUR::Session::MissingFile.connect_same_thread (forever_connections, std::bind (&ARDOUR_UI::missing_file, this, _1, _2, _3)); diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index f661e8d482..446c12e46b 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -530,8 +530,6 @@ private: ApplicationBar *application_bar; - ArdourWidgets::ArdourVSpacer recpunch_spacer; - ArdourWidgets::ArdourVSpacer latency_spacer; ArdourWidgets::ArdourVSpacer monitor_spacer; ArdourWidgets::ArdourVSpacer scripts_spacer; ArdourWidgets::ArdourVSpacer cuectrl_spacer; @@ -544,16 +542,9 @@ private: void toggle_time_master (); void toggle_video_sync (); - - ArdourWidgets::ArdourButton latency_disable_button; - ArdourWidgets::ArdourButton _cue_rec_enable; ArdourWidgets::ArdourButton _cue_play_enable; - Gtk::Label route_latency_value; - Gtk::Label io_latency_label; - Gtk::Label io_latency_value; - MiniTimeline mini_timeline; TimeInfoBox* time_info_box; @@ -866,8 +857,6 @@ private: void toggle_latency_switch (); void latency_switch_changed (); - void session_latency_updated (bool); - void feedback_detected (); ArdourWidgets::ArdourButton midi_panic_button; diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index b48670423e..aca3e3600a 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -104,8 +104,6 @@ ARDOUR_UI::setup_tooltips () set_tip (_cue_rec_enable, _("When enabled, triggering Cues will result in Cue Markers added to the timeline")); set_tip (_cue_play_enable, _("When enabled, Cue Markers will trigger the associated Cue when passed on the timeline")); - set_tip (latency_disable_button, _("Disable all Plugin Delay Compensation. This results in the shortest delay from live input to output, but any paths with delay-causing plugins will sound later than those without.")); - synchronize_sync_source_and_video_pullup (); editor->setup_tooltips (); @@ -251,12 +249,6 @@ ARDOUR_UI::setup_transport () act = ActionManager::get_action (X_("Monitor Section"), X_("monitor-cut-all")); monitor_mute_button.set_related_action (act); - act = ActionManager::get_action ("Main", "ToggleLatencyCompensation"); - latency_disable_button.set_related_action (act); - - set_size_request_to_display_given_text (route_latency_value, "1000 spl", 0, 0); - set_size_request_to_display_given_text (io_latency_value, "888.88 ms", 0, 0); - /* connect signals */ ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &MainClock::set), false)); ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &MainClock::set), false)); @@ -313,8 +305,6 @@ ARDOUR_UI::setup_transport () recorder_visibility_button.set_name (X_("page switch button")); trigger_page_visibility_button.set_name (X_("page switch button")); - latency_disable_button.set_name ("latency button"); - monitor_dim_button.set_name ("monitor section dim"); monitor_mono_button.set_name ("monitor section mono"); monitor_mute_button.set_name ("mute button"); @@ -331,9 +321,6 @@ ARDOUR_UI::setup_transport () auto_return_button.set_text(_("Auto Return")); follow_edits_button.set_text(_("Follow Range")); - latency_disable_button.set_text (_("Disable PDC")); - io_latency_label.set_text (_("I/O Latency:")); - monitor_dim_button.set_text (_("Dim All")); monitor_mono_button.set_text (_("Mono")); monitor_mute_button.set_text (_("Mute All")); @@ -429,9 +416,6 @@ ARDOUR_UI::setup_transport () button_height_size_group->add_widget (mixer_visibility_button); button_height_size_group->add_widget (prefs_visibility_button); - // PDC - button_height_size_group->add_widget (latency_disable_button); - for (int i = 0; i < MAX_LUA_ACTION_BUTTONS; ++i) { button_height_size_group->add_widget (action_script_call_btn[i]); } @@ -453,22 +437,6 @@ ARDOUR_UI::setup_transport () transport_table.attach (*application_bar, TCOL, 0, 2 , EXPAND|FILL, EXPAND|FILL, 3, 0); ++col; - transport_table.attach (recpunch_spacer, TCOL, 0, 2 , SHRINK, EXPAND|FILL, 3, 0); - ++col; - - transport_table.attach (latency_disable_button, TCOL, 0, 1 , FILL, SHRINK, hpadding, vpadding); - transport_table.attach (io_latency_label, TCOL, 1, 2 , SHRINK, EXPAND|FILL, hpadding, 0); - ++col; - transport_table.attach (route_latency_value, TCOL, 0, 1 , SHRINK, EXPAND|FILL, hpadding, 0); - transport_table.attach (io_latency_value, TCOL, 1, 2 , SHRINK, EXPAND|FILL, hpadding, 0); - ++col; - - route_latency_value.set_alignment (Gtk::ALIGN_END, Gtk::ALIGN_CENTER); - io_latency_value.set_alignment (Gtk::ALIGN_END, Gtk::ALIGN_CENTER); - - transport_table.attach (latency_spacer, TCOL, 0, 2 , SHRINK, EXPAND|FILL, 3, 0); - ++col; - transport_table.attach (follow_edits_button, TCOL, 0, 1 , FILL, SHRINK, hpadding, vpadding); transport_table.attach (auto_return_button, TCOL, 1, 2 , FILL, SHRINK, hpadding, vpadding); ++col; @@ -538,9 +506,6 @@ ARDOUR_UI::setup_transport () ++col; /* initialize */ - latency_switch_changed (); - session_latency_updated (true); - update_clock_visibility (); /* desensitize */ @@ -552,46 +517,6 @@ ARDOUR_UI::setup_transport () #undef PX_SCALE #undef TCOL -void -ARDOUR_UI::latency_switch_changed () -{ - bool pdc_off = ARDOUR::Latent::zero_latency (); - if (latency_disable_button.get_active() != pdc_off) { - latency_disable_button.set_active (pdc_off); - } -} - -void -ARDOUR_UI::session_latency_updated (bool for_playback) -{ - if (!for_playback) { - /* latency updates happen in pairs, in the following order: - * - for capture - * - for playback - */ - return; - } - - if (!_session) { - route_latency_value.set_text ("--"); - io_latency_value.set_text ("--"); - } else { - samplecnt_t wrl = _session->worst_route_latency (); - samplecnt_t iol = _session->io_latency (); - float rate = _session->nominal_sample_rate (); - - route_latency_value.set_text (samples_as_time_string (wrl, rate)); - - if (_session->engine().check_for_ambiguous_latency (true)) { - _ambiguous_latency = true; - io_latency_value.set_markup ("ambiguous"); - } else { - _ambiguous_latency = false; - io_latency_value.set_text (samples_as_time_string (iol, rate)); - } - } -} - void ARDOUR_UI::soloing_changed (bool onoff) { diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index d158067fb2..8ce1dcc809 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -216,9 +216,6 @@ ARDOUR_UI::set_session (Session *s) _session->locations()->removed.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::handle_locations_change, this, _1), gui_context()); _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::session_parameter_changed, this, _1), gui_context ()); - _session->LatencyUpdated.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&ARDOUR_UI::session_latency_updated, this, _1), gui_context()); - session_latency_updated (true); - /* Clocks are on by default after we are connected to a session, so show that here. */