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)
90 , started_at_least_once (false)
92 using namespace Notebook_Helpers;
93 vector<string> strings;
95 AttachOptions xopt = AttachOptions (FILL|EXPAND);
98 set_name (X_("AudioMIDISetup"));
100 /* the backend combo is the one thing that is ALWAYS visible
103 vector<const ARDOUR::AudioBackendInfo*> backends = ARDOUR::AudioEngine::instance()->available_backends();
105 if (backends.empty()) {
106 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));
108 throw failed_constructor ();
111 for (vector<const ARDOUR::AudioBackendInfo*>::const_iterator b = backends.begin(); b != backends.end(); ++b) {
112 strings.push_back ((*b)->name);
115 set_popdown_strings (backend_combo, strings);
116 backend_combo.set_active_text (strings.front());
117 backend_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::backend_changed));
119 /* setup basic packing characteristics for the table used on the main
120 * tab of the notebook
123 basic_packer.set_spacings (6);
124 basic_packer.set_border_width (12);
125 basic_packer.set_homogeneous (false);
129 basic_hbox.pack_start (basic_packer, false, false);
133 /* latency measurement tab */
135 lm_title.set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("Latency Measurement Tool")));
138 lm_table.set_row_spacings (12);
139 lm_table.set_col_spacings (6);
140 lm_table.set_homogeneous (false);
142 lm_table.attach (lm_title, 0, 3, row, row+1, xopt, (AttachOptions) 0);
145 Gtk::Label* preamble;
147 preamble = manage (new Label);
148 preamble->set_width_chars (60);
149 preamble->set_line_wrap (true);
150 preamble->set_markup (_("<span weight=\"bold\">Turn down the volume on your audio equipment to a very low level.</span>"));
152 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
155 preamble = manage (new Label);
156 preamble->set_width_chars (60);
157 preamble->set_line_wrap (true);
158 preamble->set_markup (_("Select two channels below and connect them using a cable."));
160 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
163 label = manage (new Label (_("Output channel")));
164 lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
166 Gtk::Alignment* misc_align = manage (new Alignment (0.0, 0.5));
167 misc_align->add (lm_output_channel_combo);
168 lm_table.attach (*misc_align, 1, 3, row, row+1, xopt, (AttachOptions) 0);
171 label = manage (new Label (_("Input channel")));
172 lm_table.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
174 misc_align = manage (new Alignment (0.0, 0.5));
175 misc_align->add (lm_input_channel_combo);
176 lm_table.attach (*misc_align, 1, 3, row, row+1, FILL, (AttachOptions) 0);
179 xopt = AttachOptions(0);
181 lm_measure_label.set_padding (10, 10);
182 lm_measure_button.add (lm_measure_label);
183 lm_measure_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::latency_button_clicked));
184 lm_use_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::use_latency_button_clicked));
185 lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), 0));
187 lm_use_button.set_sensitive (false);
189 /* Increase the default spacing around the labels of these three
195 if ((l = dynamic_cast<Gtk::Misc*>(lm_use_button.get_child())) != 0) {
196 l->set_padding (10, 10);
199 if ((l = dynamic_cast<Gtk::Misc*>(lm_back_button.get_child())) != 0) {
200 l->set_padding (10, 10);
203 preamble = manage (new Label);
204 preamble->set_width_chars (60);
205 preamble->set_line_wrap (true);
206 preamble->set_markup (_("Once the channels are connected, click the \"Measure\" button."));
207 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
210 preamble = manage (new Label);
211 preamble->set_width_chars (60);
212 preamble->set_line_wrap (true);
213 preamble->set_markup (_("When satisfied with the results, click the \"Use results\" button."));
214 lm_table.attach (*preamble, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
216 ++row; // skip a row in the table
217 ++row; // skip a row in the table
219 lm_table.attach (lm_results, 0, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
221 ++row; // skip a row in the table
222 ++row; // skip a row in the table
224 lm_table.attach (lm_measure_button, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
225 lm_table.attach (lm_use_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
226 lm_table.attach (lm_back_button, 2, 3, row, row+1, AttachOptions(FILL|EXPAND), (AttachOptions) 0);
228 lm_results.set_markup (string_compose (results_markup, _("No measurement results yet")));
230 lm_vbox.set_border_width (12);
231 lm_vbox.pack_start (lm_table, false, false);
235 notebook.pages().push_back (TabElem (basic_vbox, _("Audio")));
236 // notebook.pages().push_back (TabElem (midi_vbox, _("MIDI")));
237 notebook.pages().push_back (TabElem (lm_vbox, _("Latency")));
238 notebook.set_border_width (12);
240 notebook.set_show_tabs (false);
241 notebook.show_all ();
243 notebook.set_name ("SettingsNotebook");
245 /* packup the notebook */
247 get_vbox()->set_border_width (12);
248 get_vbox()->pack_start (notebook);
250 /* need a special function to print "all available channels" when the
251 * channel counts hit zero.
254 input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels));
255 output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels));
257 control_app_button.signal_clicked().connect (mem_fun (*this, &EngineControl::control_app_button_clicked));
258 manage_control_app_sensitivity ();
260 cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
261 ok_button = add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
262 apply_button = add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
264 /* Pick up any existing audio setup configuration, if appropriate */
266 XMLNode* audio_setup = ARDOUR::Config->extra_xml ("AudioMIDISetup");
268 ARDOUR::AudioEngine::instance()->Running.connect (running_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_running, this), gui_context());
269 ARDOUR::AudioEngine::instance()->Stopped.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context());
270 ARDOUR::AudioEngine::instance()->Halted.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&EngineControl::engine_stopped, this), gui_context());
275 set_state (*audio_setup);
278 /* Connect to signals */
280 driver_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::driver_changed));
281 sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::sample_rate_changed));
282 buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::buffer_size_changed));
283 device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
284 midi_option_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::midi_option_changed));
286 input_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
287 output_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
288 input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
289 output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
291 notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
295 EngineControl::on_response (int response_id)
297 ArdourDialog::on_response (response_id);
299 switch (response_id) {
301 push_state_to_backend (true);
304 push_state_to_backend (true);
307 case RESPONSE_DELETE_EVENT: {
309 ev.type = GDK_BUTTON_PRESS;
311 on_delete_event ((GdkEventAny*) &ev);
320 EngineControl::build_notebook ()
323 AttachOptions xopt = AttachOptions (FILL|EXPAND);
325 /* clear the table */
327 Gtkmm2ext::container_clear (basic_vbox);
328 Gtkmm2ext::container_clear (basic_packer);
330 if (control_app_button.get_parent()) {
331 control_app_button.get_parent()->remove (control_app_button);
334 label = manage (left_aligned_label (_("Audio System:")));
335 basic_packer.attach (*label, 0, 1, 0, 1, xopt, (AttachOptions) 0);
336 basic_packer.attach (backend_combo, 1, 2, 0, 1, xopt, (AttachOptions) 0);
338 lm_button.signal_clicked.connect (sigc::mem_fun (*this, &EngineControl::calibrate_latency));
339 lm_button.set_name ("generic button");
341 build_full_control_notebook ();
343 build_no_control_notebook ();
346 basic_vbox.pack_start (basic_hbox, false, false);
349 Gtk::HBox* hpacker = manage (new HBox);
350 hpacker->set_border_width (12);
351 hpacker->pack_start (control_app_button, false, false);
353 control_app_button.show();
354 basic_vbox.pack_start (*hpacker);
357 basic_vbox.show_all ();
361 EngineControl::build_full_control_notebook ()
363 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
366 using namespace Notebook_Helpers;
368 vector<string> strings;
369 AttachOptions xopt = AttachOptions (FILL|EXPAND);
370 int row = 1; // row zero == backend combo
372 /* start packing it up */
374 if (backend->requires_driver_selection()) {
375 label = manage (left_aligned_label (_("Driver:")));
376 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
377 basic_packer.attach (driver_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
381 label = manage (left_aligned_label (_("Device:")));
382 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
383 basic_packer.attach (device_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
386 label = manage (left_aligned_label (_("Sample rate:")));
387 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
388 basic_packer.attach (sample_rate_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
392 label = manage (left_aligned_label (_("Buffer size:")));
393 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
394 basic_packer.attach (buffer_size_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
395 buffer_size_duration_label.set_alignment (0.0); /* left-align */
396 basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
399 input_channels.set_name ("InputChannels");
400 input_channels.set_flags(Gtk::CAN_FOCUS);
401 input_channels.set_digits(0);
402 input_channels.set_wrap(false);
403 output_channels.set_editable (true);
405 label = manage (left_aligned_label (_("Input Channels:")));
406 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
407 basic_packer.attach (input_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
410 output_channels.set_name ("OutputChannels");
411 output_channels.set_flags(Gtk::CAN_FOCUS);
412 output_channels.set_digits(0);
413 output_channels.set_wrap(false);
414 output_channels.set_editable (true);
416 label = manage (left_aligned_label (_("Output Channels:")));
417 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
418 basic_packer.attach (output_channels, 1, 2, row, row+1, xopt, (AttachOptions) 0);
421 input_latency.set_name ("InputLatency");
422 input_latency.set_flags(Gtk::CAN_FOCUS);
423 input_latency.set_digits(0);
424 input_latency.set_wrap(false);
425 input_latency.set_editable (true);
427 label = manage (left_aligned_label (_("Hardware input latency:")));
428 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
429 basic_packer.attach (input_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0);
430 label = manage (left_aligned_label (_("samples")));
431 basic_packer.attach (*label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
434 output_latency.set_name ("OutputLatency");
435 output_latency.set_flags(Gtk::CAN_FOCUS);
436 output_latency.set_digits(0);
437 output_latency.set_wrap(false);
438 output_latency.set_editable (true);
440 label = manage (left_aligned_label (_("Hardware output latency:")));
441 basic_packer.attach (*label, 0, 1, row, row+1, xopt, (AttachOptions) 0);
442 basic_packer.attach (output_latency, 1, 2, row, row+1, xopt, (AttachOptions) 0);
443 label = manage (left_aligned_label (_("samples")));
444 basic_packer.attach (*label, 2, 3, row, row+1, SHRINK, (AttachOptions) 0);
446 /* button spans 2 rows */
448 basic_packer.attach (lm_button, 3, 4, row-1, row+1, xopt, xopt);
451 label = manage (left_aligned_label (_("MIDI System")));
452 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
453 basic_packer.attach (midi_option_combo, 1, 2, row, row + 1, SHRINK, (AttachOptions) 0);
458 EngineControl::build_no_control_notebook ()
460 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
463 using namespace Notebook_Helpers;
465 vector<string> strings;
466 AttachOptions xopt = AttachOptions (FILL|EXPAND);
467 int row = 1; // row zero == backend combo
468 const string msg = string_compose (_("The %1 audio backend was configured and started externally.\nThis limits your control over it."), backend->name());
470 label = manage (new Label);
471 label->set_markup (string_compose ("<span weight=\"bold\" foreground=\"red\">%1</span>", msg));
472 basic_packer.attach (*label, 0, 2, row, row + 1, xopt, (AttachOptions) 0);
475 if (backend->can_change_sample_rate_when_running()) {
476 label = manage (left_aligned_label (_("Sample rate:")));
477 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
478 basic_packer.attach (sample_rate_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
482 if (backend->can_change_buffer_size_when_running()) {
483 label = manage (left_aligned_label (_("Buffer size:")));
484 basic_packer.attach (*label, 0, 1, row, row + 1, xopt, (AttachOptions) 0);
485 basic_packer.attach (buffer_size_combo, 1, 2, row, row + 1, xopt, (AttachOptions) 0);
486 buffer_size_duration_label.set_alignment (0.0); /* left-align */
487 basic_packer.attach (buffer_size_duration_label, 2, 3, row, row+1, xopt, (AttachOptions) 0);
491 connect_disconnect_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::connect_disconnect_click));
493 basic_packer.attach (connect_disconnect_button, 0, 2, row, row+1, FILL, AttachOptions (0));
497 EngineControl::~EngineControl ()
499 ignore_changes = true;
503 EngineControl::disable_latency_tab ()
505 vector<string> empty;
506 set_popdown_strings (lm_output_channel_combo, empty);
507 set_popdown_strings (lm_input_channel_combo, empty);
508 lm_measure_button.set_sensitive (false);
509 lm_use_button.set_sensitive (false);
513 EngineControl::enable_latency_tab ()
515 vector<string> outputs;
516 vector<string> inputs;
518 ARDOUR::AudioEngine::instance()->get_physical_outputs (ARDOUR::DataType::AUDIO, outputs);
519 ARDOUR::AudioEngine::instance()->get_physical_inputs (ARDOUR::DataType::AUDIO, inputs);
521 if (inputs.empty() || outputs.empty()) {
522 MessageDialog msg (_("Your selected audio configuration is playback- or capture-only.\n\nLatency calibration requires playback and capture"));
523 lm_measure_button.set_sensitive (false);
524 notebook.set_current_page (0);
529 if (!outputs.empty()) {
530 set_popdown_strings (lm_output_channel_combo, outputs);
531 lm_output_channel_combo.set_active_text (outputs.front());
532 lm_output_channel_combo.set_sensitive (true);
534 lm_output_channel_combo.set_sensitive (false);
537 if (!inputs.empty()) {
538 set_popdown_strings (lm_input_channel_combo, inputs);
539 lm_input_channel_combo.set_active_text (inputs.front());
540 lm_input_channel_combo.set_sensitive (true);
542 lm_input_channel_combo.set_sensitive (false);
545 lm_measure_button.set_sensitive (true);
549 EngineControl::setup_midi_tab_for_backend ()
551 string backend = backend_combo.get_active_text ();
553 Gtkmm2ext::container_clear (midi_vbox);
555 midi_vbox.set_border_width (12);
556 midi_device_table.set_border_width (12);
558 if (backend == "JACK") {
559 setup_midi_tab_for_jack ();
562 midi_vbox.pack_start (midi_device_table, true, true);
563 midi_vbox.pack_start (midi_refresh_button, false, false);
564 midi_vbox.show_all ();
566 midi_refresh_button.signal_clicked().connect (sigc::mem_fun (*this, &EngineControl::refresh_midi_display));
570 EngineControl::setup_midi_tab_for_jack ()
575 EngineControl::refresh_midi_display ()
577 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
580 vector<string> midi_inputs;
581 vector<string> midi_outputs;
583 AttachOptions xopt = AttachOptions (FILL|EXPAND);
586 Gtkmm2ext::container_clear (midi_device_table);
588 backend->get_physical_inputs (ARDOUR::DataType::MIDI, midi_inputs);
589 backend->get_physical_outputs (ARDOUR::DataType::MIDI, midi_outputs);
591 midi_device_table.set_spacings (6);
592 midi_device_table.set_homogeneous (true);
593 midi_device_table.resize (midi_inputs.size() + midi_outputs.size() + 3, 1);
595 l = manage (new Label);
596 l->set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("MIDI Inputs")));
597 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
598 l->set_alignment (0, 0.5);
602 for (vector<string>::iterator p = midi_inputs.begin(); p != midi_inputs.end(); ++p) {
603 l = manage (new Label ((*p).substr ((*p).find_last_of (':') + 1)));
604 l->set_alignment (0, 0.5);
605 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
610 row++; // extra row of spacing
612 l = manage (new Label);
613 l->set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("MIDI Outputs")));
614 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
615 l->set_alignment (0, 0.5);
619 for (vector<string>::iterator p = midi_outputs.begin(); p != midi_outputs.end(); ++p) {
620 l = manage (new Label ((*p).substr ((*p).find_last_of (':') + 1)));
621 l->set_alignment (0, 0.5);
622 midi_device_table.attach (*l, 0, 1, row, row + 1, xopt, AttachOptions (0));
629 EngineControl::update_sensitivity ()
634 EngineControl::backend_changed ()
636 if (ignore_changes) {
640 string backend_name = backend_combo.get_active_text();
641 boost::shared_ptr<ARDOUR::AudioBackend> backend;
643 if (!(backend = ARDOUR::AudioEngine::instance()->set_backend (backend_name, "ardour", ""))) {
644 /* eh? setting the backend failed... how ? */
648 _have_control = ARDOUR::AudioEngine::instance()->setup_required ();
651 setup_midi_tab_for_backend ();
653 if (backend->requires_driver_selection()) {
654 vector<string> drivers = backend->enumerate_drivers();
656 if (!drivers.empty()) {
658 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
659 set_popdown_strings (driver_combo, drivers);
660 driver_combo.set_active_text (drivers.front());
667 driver_combo.set_sensitive (false);
668 /* this will change the device text which will cause a call to
669 * device changed which will set up parameters
674 vector<string> midi_options = backend->enumerate_midi_options();
676 if (midi_options.size() == 1) {
677 /* only contains the "none" option */
678 midi_option_combo.set_sensitive (false);
681 set_popdown_strings (midi_option_combo, midi_options);
682 midi_option_combo.set_active_text (midi_options.front());
683 midi_option_combo.set_sensitive (true);
685 midi_option_combo.set_sensitive (false);
689 maybe_display_saved_state ();
693 EngineControl::print_channel_count (Gtk::SpinButton* sb)
695 uint32_t cnt = (uint32_t) sb->get_value();
697 sb->set_text (_("all available channels"));
700 snprintf (buf, sizeof (buf), "%d", cnt);
707 EngineControl::list_devices ()
709 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
712 /* now fill out devices, mark sample rates, buffer sizes insensitive */
714 vector<ARDOUR::AudioBackend::DeviceStatus> all_devices = backend->enumerate_devices ();
716 /* NOTE: Ardour currently does not display the "available" field of the
719 * Doing so would require a different GUI widget than the combo
720 * box/popdown that we currently use, since it has no way to list
721 * items that are not selectable. Something more like a popup menu,
722 * which could have unselectable items, would be appropriate.
725 vector<string> available_devices;
727 for (vector<ARDOUR::AudioBackend::DeviceStatus>::const_iterator i = all_devices.begin(); i != all_devices.end(); ++i) {
728 available_devices.push_back (i->name);
731 if (!available_devices.empty()) {
733 update_sensitivity ();
736 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
737 set_popdown_strings (device_combo, available_devices);
738 device_combo.set_active_text (available_devices.front());
743 ok_button->set_sensitive (true);
744 apply_button->set_sensitive (true);
747 sample_rate_combo.set_sensitive (false);
748 buffer_size_combo.set_sensitive (false);
749 input_latency.set_sensitive (false);
750 output_latency.set_sensitive (false);
751 input_channels.set_sensitive (false);
752 output_channels.set_sensitive (false);
753 ok_button->set_sensitive (false);
754 apply_button->set_sensitive (false);
759 EngineControl::driver_changed ()
761 if (ignore_changes) {
765 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
768 backend->set_driver (driver_combo.get_active_text());
771 maybe_display_saved_state ();
775 EngineControl::device_changed ()
777 if (ignore_changes) {
781 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
783 string device_name = device_combo.get_active_text ();
787 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
789 /* don't allow programmatic change to combos to cause a
790 recursive call to this method.
800 sr = backend->available_sample_rates (device_name);
803 sr.push_back (8000.0f);
804 sr.push_back (16000.0f);
805 sr.push_back (32000.0f);
806 sr.push_back (44100.0f);
807 sr.push_back (48000.0f);
808 sr.push_back (88200.0f);
809 sr.push_back (96000.0f);
810 sr.push_back (192000.0f);
811 sr.push_back (384000.0f);
814 for (vector<float>::const_iterator x = sr.begin(); x != sr.end(); ++x) {
815 s.push_back (rate_as_string (*x));
816 if (*x == _desired_sample_rate) {
822 sample_rate_combo.set_sensitive (true);
823 set_popdown_strings (sample_rate_combo, s);
825 if (desired.empty()) {
826 sample_rate_combo.set_active_text (rate_as_string (backend->default_sample_rate()));
828 sample_rate_combo.set_active_text (desired);
832 sample_rate_combo.set_sensitive (false);
840 bs = backend->available_buffer_sizes(device_name);
841 } else if (backend->can_change_buffer_size_when_running()) {
855 for (vector<uint32_t>::const_iterator x = bs.begin(); x != bs.end(); ++x) {
856 s.push_back (bufsize_as_string (*x));
860 buffer_size_combo.set_sensitive (true);
861 set_popdown_strings (buffer_size_combo, s);
863 buffer_size_combo.set_active_text (bufsize_as_string (backend->default_buffer_size()));
864 show_buffer_duration ();
866 buffer_size_combo.set_sensitive (false);
869 /* XXX theoretically need to set min + max channel counts here
872 manage_control_app_sensitivity ();
875 /* pick up any saved state for this device */
877 maybe_display_saved_state ();
881 EngineControl::bufsize_as_string (uint32_t sz)
883 /* Translators: "samples" is always plural here, so no
884 need for plural+singular forms.
887 snprintf (buf, sizeof (buf), _("%u samples"), sz);
892 EngineControl::sample_rate_changed ()
894 if (ignore_changes) {
898 /* reset the strings for buffer size to show the correct msec value
899 (reflecting the new sample rate).
902 show_buffer_duration ();
908 EngineControl::buffer_size_changed ()
910 if (ignore_changes) {
914 show_buffer_duration ();
919 EngineControl::show_buffer_duration ()
922 /* buffer sizes - convert from just samples to samples + msecs for
923 * the displayed string
926 string bs_text = buffer_size_combo.get_active_text ();
927 uint32_t samples = atoi (bs_text); /* will ignore trailing text */
928 uint32_t rate = get_rate();
930 /* Translators: "msecs" is ALWAYS plural here, so we do not
931 need singular form as well.
933 /* Developers: note the hard-coding of a double buffered model
934 in the (2 * samples) computation of latency. we always start
935 the audiobackend in this configuration.
938 snprintf (buf, sizeof (buf), _("(%.1f msecs)"), (2 * samples) / (rate/1000.0));
939 buffer_size_duration_label.set_text (buf);
943 EngineControl::midi_option_changed ()
945 if (!ignore_changes) {
951 EngineControl::parameter_changed ()
953 if (!ignore_changes) {
958 EngineControl::State*
959 EngineControl::get_matching_state (const string& backend,
960 const string& driver,
961 const string& device)
963 for (StateList::iterator i = states.begin(); i != states.end(); ++i) {
964 if ((*i).backend == backend &&
965 (*i).driver == driver &&
966 (*i).device == device) {
973 EngineControl::State*
974 EngineControl::get_saved_state_for_currently_displayed_backend_and_device ()
976 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
979 return get_matching_state (backend_combo.get_active_text(),
980 (backend->requires_driver_selection() ? (std::string) driver_combo.get_active_text() : string()),
981 device_combo.get_active_text());
985 return get_matching_state (backend_combo.get_active_text(),
987 device_combo.get_active_text());
990 EngineControl::State*
991 EngineControl::save_state ()
993 if (!_have_control) {
997 bool existing = true;
998 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1005 store_state (*state);
1008 states.push_back (*state);
1015 EngineControl::store_state (State& state)
1017 state.backend = get_backend ();
1018 state.driver = get_driver ();
1019 state.device = get_device_name ();
1020 state.sample_rate = get_rate ();
1021 state.buffer_size = get_buffer_size ();
1022 state.input_latency = get_input_latency ();
1023 state.output_latency = get_output_latency ();
1024 state.input_channels = get_input_channels ();
1025 state.output_channels = get_output_channels ();
1026 state.midi_option = get_midi_option ();
1030 EngineControl::maybe_display_saved_state ()
1032 if (!_have_control) {
1036 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1039 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
1041 if (!_desired_sample_rate) {
1042 sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
1044 buffer_size_combo.set_active_text (bufsize_as_string (state->buffer_size));
1045 /* call this explicitly because we're ignoring changes to
1046 the controls at this point.
1048 show_buffer_duration ();
1049 input_latency.set_value (state->input_latency);
1050 output_latency.set_value (state->output_latency);
1052 if (!state->midi_option.empty()) {
1053 midi_option_combo.set_active_text (state->midi_option);
1059 EngineControl::get_state ()
1061 XMLNode* root = new XMLNode ("AudioMIDISetup");
1064 if (!states.empty()) {
1065 XMLNode* state_nodes = new XMLNode ("EngineStates");
1067 for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
1069 XMLNode* node = new XMLNode ("State");
1071 node->add_property ("backend", (*i).backend);
1072 node->add_property ("driver", (*i).driver);
1073 node->add_property ("device", (*i).device);
1074 node->add_property ("sample-rate", (*i).sample_rate);
1075 node->add_property ("buffer-size", (*i).buffer_size);
1076 node->add_property ("input-latency", (*i).input_latency);
1077 node->add_property ("output-latency", (*i).output_latency);
1078 node->add_property ("input-channels", (*i).input_channels);
1079 node->add_property ("output-channels", (*i).output_channels);
1080 node->add_property ("active", (*i).active ? "yes" : "no");
1081 node->add_property ("midi-option", (*i).midi_option);
1083 state_nodes->add_child_nocopy (*node);
1086 root->add_child_nocopy (*state_nodes);
1093 EngineControl::set_state (const XMLNode& root)
1095 XMLNodeList clist, cclist;
1096 XMLNodeConstIterator citer, cciter;
1098 XMLNode* grandchild;
1099 XMLProperty* prop = NULL;
1101 if (root.name() != "AudioMIDISetup") {
1105 clist = root.children();
1109 for (citer = clist.begin(); citer != clist.end(); ++citer) {
1113 if (child->name() != "EngineStates") {
1117 cclist = child->children();
1119 for (cciter = cclist.begin(); cciter != cclist.end(); ++cciter) {
1122 grandchild = *cciter;
1124 if (grandchild->name() != "State") {
1128 if ((prop = grandchild->property ("backend")) == 0) {
1131 state.backend = prop->value ();
1133 if ((prop = grandchild->property ("driver")) == 0) {
1136 state.driver = prop->value ();
1138 if ((prop = grandchild->property ("device")) == 0) {
1141 state.device = prop->value ();
1143 if ((prop = grandchild->property ("sample-rate")) == 0) {
1146 state.sample_rate = atof (prop->value ());
1148 if ((prop = grandchild->property ("buffer-size")) == 0) {
1151 state.buffer_size = atoi (prop->value ());
1153 if ((prop = grandchild->property ("input-latency")) == 0) {
1156 state.input_latency = atoi (prop->value ());
1158 if ((prop = grandchild->property ("output-latency")) == 0) {
1161 state.output_latency = atoi (prop->value ());
1163 if ((prop = grandchild->property ("input-channels")) == 0) {
1166 state.input_channels = atoi (prop->value ());
1168 if ((prop = grandchild->property ("output-channels")) == 0) {
1171 state.output_channels = atoi (prop->value ());
1173 if ((prop = grandchild->property ("active")) == 0) {
1176 state.active = string_is_affirmative (prop->value ());
1178 if ((prop = grandchild->property ("midi-option")) == 0) {
1181 state.midi_option = prop->value ();
1183 states.push_back (state);
1187 /* now see if there was an active state and switch the setup to it */
1189 for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
1193 backend_combo.set_active_text ((*i).backend);
1194 driver_combo.set_active_text ((*i).driver);
1195 device_combo.set_active_text ((*i).device);
1196 sample_rate_combo.set_active_text (rate_as_string ((*i).sample_rate));
1197 buffer_size_combo.set_active_text (bufsize_as_string ((*i).buffer_size));
1198 input_latency.set_value ((*i).input_latency);
1199 output_latency.set_value ((*i).output_latency);
1200 midi_option_combo.set_active_text ((*i).midi_option);
1208 EngineControl::push_state_to_backend (bool start)
1210 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1216 /* figure out what is going to change */
1218 bool restart_required = false;
1219 bool was_running = ARDOUR::AudioEngine::instance()->running();
1220 bool change_driver = false;
1221 bool change_device = false;
1222 bool change_rate = false;
1223 bool change_bufsize = false;
1224 bool change_latency = false;
1225 bool change_channels = false;
1226 bool change_midi = false;
1228 uint32_t ochan = get_output_channels ();
1229 uint32_t ichan = get_input_channels ();
1231 if (_have_control) {
1233 if (started_at_least_once) {
1235 /* we can control the backend */
1237 if (backend->requires_driver_selection()) {
1238 if (get_driver() != backend->driver_name()) {
1239 change_driver = true;
1243 if (get_device_name() != backend->device_name()) {
1244 change_device = true;
1247 if (get_rate() != backend->sample_rate()) {
1251 if (get_buffer_size() != backend->buffer_size()) {
1252 change_bufsize = true;
1255 if (get_midi_option() != backend->midi_option()) {
1259 /* zero-requested channels means "all available" */
1262 ichan = backend->input_channels();
1266 ochan = backend->output_channels();
1269 if (ichan != backend->input_channels()) {
1270 change_channels = true;
1273 if (ochan != backend->output_channels()) {
1274 change_channels = true;
1277 if (get_input_latency() != backend->systemic_input_latency() ||
1278 get_output_latency() != backend->systemic_output_latency()) {
1279 change_latency = true;
1282 /* backend never started, so we have to force a group
1285 change_device = true;
1286 if (backend->requires_driver_selection()) {
1287 change_driver = true;
1290 change_bufsize = true;
1291 change_channels = true;
1292 change_latency = true;
1298 /* we have no control over the backend, meaning that we can
1299 * only possibly change sample rate and buffer size.
1303 if (get_rate() != backend->sample_rate()) {
1304 change_bufsize = true;
1307 if (get_buffer_size() != backend->buffer_size()) {
1308 change_bufsize = true;
1312 if (!_have_control) {
1314 /* We do not have control over the backend, so the best we can
1315 * do is try to change the sample rate and/or bufsize and get
1319 if (change_rate && !backend->can_change_sample_rate_when_running()) {
1323 if (change_bufsize && !backend->can_change_buffer_size_when_running()) {
1328 backend->set_sample_rate (get_rate());
1331 if (change_bufsize) {
1332 backend->set_buffer_size (get_buffer_size());
1336 if (ARDOUR::AudioEngine::instance()->start ()) {
1337 error << string_compose (_("Could not start backend engine %1"), backend->name()) << endmsg;
1347 /* determine if we need to stop the backend before changing parameters */
1349 if (change_driver || change_device || change_channels || change_latency ||
1350 (change_rate && !backend->can_change_sample_rate_when_running()) ||
1352 (change_bufsize && !backend->can_change_buffer_size_when_running())) {
1353 restart_required = true;
1355 restart_required = false;
1360 if (!change_driver && !change_device && !change_channels && !change_latency && !change_midi) {
1361 /* no changes in any parameters that absolutely require a
1362 * restart, so check those that might be changeable without a
1366 if (change_rate && !backend->can_change_sample_rate_when_running()) {
1367 /* can't do this while running ... */
1368 restart_required = true;
1371 if (change_bufsize && !backend->can_change_buffer_size_when_running()) {
1372 /* can't do this while running ... */
1373 restart_required = true;
1379 if (restart_required) {
1380 if (ARDOUR_UI::instance()->disconnect_from_engine ()) {
1387 if (change_driver && backend->set_driver (get_driver())) {
1388 error << string_compose (_("Cannot set driver to %1"), get_driver()) << endmsg;
1391 if (change_device && backend->set_device_name (get_device_name())) {
1392 error << string_compose (_("Cannot set device name to %1"), get_device_name()) << endmsg;
1395 if (change_rate && backend->set_sample_rate (get_rate())) {
1396 error << string_compose (_("Cannot set sample rate to %1"), get_rate()) << endmsg;
1399 if (change_bufsize && backend->set_buffer_size (get_buffer_size())) {
1400 error << string_compose (_("Cannot set buffer size to %1"), get_buffer_size()) << endmsg;
1404 if (change_channels || get_input_channels() == 0 || get_output_channels() == 0) {
1405 if (backend->set_input_channels (get_input_channels())) {
1406 error << string_compose (_("Cannot set input channels to %1"), get_input_channels()) << endmsg;
1409 if (backend->set_output_channels (get_output_channels())) {
1410 error << string_compose (_("Cannot set output channels to %1"), get_output_channels()) << endmsg;
1414 if (change_latency) {
1415 if (backend->set_systemic_input_latency (get_input_latency())) {
1416 error << string_compose (_("Cannot set input latency to %1"), get_input_latency()) << endmsg;
1419 if (backend->set_systemic_output_latency (get_output_latency())) {
1420 error << string_compose (_("Cannot set output latency to %1"), get_output_latency()) << endmsg;
1426 backend->set_midi_option (get_midi_option());
1429 if (start || (was_running && restart_required)) {
1430 if (ARDOUR_UI::instance()->reconnect_to_engine()) {
1441 EngineControl::post_push ()
1443 /* get a pointer to the current state object, creating one if
1447 if (_have_control) {
1448 State* state = get_saved_state_for_currently_displayed_backend_and_device ();
1451 state = save_state ();
1457 for (StateList::iterator i = states.begin(); i != states.end(); ++i) {
1458 (*i).active = false;
1461 /* mark this one active (to be used next time the dialog is
1465 state->active = true;
1467 manage_control_app_sensitivity ();
1470 /* schedule a redisplay of MIDI ports */
1472 Glib::signal_timeout().connect (sigc::bind_return (sigc::mem_fun (*this, &EngineControl::refresh_midi_display), false), 1000);
1477 EngineControl::get_rate () const
1479 float r = atof (sample_rate_combo.get_active_text ());
1480 /* the string may have been translated with an abbreviation for
1481 * thousands, so use a crude heuristic to fix this.
1491 EngineControl::get_buffer_size () const
1493 string txt = buffer_size_combo.get_active_text ();
1496 if (sscanf (txt.c_str(), "%d", &samples) != 1) {
1504 EngineControl::get_midi_option () const
1506 return midi_option_combo.get_active_text();
1510 EngineControl::get_input_channels() const
1512 return (uint32_t) input_channels_adjustment.get_value();
1516 EngineControl::get_output_channels() const
1518 return (uint32_t) output_channels_adjustment.get_value();
1522 EngineControl::get_input_latency() const
1524 return (uint32_t) input_latency_adjustment.get_value();
1528 EngineControl::get_output_latency() const
1530 return (uint32_t) output_latency_adjustment.get_value();
1534 EngineControl::get_backend () const
1536 return backend_combo.get_active_text ();
1540 EngineControl::get_driver () const
1542 return driver_combo.get_active_text ();
1546 EngineControl::get_device_name () const
1548 return device_combo.get_active_text ();
1552 EngineControl::control_app_button_clicked ()
1554 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1560 backend->launch_control_app ();
1564 EngineControl::manage_control_app_sensitivity ()
1566 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1572 string appname = backend->control_app_name();
1574 if (appname.empty()) {
1575 control_app_button.set_sensitive (false);
1577 control_app_button.set_sensitive (true);
1582 EngineControl::set_desired_sample_rate (uint32_t sr)
1584 _desired_sample_rate = sr;
1589 EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
1591 if (page_num == 0) {
1592 cancel_button->set_sensitive (true);
1593 ok_button->set_sensitive (true);
1594 apply_button->set_sensitive (true);
1596 cancel_button->set_sensitive (false);
1597 ok_button->set_sensitive (false);
1598 apply_button->set_sensitive (false);
1601 if (page_num == midi_tab) {
1603 refresh_midi_display ();
1606 if (page_num == latency_tab) {
1609 if (!ARDOUR::AudioEngine::instance()->running()) {
1611 PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
1613 /* save any existing latency values */
1615 uint32_t il = (uint32_t) input_latency.get_value ();
1616 uint32_t ol = (uint32_t) input_latency.get_value ();
1618 /* reset to zero so that our new test instance
1619 will be clean of any existing latency measures.
1622 input_latency.set_value (0);
1623 output_latency.set_value (0);
1627 input_latency.set_value (il);
1628 output_latency.set_value (ol);
1632 if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) {
1633 disable_latency_tab ();
1636 enable_latency_tab ();
1640 ARDOUR::AudioEngine::instance()->stop_latency_detection();
1645 /* latency measurement */
1648 EngineControl::check_latency_measurement ()
1650 MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm ();
1652 if (mtdm->resolve () < 0) {
1653 lm_results.set_markup (string_compose (results_markup, _("No signal detected ")));
1657 if (mtdm->err () > 0.3) {
1663 ARDOUR::framecnt_t const sample_rate = ARDOUR::AudioEngine::instance()->sample_rate();
1665 if (sample_rate == 0) {
1666 lm_results.set_markup (string_compose (results_markup, _("Disconnected from audio engine")));
1667 ARDOUR::AudioEngine::instance()->stop_latency_detection ();
1671 uint32_t frames_total = mtdm->del();
1672 uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
1674 snprintf (buf, sizeof (buf), "%u samples / %.3lf ms", extra, extra * 1000.0f/sample_rate);
1678 if (mtdm->err () > 0.2) {
1680 strcat (buf, _("(signal detection error)"));
1686 strcat (buf, _("(inverted - bad wiring)"));
1691 end_latency_detection ();
1692 lm_use_button.set_sensitive (true);
1693 have_lm_results = true;
1696 lm_results.set_markup (string_compose (results_markup, string_compose (_("Detected roundtrip latency: %1"), buf)));
1702 EngineControl::start_latency_detection ()
1704 ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
1705 ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
1707 if (ARDOUR::AudioEngine::instance()->start_latency_detection () == 0) {
1708 lm_results.set_markup (string_compose (results_markup, _("Detecting ...")));
1709 latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 100);
1710 lm_measure_label.set_text (_("Cancel"));
1711 have_lm_results = false;
1712 lm_use_button.set_sensitive (false);
1713 lm_input_channel_combo.set_sensitive (false);
1714 lm_output_channel_combo.set_sensitive (false);
1720 EngineControl::end_latency_detection ()
1722 latency_timeout.disconnect ();
1723 ARDOUR::AudioEngine::instance()->stop_latency_detection ();
1724 lm_measure_label.set_text (_("Measure"));
1725 if (!have_lm_results) {
1726 lm_results.set_markup (string_compose (results_markup, _("No measurement results yet")));
1728 lm_use_button.set_sensitive (false);
1730 lm_input_channel_combo.set_sensitive (true);
1731 lm_output_channel_combo.set_sensitive (true);
1736 EngineControl::latency_button_clicked ()
1739 start_latency_detection ();
1741 end_latency_detection ();
1746 EngineControl::use_latency_button_clicked ()
1748 MTDM* mtdm = ARDOUR::AudioEngine::instance()->mtdm ();
1754 uint32_t frames_total = mtdm->del();
1755 uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
1756 uint32_t one_way = extra/2;
1758 input_latency_adjustment.set_value (one_way);
1759 output_latency_adjustment.set_value (one_way);
1761 /* back to settings page */
1763 notebook.set_current_page (0);
1767 EngineControl::on_delete_event (GdkEventAny* ev)
1769 if (notebook.get_current_page() == 2) {
1770 /* currently on latency tab - be sure to clean up */
1771 end_latency_detection ();
1773 return ArdourDialog::on_delete_event (ev);
1777 EngineControl::engine_running ()
1779 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1782 buffer_size_combo.set_active_text (bufsize_as_string (backend->buffer_size()));
1783 sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
1785 buffer_size_combo.set_sensitive (true);
1786 sample_rate_combo.set_sensitive (true);
1788 connect_disconnect_button.set_label (string_compose (_("Disconnect from %1"), backend->name()));
1790 started_at_least_once = true;
1794 EngineControl::engine_stopped ()
1796 boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
1799 buffer_size_combo.set_sensitive (false);
1800 connect_disconnect_button.set_label (string_compose (_("Connect to %1"), backend->name()));
1802 sample_rate_combo.set_sensitive (true);
1803 buffer_size_combo.set_sensitive (true);
1807 EngineControl::connect_disconnect_click()
1809 if (ARDOUR::AudioEngine::instance()->running()) {
1810 ARDOUR_UI::instance()->disconnect_from_engine ();
1812 ARDOUR_UI::instance()->reconnect_to_engine ();
1817 EngineControl::calibrate_latency ()
1819 notebook.set_current_page (latency_tab);