2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <boost/scoped_ptr.hpp>
28 #include <gtkmm/messagedialog.h>
30 #include "pbd/error.h"
31 #include "pbd/xml++.h"
32 #include "pbd/unwind.h"
33 #include "pbd/failed_constructor.h"
35 #include <gtkmm/alignment.h>
36 #include <gtkmm/stock.h>
37 #include <gtkmm/notebook.h>
38 #include <gtkmm2ext/utils.h>
40 #include "ardour/audio_backend.h"
41 #include "ardour/audioengine.h"
42 #include "ardour/mtdm.h"
43 #include "ardour/rc_configuration.h"
44 #include "ardour/types.h"
46 #include "pbd/convert.h"
47 #include "pbd/error.h"
49 #include "ardour_ui.h"
50 #include "engine_dialog.h"
51 #include "gui_thread.h"
57 using namespace Gtkmm2ext;
61 static const unsigned int midi_tab = -1; /* not currently in use */
62 static const unsigned int latency_tab = 1; /* zero-based, page zero is the main setup page */
64 static const char* results_markup = X_("<span foreground=\"red\" style=\"italic\" size=\"larger\">%1</span>");
66 EngineControl::EngineControl ()
67 : ArdourDialog (_("Audio/MIDI Setup"))
69 , input_latency_adjustment (0, 0, 99999, 1)
70 , input_latency (input_latency_adjustment)
71 , output_latency_adjustment (0, 0, 99999, 1)
72 , output_latency (output_latency_adjustment)
73 , input_channels_adjustment (0, 0, 256, 1)
74 , input_channels (input_channels_adjustment)
75 , output_channels_adjustment (0, 0, 256, 1)
76 , output_channels (output_channels_adjustment)
77 , ports_adjustment (128, 8, 1024, 1, 16)
78 , ports_spinner (ports_adjustment)
79 , control_app_button (_("Device Control Panel"))
80 , lm_measure_label (_("Measure"))
81 , lm_use_button (_("Use results"))
82 , lm_back_button (_("Back to settings ... (ignore results)"))
83 , lm_button (_("Calibrate..."))
85 , have_lm_results (false)
87 , midi_refresh_button (_("Refresh list"))
89 , _desired_sample_rate (0)
91 , started_at_least_once (false)
93 using namespace Notebook_Helpers;
94 vector<string> strings;
96 AttachOptions xopt = AttachOptions (FILL|EXPAND);
99 set_name (X_("AudioMIDISetup"));
101 /* the backend combo is the one thing that is ALWAYS visible
104 vector<const ARDOUR::AudioBackendInfo*> backends = ARDOUR::AudioEngine::instance()->available_backends();
106 if (backends.empty()) {
107 MessageDialog msg (string_compose (_("No audio/MIDI backends detected. %1 cannot run\n\n(This is a build/packaging/system error. It should never happen.)"), PROGRAM_NAME));
109 throw failed_constructor ();
112 for (vector<const ARDOUR::AudioBackendInfo*>::const_iterator b = backends.begin(); b != backends.end(); ++b) {
113 strings.push_back ((*b)->name);
116 set_popdown_strings (backend_combo, strings);
117 backend_combo.set_active_text (strings.front());
118 backend_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::backend_changed));
120 /* setup basic packing characteristics for the table used on the main
121 * tab of the notebook
124 basic_packer.set_spacings (6);
125 basic_packer.set_border_width (12);
126 basic_packer.set_homogeneous (false);
130 basic_hbox.pack_start (basic_packer, false, false);
134 /* latency measurement tab */
136 lm_title.set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("Latency Measurement Tool")));
139 lm_table.set_row_spacings (12);
140 lm_table.set_col_spacings (6);
141 lm_table.set_homogeneous (false);
143 lm_table.attach (lm_title, 0, 3, row, row+1, xopt, (AttachOptions) 0);
146 Gtk::Label* preamble;
148 preamble = manage (new Label);
149 preamble->set_width_chars (60);
150 preamble->set_line_wrap (true);
151 preamble->set_markup (_("<span weight=\"bold\">Turn down the volume on your audio equipment to a very low level.</span>"));
153 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
156 preamble = manage (new Label);
157 preamble->set_width_chars (60);
158 preamble->set_line_wrap (true);
159 preamble->set_markup (_("Select two channels below and connect them using a cable."));
161 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
164 label = manage (new Label (_("Output channel")));
165 lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
167 Gtk::Alignment* misc_align = manage (new Alignment (0.0, 0.5));
168 misc_align->add (lm_output_channel_combo);
169 lm_table.attach (*misc_align, 1, 3, row, row+1, xopt, (AttachOptions) 0);
172 label = manage (new Label (_("Input channel")));
173 lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
175 misc_align = manage (new Alignment (0.0, 0.5));
176 misc_align->add (lm_input_channel_combo);
177 lm_table.attach (*misc_align, 1, 3, row, row+1, FILL, (AttachOptions) 0);
180 xopt = AttachOptions(0);
182 lm_measure_label.set_padding (10, 10);
183 lm_measure_button.add (lm_measure_label);
184 lm_measure_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::latency_button_clicked));
185 lm_use_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::use_latency_button_clicked));
186 lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), 0));
188 lm_use_button.set_sensitive (false);
190 /* Increase the default spacing around the labels of these three
196 if ((l = dynamic_cast<Gtk::Misc*>(lm_use_button.get_child())) != 0) {
197 l->set_padding (10, 10);
200 if ((l = dynamic_cast<Gtk::Misc*>(lm_back_button.get_child())) != 0) {
201 l->set_padding (10, 10);
204 preamble = manage (new Label);
205 preamble->set_width_chars (60);
206 preamble->set_line_wrap (true);
207 preamble->set_markup (_("Once the channels are connected, click the \"Measure\" button."));
208 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
211 preamble = manage (new Label);
212 preamble->set_width_chars (60);
213 preamble->set_line_wrap (true);
214 preamble->set_markup (_("When satisfied with the results, click the \"Use results\" button."));
215 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
217 ++row; // skip a row in the table
218 ++row; // skip a row in the table
220 lm_table.attach (lm_results, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
222 ++row; // skip a row in the table
223 ++row; // skip a row in the table
225 lm_table.attach (lm_measure_button, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
226 lm_table.attach (lm_use_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
227 lm_table.attach (lm_back_button, 2, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
229 lm_results.set_markup (string_compose (results_markup, _("No measurement results yet")));
231 lm_vbox.set_border_width (12);
232 lm_vbox.pack_start (lm_table, false, false);
236 notebook.pages().push_back (TabElem (basic_vbox, _("Audio")));
237 // notebook.pages().push_back (TabElem (midi_vbox, _("MIDI")));
238 notebook.pages().push_back (TabElem (lm_vbox, _("Latency")));
239 notebook.set_border_width (12);
241 notebook.set_show_tabs (false);
242 notebook.show_all ();
244 notebook.set_name ("SettingsNotebook");
246 /* packup the notebook */
248 get_vbox()->set_border_width (12);
249 get_vbox()->pack_start (notebook);
251 /* need a special function to print "all available channels" when the
252 * channel counts hit zero.
255 input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels));
256 output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels));
258 control_app_button.signal_clicked().connect (mem_fun (*this, &EngineControl::control_app_button_clicked));
259 manage_control_app_sensitivity ();
261 cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
262 ok_button = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
263 apply_button = add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
265 /* Pick up any existing audio setup configuration, if appropriate */
267 XMLNode* audio_setup = ARDOUR::Config->extra_xml ("AudioMIDISetup");
269 ARDOUR::AudioEngine::instance()->Running.connect (running_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_running, this), gui_context());
270 ARDOUR::AudioEngine::instance()->Stopped.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context());
271 ARDOUR::AudioEngine::instance()->Halted.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context());
276 set_state (*audio_setup);
279 /* Connect to signals */
281 driver_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::driver_changed));
282 sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::sample_rate_changed));
283 buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::buffer_size_changed));
284 device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
285 midi_option_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::midi_option_changed));
287 input_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
288 output_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
289 input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
290 output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
292 notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
298 EngineControl::on_response (int response_id)
300 ArdourDialog::on_response (response_id);
302 switch (response_id) {
304 push_state_to_backend (true);
307 push_state_to_backend (true);
310 case RESPONSE_DELETE_EVENT: {
312 ev.type = GDK_BUTTON_PRESS;
314 on_delete_event ((GdkEventAny*) &ev);
323 EngineControl::build_notebook ()
326 AttachOptions xopt = AttachOptions (FILL|EXPAND);
328 /* clear the table */
330 Gtkmm2ext::container_clear (basic_vbox);
331 Gtkmm2ext::container_clear (basic_packer);
333 label = manage (left_aligned_label (_("Audio System:")));
334 basic_packer.attach (*label, 0, 1, 0, 1, xopt, (AttachOptions) 0);
335 basic_packer.attach (backend_combo, 1, 2, 0, 1, xopt, (AttachOptions) 0);
337 lm_button.signal_clicked.connect (sigc::mem_fun (*this, &EngineControl::calibrate_latency));
338 lm_button.set_name ("record enable button");
340 build_full_control_notebook ();
342 build_no_control_notebook ();
345 basic_vbox.pack_start (basic_hbox, false, false);
348 Gtk::HBox* hpacker = manage (new HBox);
349 hpacker->set_border_width (12);
350 hpacker->pack_start (control_app_button, false, false);
352 control_app_button.show();
353 basic_vbox.pack_start (*hpacker);
356 basic_vbox.show_all ();
360 EngineControl::build_full_control_notebook ()
362 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
365 using namespace Notebook_Helpers;
367 vector<string> strings;
368 AttachOptions xopt = AttachOptions (FILL|EXPAND);
369 int row = 1; // row zero == backend combo
371 /* start packing it up */
373 if (backend->requires_driver_selection()) {
374 label = manage (left_aligned_label (_("Driver:")));
375 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
376 basic_packer.attach (driver_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
380 label = manage (left_aligned_label (_("Device:")));
381 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
382 basic_packer.attach (device_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
385 label = manage (left_aligned_label (_("Sample rate:")));
386 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
387 basic_packer.attach (sample_rate_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
391 label = manage (left_aligned_label (_("Buffer size:")));
392 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
393 basic_packer.attach (buffer_size_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
394 buffer_size_duration_label.set_alignment (0.0); /* left-align */
395 basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
398 input_channels.set_name ("InputChannels");
399 input_channels.set_flags(Gtk::CAN_FOCUS);
400 input_channels.set_digits(0);
401 input_channels.set_wrap(false);
402 output_channels.set_editable (true);
404 label = manage (left_aligned_label (_("Input Channels:")));
405 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
406 basic_packer.attach (input_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
409 output_channels.set_name ("OutputChannels");
410 output_channels.set_flags(Gtk::CAN_FOCUS);
411 output_channels.set_digits(0);
412 output_channels.set_wrap(false);
413 output_channels.set_editable (true);
415 label = manage (left_aligned_label (_("Output Channels:")));
416 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
417 basic_packer.attach (output_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
420 input_latency.set_name ("InputLatency");
421 input_latency.set_flags(Gtk::CAN_FOCUS);
422 input_latency.set_digits(0);
423 input_latency.set_wrap(false);
424 input_latency.set_editable (true);
426 label = manage (left_aligned_label (_("Hardware input latency:")));
427 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
428 basic_packer.attach (input_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0);
429 label = manage (left_aligned_label (_("samples")));
430 basic_packer.attach (*label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
433 output_latency.set_name ("OutputLatency");
434 output_latency.set_flags(Gtk::CAN_FOCUS);
435 output_latency.set_digits(0);
436 output_latency.set_wrap(false);
437 output_latency.set_editable (true);
439 label = manage (left_aligned_label (_("Hardware output latency:")));
440 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
441 basic_packer.attach (output_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0);
442 label = manage (left_aligned_label (_("samples")));
443 basic_packer.attach (*label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
445 /* button spans 2 rows */
447 basic_packer.attach (lm_button, 3, 4, row-1, row+1, xopt, xopt);
450 label = manage (left_aligned_label (_("MIDI System")));
451 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
452 basic_packer.attach (midi_option_combo, 1, 2, row, row + 1, SHRINK, (AttachOptions) 0);
457 EngineControl::build_no_control_notebook ()
459 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
462 using namespace Notebook_Helpers;
464 vector<string> strings;
465 AttachOptions xopt = AttachOptions (FILL|EXPAND);
466 int row = 1; // row zero == backend combo
467 const string msg = string_compose (_("The %1 audio backend was configured and started externally.\nThis limits your control over it."), backend->name());
469 label = manage (new Label);
470 label->set_markup (string_compose ("<span weight=\"bold\" foreground=\"red\">%1</span>", msg));
471 basic_packer.attach (*label, 0, 2, row, row + 1, xopt, (AttachOptions) 0);
474 if (backend->can_change_sample_rate_when_running()) {
475 label = manage (left_aligned_label (_("Sample rate:")));
476 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
477 basic_packer.attach (sample_rate_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
481 if (backend->can_change_buffer_size_when_running()) {
482 label = manage (left_aligned_label (_("Buffer size:")));
483 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
484 basic_packer.attach (buffer_size_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
485 buffer_size_duration_label.set_alignment (0.0); /* left-align */
486 basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, xopt, (AttachOptions) 0);
490 connect_disconnect_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::connect_disconnect_click));
492 basic_packer.attach (connect_disconnect_button, 0, 2, row, row+1, FILL, AttachOptions (0));
496 EngineControl::~EngineControl ()
498 ignore_changes = true;
502 EngineControl::disable_latency_tab ()
504 vector<string> empty;
505 set_popdown_strings (lm_output_channel_combo, empty);
506 set_popdown_strings (lm_input_channel_combo, empty);
507 lm_measure_button.set_sensitive (false);
508 lm_use_button.set_sensitive (false);
512 EngineControl::enable_latency_tab ()
514 vector<string> outputs;
515 vector<string> inputs;
517 ARDOUR::AudioEngine::instance()->get_physical_outputs (ARDOUR::DataType::AUDIO, outputs);
518 ARDOUR::AudioEngine::instance()->get_physical_inputs (ARDOUR::DataType::AUDIO, inputs);
520 if (inputs.empty() || outputs.empty()) {
521 MessageDialog msg (_("Your selected audio configuration is playback- or capture-only.\n\nLatency calibration requires playback and capture"));
522 lm_measure_button.set_sensitive (false);
523 notebook.set_current_page (0);
528 if (!outputs.empty()) {
529 set_popdown_strings (lm_output_channel_combo, outputs);
530 lm_output_channel_combo.set_active_text (outputs.front());
531 lm_output_channel_combo.set_sensitive (true);
533 lm_output_channel_combo.set_sensitive (false);
536 if (!inputs.empty()) {
537 set_popdown_strings (lm_input_channel_combo, inputs);
538 lm_input_channel_combo.set_active_text (inputs.front());
539 lm_input_channel_combo.set_sensitive (true);
541 lm_input_channel_combo.set_sensitive (false);
544 lm_measure_button.set_sensitive (true);
548 EngineControl::setup_midi_tab_for_backend ()
550 string backend = backend_combo.get_active_text ();
552 Gtkmm2ext::container_clear (midi_vbox);
554 midi_vbox.set_border_width (12);
555 midi_device_table.set_border_width (12);
557 if (backend == "JACK") {
558 setup_midi_tab_for_jack ();
561 midi_vbox.pack_start (midi_device_table, true, true);
562 midi_vbox.pack_start (midi_refresh_button, false, false);
563 midi_vbox.show_all ();
565 midi_refresh_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::refresh_midi_display));
569 EngineControl::setup_midi_tab_for_jack ()
574 EngineControl::refresh_midi_display ()
576 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
579 vector<string> midi_inputs;
580 vector<string> midi_outputs;
582 AttachOptions xopt = AttachOptions (FILL|EXPAND);
585 Gtkmm2ext::container_clear (midi_device_table);
587 backend->get_physical_inputs (ARDOUR::DataType::MIDI, midi_inputs);
588 backend->get_physical_outputs (ARDOUR::DataType::MIDI, midi_outputs);
590 midi_device_table.set_spacings (6);
591 midi_device_table.set_homogeneous (true);
592 midi_device_table.resize (midi_inputs.size() + midi_outputs.size() + 3, 1);
594 l = manage (new Label);
595 l->set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("MIDI Inputs")));
596 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
597 l->set_alignment (0, 0.5);
601 for (vector<string>::iterator p = midi_inputs.begin(); p != midi_inputs.end(); ++p) {
602 l = manage (new Label ((*p).substr ((*p).find_last_of (':') + 1)));
603 l->set_alignment (0, 0.5);
604 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
609 row++; // extra row of spacing
611 l = manage (new Label);
612 l->set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("MIDI Outputs")));
613 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
614 l->set_alignment (0, 0.5);
618 for (vector<string>::iterator p = midi_outputs.begin(); p != midi_outputs.end(); ++p) {
619 l = manage (new Label ((*p).substr ((*p).find_last_of (':') + 1)));
620 l->set_alignment (0, 0.5);
621 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
628 EngineControl::update_sensitivity ()
633 EngineControl::backend_changed ()
635 if (ignore_changes) {
639 string backend_name = backend_combo.get_active_text();
640 boost::shared_ptr<ARDOUR::AudioBackend> backend;
642 if (!(backend = ARDOUR::AudioEngine::instance()->set_backend (backend_name, "ardour", ""))) {
643 /* eh? setting the backend failed... how ? */
647 _have_control = ARDOUR::AudioEngine::instance()->setup_required ();
650 setup_midi_tab_for_backend ();
652 if (backend->requires_driver_selection()) {
653 vector<string> drivers = backend->enumerate_drivers();
655 if (!drivers.empty()) {
657 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
658 set_popdown_strings (driver_combo, drivers);
659 driver_combo.set_active_text (drivers.front());
666 driver_combo.set_sensitive (false);
667 /* this will change the device text which will cause a call to
668 * device changed which will set up parameters
673 vector<string> midi_options = backend->enumerate_midi_options();
675 if (midi_options.size() == 1) {
676 /* only contains the "none" option */
677 midi_option_combo.set_sensitive (false);
680 set_popdown_strings (midi_option_combo, midi_options);
681 midi_option_combo.set_active_text (midi_options.front());
682 midi_option_combo.set_sensitive (true);
684 midi_option_combo.set_sensitive (false);
688 maybe_display_saved_state ();
692 EngineControl::print_channel_count (Gtk::SpinButton* sb)
694 uint32_t cnt = (uint32_t) sb->get_value();
696 sb->set_text (_("all available channels"));
699 snprintf (buf, sizeof (buf), "%d", cnt);
706 EngineControl::list_devices ()
708 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
711 /* now fill out devices, mark sample rates, buffer sizes insensitive */
713 vector<ARDOUR::AudioBackend::DeviceStatus> all_devices = backend->enumerate_devices ();
715 /* NOTE: Ardour currently does not display the "available" field of the
718 * Doing so would require a different GUI widget than the combo
719 * box/popdown that we currently use, since it has no way to list
720 * items that are not selectable. Something more like a popup menu,
721 * which could have unselectable items, would be appropriate.
724 vector<string> available_devices;
726 for (vector<ARDOUR::AudioBackend::DeviceStatus>::const_iterator i = all_devices.begin(); i != all_devices.end(); ++i) {
727 available_devices.push_back (i->name);
730 if (!available_devices.empty()) {
732 update_sensitivity ();
735 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
736 set_popdown_strings (device_combo, available_devices);
737 device_combo.set_active_text (available_devices.front());
742 ok_button->set_sensitive (true);
743 apply_button->set_sensitive (true);
746 sample_rate_combo.set_sensitive (false);
747 buffer_size_combo.set_sensitive (false);
748 input_latency.set_sensitive (false);
749 output_latency.set_sensitive (false);
750 input_channels.set_sensitive (false);
751 output_channels.set_sensitive (false);
752 ok_button->set_sensitive (false);
753 apply_button->set_sensitive (false);
758 EngineControl::driver_changed ()
760 if (ignore_changes) {
764 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
767 backend->set_driver (driver_combo.get_active_text());
770 maybe_display_saved_state ();
774 EngineControl::device_changed ()
776 if (ignore_changes) {
780 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
782 string device_name = device_combo.get_active_text ();
786 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
788 /* don't allow programmatic change to combos to cause a
789 recursive call to this method.
799 sr = backend->available_sample_rates (device_name);
802 sr.push_back (8000.0f);
803 sr.push_back (16000.0f);
804 sr.push_back (32000.0f);
805 sr.push_back (44100.0f);
806 sr.push_back (48000.0f);
807 sr.push_back (88200.0f);
808 sr.push_back (96000.0f);
809 sr.push_back (192000.0f);
810 sr.push_back (384000.0f);
813 for (vector<float>::const_iterator x = sr.begin(); x != sr.end(); ++x) {
814 s.push_back (rate_as_string (*x));
815 if (*x == _desired_sample_rate) {
821 sample_rate_combo.set_sensitive (true);
822 set_popdown_strings (sample_rate_combo, s);
824 if (desired.empty()) {
825 sample_rate_combo.set_active_text (rate_as_string (backend->default_sample_rate()));
827 sample_rate_combo.set_active_text (desired);
831 sample_rate_combo.set_sensitive (false);
839 bs = backend->available_buffer_sizes(device_name);
840 } else if (backend->can_change_buffer_size_when_running()) {
854 for (vector<uint32_t>::const_iterator x = bs.begin(); x != bs.end(); ++x) {
855 s.push_back (bufsize_as_string (*x));
859 buffer_size_combo.set_sensitive (true);
860 set_popdown_strings (buffer_size_combo, s);
862 buffer_size_combo.set_active_text (bufsize_as_string (backend->default_buffer_size()));
863 show_buffer_duration ();
865 buffer_size_combo.set_sensitive (false);
868 /* XXX theoretically need to set min + max channel counts here
871 manage_control_app_sensitivity ();
874 /* pick up any saved state for this device */
876 maybe_display_saved_state ();
878 /* and push it to the backend */
880 push_state_to_backend (false);
884 EngineControl::bufsize_as_string (uint32_t sz)
886 /* Translators: "samples" is always plural here, so no
887 need for plural+singular forms.
890 snprintf (buf, sizeof (buf), _("%u samples"), sz);
895 EngineControl::sample_rate_changed ()
897 if (ignore_changes) {
901 /* reset the strings for buffer size to show the correct msec value
902 (reflecting the new sample rate).
905 show_buffer_duration ();
911 EngineControl::buffer_size_changed ()
913 if (ignore_changes) {
917 show_buffer_duration ();
922 EngineControl::show_buffer_duration ()
925 /* buffer sizes - convert from just samples to samples + msecs for
926 * the displayed string
929 string bs_text = buffer_size_combo.get_active_text ();
930 uint32_t samples = atoi (bs_text); /* will ignore trailing text */
931 uint32_t rate = get_rate();
933 /* Translators: "msecs" is ALWAYS plural here, so we do not
934 need singular form as well.
936 /* Developers: note the hard-coding of a double buffered model
937 in the (2 * samples) computation of latency. we always start
938 the audiobackend in this configuration.
941 snprintf (buf, sizeof (buf), _("(%.1f msecs)"), (2 * samples) / (rate/1000.0));
942 buffer_size_duration_label.set_text (buf);
946 EngineControl::midi_option_changed ()
948 if (!ignore_changes) {
954 EngineControl::parameter_changed ()
956 if (!ignore_changes) {
961 EngineControl::State*
962 EngineControl::get_matching_state (const string& backend,
963 const string& driver,
964 const string& device)
966 for (StateList::iterator i = states.begin(); i != states.end(); ++i) {
967 if ((*i).backend == backend &&
968 (*i).driver == driver &&
969 (*i).device == device) {
976 EngineControl::State*
977 EngineControl::get_saved_state_for_currently_displayed_backend_and_device ()
979 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
982 return get_matching_state (backend_combo.get_active_text(),
983 (backend->requires_driver_selection() ? (std::string) driver_combo.get_active_text() : string()),
984 device_combo.get_active_text());
988 return get_matching_state (backend_combo.get_active_text(),
990 device_combo.get_active_text());
993 EngineControl::State*
994 EngineControl::save_state ()
996 if (!_have_control) {
1000 bool existing = true;
1001 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1008 store_state (*state);
1011 states.push_back (*state);
1018 EngineControl::store_state (State& state)
1020 state.backend = get_backend ();
1021 state.driver = get_driver ();
1022 state.device = get_device_name ();
1023 state.sample_rate = get_rate ();
1024 state.buffer_size = get_buffer_size ();
1025 state.input_latency = get_input_latency ();
1026 state.output_latency = get_output_latency ();
1027 state.input_channels = get_input_channels ();
1028 state.output_channels = get_output_channels ();
1029 state.midi_option = get_midi_option ();
1033 EngineControl::maybe_display_saved_state ()
1035 if (!_have_control) {
1039 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1042 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
1044 if (!_desired_sample_rate) {
1045 sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
1047 buffer_size_combo.set_active_text (bufsize_as_string (state->buffer_size));
1048 /* call this explicitly because we're ignoring changes to
1049 the controls at this point.
1051 show_buffer_duration ();
1052 input_latency.set_value (state->input_latency);
1053 output_latency.set_value (state->output_latency);
1055 if (!state->midi_option.empty()) {
1056 midi_option_combo.set_active_text (state->midi_option);
1062 EngineControl::get_state ()
1064 XMLNode* root = new XMLNode ("AudioMIDISetup");
1067 if (!states.empty()) {
1068 XMLNode* state_nodes = new XMLNode ("EngineStates");
1070 for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
1072 XMLNode* node = new XMLNode ("State");
1074 node->add_property ("backend", (*i).backend);
1075 node->add_property ("driver", (*i).driver);
1076 node->add_property ("device", (*i).device);
1077 node->add_property ("sample-rate", (*i).sample_rate);
1078 node->add_property ("buffer-size", (*i).buffer_size);
1079 node->add_property ("input-latency", (*i).input_latency);
1080 node->add_property ("output-latency", (*i).output_latency);
1081 node->add_property ("input-channels", (*i).input_channels);
1082 node->add_property ("output-channels", (*i).output_channels);
1083 node->add_property ("active", (*i).active ? "yes" : "no");
1084 node->add_property ("midi-option", (*i).midi_option);
1086 state_nodes->add_child_nocopy (*node);
1089 root->add_child_nocopy (*state_nodes);
1096 EngineControl::set_state (const XMLNode& root)
1098 XMLNodeList clist, cclist;
1099 XMLNodeConstIterator citer, cciter;
1101 XMLNode* grandchild;
1102 XMLProperty* prop = NULL;
1104 if (root.name() != "AudioMIDISetup") {
1108 clist = root.children();
1112 for (citer = clist.begin(); citer != clist.end(); ++citer) {
1116 if (child->name() != "EngineStates") {
1120 cclist = child->children();
1122 for (cciter = cclist.begin(); cciter != cclist.end(); ++cciter) {
1125 grandchild = *cciter;
1127 if (grandchild->name() != "State") {
1131 if ((prop = grandchild->property ("backend")) == 0) {
1134 state.backend = prop->value ();
1136 if ((prop = grandchild->property ("driver")) == 0) {
1139 state.driver = prop->value ();
1141 if ((prop = grandchild->property ("device")) == 0) {
1144 state.device = prop->value ();
1146 if ((prop = grandchild->property ("sample-rate")) == 0) {
1149 state.sample_rate = atof (prop->value ());
1151 if ((prop = grandchild->property ("buffer-size")) == 0) {
1154 state.buffer_size = atoi (prop->value ());
1156 if ((prop = grandchild->property ("input-latency")) == 0) {
1159 state.input_latency = atoi (prop->value ());
1161 if ((prop = grandchild->property ("output-latency")) == 0) {
1164 state.output_latency = atoi (prop->value ());
1166 if ((prop = grandchild->property ("input-channels")) == 0) {
1169 state.input_channels = atoi (prop->value ());
1171 if ((prop = grandchild->property ("output-channels")) == 0) {
1174 state.output_channels = atoi (prop->value ());
1176 if ((prop = grandchild->property ("active")) == 0) {
1179 state.active = string_is_affirmative (prop->value ());
1181 if ((prop = grandchild->property ("midi-option")) == 0) {
1184 state.midi_option = prop->value ();
1186 states.push_back (state);
1190 /* now see if there was an active state and switch the setup to it */
1192 for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
1196 backend_combo.set_active_text ((*i).backend);
1197 driver_combo.set_active_text ((*i).driver);
1198 device_combo.set_active_text ((*i).device);
1199 sample_rate_combo.set_active_text (rate_as_string ((*i).sample_rate));
1200 buffer_size_combo.set_active_text (bufsize_as_string ((*i).buffer_size));
1201 input_latency.set_value ((*i).input_latency);
1202 output_latency.set_value ((*i).output_latency);
1203 midi_option_combo.set_active_text ((*i).midi_option);
1212 EngineControl::push_state_to_backend (bool start)
1218 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1224 /* figure out what is going to change */
1226 bool restart_required = false;
1227 bool was_running = ARDOUR::AudioEngine::instance()->running();
1228 bool change_driver = false;
1229 bool change_device = false;
1230 bool change_rate = false;
1231 bool change_bufsize = false;
1232 bool change_latency = false;
1233 bool change_channels = false;
1234 bool change_midi = false;
1236 uint32_t ochan = get_output_channels ();
1237 uint32_t ichan = get_input_channels ();
1239 if (_have_control) {
1241 if (started_at_least_once) {
1243 /* we can control the backend */
1245 if (backend->requires_driver_selection()) {
1246 if (get_driver() != backend->driver_name()) {
1247 change_driver = true;
1251 if (get_device_name() != backend->device_name()) {
1252 change_device = true;
1255 if (get_rate() != backend->sample_rate()) {
1259 if (get_buffer_size() != backend->buffer_size()) {
1260 change_bufsize = true;
1263 if (get_midi_option() != backend->midi_option()) {
1267 /* zero-requested channels means "all available" */
1270 ichan = backend->input_channels();
1274 ochan = backend->output_channels();
1277 if (ichan != backend->input_channels()) {
1278 change_channels = true;
1281 if (ochan != backend->output_channels()) {
1282 change_channels = true;
1285 if (get_input_latency() != backend->systemic_input_latency() ||
1286 get_output_latency() != backend->systemic_output_latency()) {
1287 change_latency = true;
1290 /* backend never started, so we have to force a group
1293 change_device = true;
1294 if (backend->requires_driver_selection()) {
1295 change_driver = true;
1298 change_bufsize = true;
1299 change_channels = true;
1300 change_latency = true;
1306 /* we have no control over the backend, meaning that we can
1307 * only possibly change sample rate and buffer size.
1311 if (get_rate() != backend->sample_rate()) {
1312 change_bufsize = true;
1315 if (get_buffer_size() != backend->buffer_size()) {
1316 change_bufsize = true;
1320 if (!_have_control) {
1322 /* We do not have control over the backend, so the best we can
1323 * do is try to change the sample rate and/or bufsize and get
1327 if (change_rate && !backend->can_change_sample_rate_when_running()) {
1331 if (change_bufsize && !backend->can_change_buffer_size_when_running()) {
1336 backend->set_sample_rate (get_rate());
1339 if (change_bufsize) {
1340 backend->set_buffer_size (get_buffer_size());
1348 /* determine if we need to stop the backend before changing parameters */
1350 if (change_driver || change_device || change_channels || change_latency ||
1351 (change_rate && !backend->can_change_sample_rate_when_running()) ||
1353 (change_bufsize && !backend->can_change_buffer_size_when_running())) {
1354 restart_required = true;
1356 restart_required = false;
1361 if (!change_driver && !change_device && !change_channels && !change_latency && !change_midi) {
1362 /* no changes in any parameters that absolutely require a
1363 * restart, so check those that might be changeable without a
1367 if (change_rate && !backend->can_change_sample_rate_when_running()) {
1368 /* can't do this while running ... */
1369 restart_required = true;
1372 if (change_bufsize && !backend->can_change_buffer_size_when_running()) {
1373 /* can't do this while running ... */
1374 restart_required = true;
1380 if (restart_required) {
1381 if (ARDOUR_UI::instance()->disconnect_from_engine ()) {
1388 if (change_driver && backend->set_driver (get_driver())) {
1389 error << string_compose (_("Cannot set driver to %1"), get_driver()) << endmsg;
1392 if (change_device && backend->set_device_name (get_device_name())) {
1393 error << string_compose (_("Cannot set device name to %1"), get_device_name()) << endmsg;
1396 if (change_rate && backend->set_sample_rate (get_rate())) {
1397 error << string_compose (_("Cannot set sample rate to %1"), get_rate()) << endmsg;
1400 if (change_bufsize && backend->set_buffer_size (get_buffer_size())) {
1401 error << string_compose (_("Cannot set buffer size to %1"), get_buffer_size()) << endmsg;
1405 if (change_channels || get_input_channels() == 0 || get_output_channels() == 0) {
1406 if (backend->set_input_channels (get_input_channels())) {
1407 error << string_compose (_("Cannot set input channels to %1"), get_input_channels()) << endmsg;
1410 if (backend->set_output_channels (get_output_channels())) {
1411 error << string_compose (_("Cannot set output channels to %1"), get_output_channels()) << endmsg;
1415 if (change_latency) {
1416 if (backend->set_systemic_input_latency (get_input_latency())) {
1417 error << string_compose (_("Cannot set input latency to %1"), get_input_latency()) << endmsg;
1420 if (backend->set_systemic_output_latency (get_output_latency())) {
1421 error << string_compose (_("Cannot set output latency to %1"), get_output_latency()) << endmsg;
1427 backend->set_midi_option (get_midi_option());
1430 if (start || (was_running && restart_required)) {
1431 if (ARDOUR_UI::instance()->reconnect_to_engine()) {
1442 EngineControl::post_push ()
1444 /* get a pointer to the current state object, creating one if
1448 if (_have_control) {
1449 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1452 state = save_state ();
1458 for (StateList::iterator i = states.begin(); i != states.end(); ++i) {
1459 (*i).active = false;
1462 /* mark this one active (to be used next time the dialog is
1466 state->active = true;
1468 manage_control_app_sensitivity ();
1471 /* schedule a redisplay of MIDI ports */
1473 Glib::signal_timeout().connect (sigc::bind_return (sigc::mem_fun (*this, &EngineControl::refresh_midi_display), false), 1000);
1478 EngineControl::get_rate () const
1480 float r = atof (sample_rate_combo.get_active_text ());
1481 /* the string may have been translated with an abbreviation for
1482 * thousands, so use a crude heuristic to fix this.
1492 EngineControl::get_buffer_size () const
1494 string txt = buffer_size_combo.get_active_text ();
1497 if (sscanf (txt.c_str(), "%d", &samples) != 1) {
1505 EngineControl::get_midi_option () const
1507 return midi_option_combo.get_active_text();
1511 EngineControl::get_input_channels() const
1513 return (uint32_t) input_channels_adjustment.get_value();
1517 EngineControl::get_output_channels() const
1519 return (uint32_t) output_channels_adjustment.get_value();
1523 EngineControl::get_input_latency() const
1525 return (uint32_t) input_latency_adjustment.get_value();
1529 EngineControl::get_output_latency() const
1531 return (uint32_t) output_latency_adjustment.get_value();
1535 EngineControl::get_backend () const
1537 return backend_combo.get_active_text ();
1541 EngineControl::get_driver () const
1543 return driver_combo.get_active_text ();
1547 EngineControl::get_device_name () const
1549 return device_combo.get_active_text ();
1553 EngineControl::control_app_button_clicked ()
1555 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1561 backend->launch_control_app ();
1565 EngineControl::manage_control_app_sensitivity ()
1567 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1573 string appname = backend->control_app_name();
1575 if (appname.empty()) {
1576 control_app_button.set_sensitive (false);
1578 control_app_button.set_sensitive (true);
1583 EngineControl::set_desired_sample_rate (uint32_t sr)
1585 _desired_sample_rate = sr;
1590 EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
1592 if (page_num == 0) {
1593 cancel_button->set_sensitive (true);
1594 ok_button->set_sensitive (true);
1595 apply_button->set_sensitive (true);
1597 cancel_button->set_sensitive (false);
1598 ok_button->set_sensitive (false);
1599 apply_button->set_sensitive (false);
1602 if (page_num == midi_tab) {
1604 refresh_midi_display ();
1607 if (page_num == latency_tab) {
1610 if (!ARDOUR::AudioEngine::instance()->running()) {
1612 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
1614 /* save any existing latency values */
1616 uint32_t il = (uint32_t) input_latency.get_value ();
1617 uint32_t ol = (uint32_t) input_latency.get_value ();
1619 /* reset to zero so that our new test instance of JACK
1620 will be clean of any existing latency measures.
1623 input_latency.set_value (0);
1624 output_latency.set_value (0);
1628 input_latency.set_value (il);
1629 output_latency.set_value (ol);
1633 if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) {
1634 disable_latency_tab ();
1637 enable_latency_tab ();
1641 ARDOUR::AudioEngine::instance()->stop_latency_detection();
1646 /* latency measurement */
1649 EngineControl::check_latency_measurement ()
1651 MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm ();
1653 if (mtdm->resolve () < 0) {
1654 lm_results.set_markup (string_compose (results_markup, _("No signal detected ")));
1658 if (mtdm->err () > 0.3) {
1664 ARDOUR::framecnt_t const sample_rate = ARDOUR::AudioEngine::instance()->sample_rate();
1666 if (sample_rate == 0) {
1667 lm_results.set_markup (string_compose (results_markup, _("Disconnected from audio engine")));
1668 ARDOUR::AudioEngine::instance()->stop_latency_detection ();
1672 uint32_t frames_total = mtdm->del();
1673 uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
1675 snprintf (buf, sizeof (buf), "%u samples / %.3lf ms", extra, extra * 1000.0f/sample_rate);
1679 if (mtdm->err () > 0.2) {
1681 strcat (buf, _("(signal detection error)"));
1687 strcat (buf, _("(inverted - bad wiring)"));
1692 end_latency_detection ();
1693 lm_use_button.set_sensitive (true);
1694 have_lm_results = true;
1697 lm_results.set_markup (string_compose (results_markup, string_compose (_("Detected roundtrip latency: %1"), buf)));
1703 EngineControl::start_latency_detection ()
1705 ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
1706 ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
1708 if (ARDOUR::AudioEngine::instance()->start_latency_detection () == 0) {
1709 lm_results.set_markup (string_compose (results_markup, _("Detecting ...")));
1710 latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 100);
1711 lm_measure_label.set_text (_("Cancel"));
1712 have_lm_results = false;
1713 lm_use_button.set_sensitive (false);
1714 lm_input_channel_combo.set_sensitive (false);
1715 lm_output_channel_combo.set_sensitive (false);
1721 EngineControl::end_latency_detection ()
1723 latency_timeout.disconnect ();
1724 ARDOUR::AudioEngine::instance()->stop_latency_detection ();
1725 lm_measure_label.set_text (_("Measure"));
1726 if (!have_lm_results) {
1727 lm_results.set_markup (string_compose (results_markup, _("No measurement results yet")));
1729 lm_use_button.set_sensitive (false);
1731 lm_input_channel_combo.set_sensitive (true);
1732 lm_output_channel_combo.set_sensitive (true);
1737 EngineControl::latency_button_clicked ()
1740 start_latency_detection ();
1742 end_latency_detection ();
1747 EngineControl::use_latency_button_clicked ()
1749 MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm ();
1755 uint32_t frames_total = mtdm->del();
1756 uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
1757 uint32_t one_way = extra/2;
1759 input_latency_adjustment.set_value (one_way);
1760 output_latency_adjustment.set_value (one_way);
1762 /* back to settings page */
1764 notebook.set_current_page (0);
1768 EngineControl::on_delete_event (GdkEventAny* ev)
1770 if (notebook.get_current_page() == 2) {
1771 /* currently on latency tab - be sure to clean up */
1772 end_latency_detection ();
1774 return ArdourDialog::on_delete_event (ev);
1778 EngineControl::engine_running ()
1780 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1783 buffer_size_combo.set_active_text (bufsize_as_string (backend->buffer_size()));
1784 sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
1786 buffer_size_combo.set_sensitive (true);
1787 sample_rate_combo.set_sensitive (true);
1789 connect_disconnect_button.set_label (string_compose (_("Disconnect from %1"), backend->name()));
1791 started_at_least_once = true;
1795 EngineControl::engine_stopped ()
1797 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1800 buffer_size_combo.set_sensitive (false);
1801 connect_disconnect_button.set_label (string_compose (_("Connect to %1"), backend->name()));
1803 sample_rate_combo.set_sensitive (true);
1804 buffer_size_combo.set_sensitive (true);
1808 EngineControl::connect_disconnect_click()
1810 if (ARDOUR::AudioEngine::instance()->running()) {
1811 ARDOUR_UI::instance()->disconnect_from_engine ();
1813 ARDOUR_UI::instance()->reconnect_to_engine ();
1818 EngineControl::calibrate_latency ()
1820 notebook.set_current_page (latency_tab);