From 4f413678365373cd49c765a40153855128b5eb89 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 29 Sep 2019 01:23:48 +0200 Subject: Add Latency Control Toolbar Widgets --- gtk2_ardour/ardour_ui.cc | 4 +++ gtk2_ardour/ardour_ui.h | 12 +++++++ gtk2_ardour/ardour_ui2.cc | 69 ++++++++++++++++++++++++++++++++++++++++ gtk2_ardour/ardour_ui_dialogs.cc | 3 ++ gtk2_ardour/ardour_ui_ed.cc | 2 ++ gtk2_ardour/ardour_ui_options.cc | 9 ++++++ gtk2_ardour/rc_option_editor.cc | 8 +++++ gtk2_ardour/ui_config_vars.h | 1 + 8 files changed, 108 insertions(+) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 3c51c3912f..8cc3cbe366 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -304,6 +304,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , _shared_popup_menu (0) , secondary_clock_spacer (0) , auto_input_button (ArdourButton::led_default_elements) + , latency_disable_button (ArdourButton::led_default_elements) , time_info_box (0) , auto_return_button (ArdourButton::led_default_elements) , follow_edits_button (ArdourButton::led_default_elements) @@ -454,6 +455,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) ARDOUR::Session::FeedbackDetected.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::feedback_detected, this), gui_context ()); ARDOUR::Session::SuccessfulGraphSort.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::successful_graph_sort, this), gui_context ()); + /* indicate global latency compensation en/disable */ + ARDOUR::Latent::DisableSwitchChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::latency_switch_changed, this), gui_context ()); + /* handle requests to deal with missing files */ ARDOUR::Session::MissingFile.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::missing_file, this, _1, _2, _3)); diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 5425311e7c..8efcb787e7 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -496,6 +496,7 @@ private: ArdourWidgets::ArdourVSpacer recpunch_spacer; ArdourWidgets::ArdourVSpacer monitoring_spacer; + ArdourWidgets::ArdourVSpacer latency_spacer; ArdourWidgets::ArdourButton monitor_in_button; ArdourWidgets::ArdourButton monitor_disk_button; @@ -511,6 +512,13 @@ private: void toggle_time_master (); void toggle_video_sync (); + + ArdourWidgets::ArdourButton latency_disable_button; + + Gtk::Label route_latency_value; + Gtk::Label io_latency_label; + Gtk::Label io_latency_value; + ShuttleControl shuttle_box; MiniTimeline mini_timeline; TimeInfoBox* time_info_box; @@ -828,6 +836,10 @@ private: */ ARDOUR::ProcessThread* _process_thread; + void toggle_latency_switch (); + void latency_switch_changed (); + void session_latency_updated (); + void feedback_detected (); ArdourWidgets::ArdourButton midi_panic_button; diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 9ded21f221..c58f5dc9d9 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -95,6 +95,8 @@ ARDOUR_UI::setup_tooltips () set_tip (editor_meter_peak_display, _("Reset All Peak Meters")); set_tip (error_alert_button, _("Show Error Log and acknowledge warnings")); + set_tip (latency_disable_button, _("Disable all latency compensation. This will result in playback and monitoring to not be out of sync.")); + synchronize_sync_source_and_video_pullup (); editor->setup_tooltips (); @@ -233,6 +235,18 @@ ARDOUR_UI::repack_transport_hbox () recpunch_spacer.hide (); } + bool show_pdc = UIConfiguration::instance().get_show_toolbar_latency (); + if (show_pdc) { + latency_disable_button.show (); + route_latency_value.show (); + io_latency_value.show (); + latency_spacer.show (); + } else { + latency_disable_button.hide (); + route_latency_value.hide (); + io_latency_value.hide (); + latency_spacer.hide (); + } } void @@ -302,6 +316,12 @@ ARDOUR_UI::setup_transport () act = ActionManager::get_action ("Transport", "SessionMonitorDisk"); monitor_disk_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, "1000 spl", 0, 0); + /* connect signals */ ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &MainClock::set), false, 0)); ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &MainClock::set), false, 0)); @@ -350,6 +370,8 @@ ARDOUR_UI::setup_transport () monitor_disk_button.set_name ("monitor button"); auto_input_button.set_name ("transport option button"); + latency_disable_button.set_name ("monitor button"); + sync_button.set_name ("transport active option button"); /* and widget text */ @@ -363,6 +385,9 @@ ARDOUR_UI::setup_transport () monitor_disk_button.set_text (_("All Disk")); auto_input_button.set_text (_("Auto-Input")); + latency_disable_button.set_text (_("Disable PDC")); + io_latency_label.set_text (_("I/O Latency:")); + punch_label.set_text (_("Punch:")); layered_label.set_text (_("Rec:")); @@ -504,6 +529,20 @@ ARDOUR_UI::setup_transport () transport_table.attach (monitoring_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, vpadding); + ++col; + transport_table.attach (route_latency_value, TCOL, 0, 1 , SHRINK, EXPAND|FILL, hpadding, vpadding); + transport_table.attach (io_latency_value, TCOL, 1, 2 , SHRINK, EXPAND|FILL, hpadding, vpadding); + ++col; + + route_latency_value.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER); + io_latency_value.set_alignment (Gtk::ALIGN_RIGHT, 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; @@ -549,6 +588,10 @@ ARDOUR_UI::setup_transport () transport_table.attach (mixer_visibility_button, TCOL, 1, 2 , FILL, SHRINK, hpadding, vpadding); ++col; + /* initialize */ + latency_switch_changed (); + session_latency_updated (); + repack_transport_hbox (); update_clock_visibility (); /* desensitize */ @@ -563,6 +606,32 @@ 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 () +{ + if (!_session) { + route_latency_value.set_text ("--"); + io_latency_value.set_text ("--"); + } else { + samplecnt_t wrl = _session->worst_route_latency (); + samplecnt_t wpl = _session->worst_latency_preroll (); + float rate = _session->nominal_sample_rate (); + + route_latency_value.set_text (samples_as_time_string (wrl, rate)); + io_latency_value.set_text (samples_as_time_string (wpl, 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 cee609349c..f56f4c6adc 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -190,6 +190,9 @@ ARDOUR_UI::set_session (Session *s) _session->locations()->removed.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::handle_locations_change, this, _1), gui_context()); _session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_parameter_changed, this, _1), gui_context ()); + _session->LatencyUpdated.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_latency_updated, this), gui_context()); + session_latency_updated (); + /* Clocks are on by default after we are connected to a session, so show that here. */ diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index b7bf68ce28..6dc5316c1d 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -483,6 +483,8 @@ ARDOUR_UI::install_actions () ActionManager::session_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act); + act = ActionManager::register_toggle_action (main_actions, X_("ToggleLatencyCompensation"), _("Disable Latency Compensation"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_latency_switch)); + act = ActionManager::register_action (main_actions, X_("MonitorMenu"), _("Monitor Section")); /* just the submenu item */ ActionManager::session_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index c11d71796d..4998f76303 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -278,6 +278,13 @@ ARDOUR_UI::toggle_editing_space() } } +void +ARDOUR_UI::toggle_latency_switch () +{ + Glib::RefPtr tact = ActionManager::get_toggle_action ("Main", "ToggleLatencyCompensation"); + ARDOUR::Latent::force_zero_latency (tact->get_active()); +} + void ARDOUR_UI::setup_session_options () { @@ -429,6 +436,8 @@ ARDOUR_UI::parameter_changed (std::string p) repack_transport_hbox (); } else if (p == "show-toolbar-selclock") { repack_transport_hbox (); + } else if (p == "show-toolbar-latency") { + repack_transport_hbox (); } else if (p == "show-editor-meter") { repack_transport_hbox (); } else if (p == "show-secondary-clock") { diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index cf59952c9d..e3e41e3b25 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -3877,6 +3877,14 @@ RCOptionEditor::RCOptionEditor () sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_show_toolbar_monitoring) )); + add_option (_("Appearance/Toolbar"), + new BoolOption ( + "show-toolbar-latency", + _("Display Latency Compensation Info"), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_show_toolbar_latency), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_show_toolbar_latency) + )); + add_option (_("Appearance/Toolbar"), new BoolOption ( "show-toolbar-selclock", diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index 80dca868f0..6300862097 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -86,6 +86,7 @@ UI_CONFIG_VARIABLE (bool, show_editor_meter, "show-editor-meter", true) UI_CONFIG_VARIABLE (bool, show_toolbar_recpunch, "show-toolbar-recpunch", true) UI_CONFIG_VARIABLE (bool, show_toolbar_monitoring, "show-toolbar-monitoring", false) UI_CONFIG_VARIABLE (bool, show_toolbar_selclock, "show-toolbar-selclock", false) +UI_CONFIG_VARIABLE (bool, show_toolbar_latency, "show-toolbar-latency", false) UI_CONFIG_VARIABLE (bool, show_mini_timeline, "show-mini-timeline", true) UI_CONFIG_VARIABLE (bool, show_secondary_clock, "show-secondary-clock", true) UI_CONFIG_VARIABLE (double, waveform_clip_level, "waveform-clip-level", -0.0933967) /* units of dB */ -- cgit v1.2.3