2 Copyright (C) 1999-2013 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.
21 #include "gtk2ardour-config.h"
22 #include "gtk2ardour-version.h"
31 #ifndef PLATFORM_WINDOWS
32 #include <sys/resource.h>
42 #include <glib/gstdio.h>
44 #include <gtkmm/messagedialog.h>
45 #include <gtkmm/accelmap.h>
47 #include "pbd/error.h"
48 #include "pbd/basename.h"
49 #include "pbd/compose.h"
50 #include "pbd/failed_constructor.h"
51 #include "pbd/enumwriter.h"
52 #include "pbd/memento_command.h"
53 #include "pbd/openuri.h"
54 #include "pbd/stl_delete.h"
55 #include "pbd/file_utils.h"
56 #include "pbd/localtime_r.h"
57 #include "pbd/pthread_utils.h"
59 #include "gtkmm2ext/application.h"
60 #include "gtkmm2ext/bindings.h"
61 #include "gtkmm2ext/gtk_ui.h"
62 #include "gtkmm2ext/utils.h"
63 #include "gtkmm2ext/click_box.h"
64 #include "gtkmm2ext/fastmeter.h"
65 #include "gtkmm2ext/popup.h"
66 #include "gtkmm2ext/window_title.h"
68 #include "ardour/ardour.h"
69 #include "ardour/audio_backend.h"
70 #include "ardour/audioengine.h"
71 #include "ardour/audiofilesource.h"
72 #include "ardour/automation_watch.h"
73 #include "ardour/diskstream.h"
74 #include "ardour/filename_extensions.h"
75 #include "ardour/filesystem_paths.h"
76 #include "ardour/port.h"
77 #include "ardour/plugin_manager.h"
78 #include "ardour/process_thread.h"
79 #include "ardour/profile.h"
80 #include "ardour/recent_sessions.h"
81 #include "ardour/session_directory.h"
82 #include "ardour/session_route.h"
83 #include "ardour/session_state_utils.h"
84 #include "ardour/session_utils.h"
85 #include "ardour/slave.h"
86 #include "ardour/system_exec.h"
88 #ifdef WINDOWS_VST_SUPPORT
91 #ifdef AUDIOUNIT_SUPPORT
92 #include "ardour/audio_unit.h"
95 #include "timecode/time.h"
97 typedef uint64_t microseconds_t;
101 #include "add_route_dialog.h"
102 #include "ambiguous_file_dialog.h"
103 #include "ardour_ui.h"
104 #include "audio_clock.h"
105 #include "big_clock_window.h"
106 #include "bundle_manager.h"
107 #include "engine_dialog.h"
108 #include "export_video_dialog.h"
109 #include "export_video_infobox.h"
110 #include "gain_meter.h"
111 #include "global_port_matrix.h"
112 #include "gui_object.h"
113 #include "gui_thread.h"
114 #include "keyboard.h"
115 #include "keyeditor.h"
116 #include "location_ui.h"
117 #include "main_clock.h"
118 #include "missing_file_dialog.h"
119 #include "missing_plugin_dialog.h"
120 #include "mixer_ui.h"
121 #include "mouse_cursors.h"
124 #include "pingback.h"
125 #include "processor_box.h"
126 #include "prompter.h"
127 #include "public_editor.h"
128 #include "rc_option_editor.h"
129 #include "route_time_axis.h"
130 #include "route_params_ui.h"
131 #include "save_as_dialog.h"
132 #include "session_dialog.h"
133 #include "session_metadata_dialog.h"
134 #include "session_option_editor.h"
135 #include "shuttle_control.h"
136 #include "speaker_dialog.h"
139 #include "theme_manager.h"
140 #include "time_axis_view_item.h"
143 #include "video_server_dialog.h"
144 #include "add_video_dialog.h"
145 #include "transcode_video_dialog.h"
149 using namespace ARDOUR;
150 using namespace ARDOUR_UI_UTILS;
152 using namespace Gtkmm2ext;
156 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
158 sigc::signal<void, framepos_t, bool, framepos_t> ARDOUR_UI::Clock;
159 sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
163 ask_about_configuration_copy (string const & old_dir, string const & new_dir, int version)
165 MessageDialog msg (string_compose (_("%1 %2.x has discovered configuration files from %1 %3.x.\n\n"
166 "Would you like these files to be copied and used for %1 %2.x?\n\n"
167 "(This will require you to restart %1.)"),
168 PROGRAM_NAME, PROGRAM_VERSION, version),
169 false, /* no markup */
172 true /* modal, though it hardly matters since it is the only window */
175 msg.set_default_response (Gtk::RESPONSE_YES);
178 return (msg.run() == Gtk::RESPONSE_YES);
181 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
183 : Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp)
184 , ui_config (new UIConfiguration)
185 , gui_object_state (new GUIObjectState)
187 , primary_clock (new MainClock (X_("primary"), X_("transport"), true ))
188 , secondary_clock (new MainClock (X_("secondary"), X_("secondary"), false))
192 , big_clock (new AudioClock (X_("bigclock"), false, "big", true, true, false, false))
195 /* start of private members */
200 , _mixer_on_top (false)
201 , first_time_engine_run (true)
205 , roll_controllable (new TransportControllable ("transport roll", *this, TransportControllable::Roll))
206 , stop_controllable (new TransportControllable ("transport stop", *this, TransportControllable::Stop))
207 , goto_start_controllable (new TransportControllable ("transport goto start", *this, TransportControllable::GotoStart))
208 , goto_end_controllable (new TransportControllable ("transport goto end", *this, TransportControllable::GotoEnd))
209 , auto_loop_controllable (new TransportControllable ("transport auto loop", *this, TransportControllable::AutoLoop))
210 , play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection))
211 , rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable))
213 , auto_return_button (ArdourButton::led_default_elements)
214 , follow_edits_button (ArdourButton::led_default_elements)
215 , auto_input_button (ArdourButton::led_default_elements)
217 , auditioning_alert_button (_("Audition"))
218 , solo_alert_button (_("Solo"))
219 , feedback_alert_button (_("Feedback"))
220 , error_alert_button ( ArdourButton::just_led_default_elements )
223 , editor_meter_peak_display()
225 , speaker_config_window (X_("speaker-config"), _("Speaker Configuration"))
226 , key_editor (X_("key-editor"), _("Key Bindings"))
227 , rc_option_editor (X_("rc-options-editor"), _("Preferences"))
228 , add_route_dialog (X_("add-routes"), _("Add Tracks/Busses"))
229 , about (X_("about"), _("About"))
230 , location_ui (X_("locations"), _("Locations"))
231 , route_params (X_("inspector"), _("Tracks and Busses"))
232 , audio_midi_setup (X_("audio-midi-setup"), _("Audio/MIDI Setup"))
233 , export_video_dialog (X_("video-export"), _("Video Export Dialog"))
234 , session_option_editor (X_("session-options-editor"), _("Properties"), boost::bind (&ARDOUR_UI::create_session_option_editor, this))
235 , add_video_dialog (X_("add-video"), _("Add Tracks/Busses"), boost::bind (&ARDOUR_UI::create_add_video_dialog, this))
236 , bundle_manager (X_("bundle-manager"), _("Bundle Manager"), boost::bind (&ARDOUR_UI::create_bundle_manager, this))
237 , big_clock_window (X_("big-clock"), _("Big Clock"), boost::bind (&ARDOUR_UI::create_big_clock_window, this))
238 , audio_port_matrix (X_("audio-connection-manager"), _("Audio Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::AUDIO))
239 , midi_port_matrix (X_("midi-connection-manager"), _("MIDI Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::MIDI))
241 , _status_bar_visibility (X_("status-bar"))
242 , _feedback_exists (false)
243 , _log_not_acknowledged (LogLevelNone)
245 Gtkmm2ext::init(localedir);
247 if (ARDOUR::handle_old_configuration_files (boost::bind (ask_about_configuration_copy, _1, _2, _3))) {
248 MessageDialog msg (string_compose (_("Your configuration files were copied. You can now restart %1."), PROGRAM_NAME), true);
250 /* configuration was modified, exit immediately */
257 _numpad_locate_happening = false;
259 if (theArdourUI == 0) {
263 ui_config->ParameterChanged.connect (sigc::mem_fun (*this, &ARDOUR_UI::parameter_changed));
264 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
265 ui_config->map_parameters (pc);
271 _session_is_new = false;
272 session_selector_window = 0;
273 last_key_press_time = 0;
274 video_server_process = 0;
275 open_session_selector = 0;
276 have_configure_timeout = false;
277 have_disk_speed_dialog_displayed = false;
278 session_loaded = false;
279 ignore_dual_punch = false;
281 roll_button.set_controllable (roll_controllable);
282 stop_button.set_controllable (stop_controllable);
283 goto_start_button.set_controllable (goto_start_controllable);
284 goto_end_button.set_controllable (goto_end_controllable);
285 auto_loop_button.set_controllable (auto_loop_controllable);
286 play_selection_button.set_controllable (play_selection_controllable);
287 rec_button.set_controllable (rec_controllable);
289 roll_button.set_name ("transport button");
290 stop_button.set_name ("transport button");
291 goto_start_button.set_name ("transport button");
292 goto_end_button.set_name ("transport button");
293 auto_loop_button.set_name ("transport button");
294 play_selection_button.set_name ("transport button");
295 rec_button.set_name ("transport recenable button");
296 midi_panic_button.set_name ("transport button");
298 last_configure_time= 0;
301 ARDOUR::Diskstream::DiskOverrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
302 ARDOUR::Diskstream::DiskUnderrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
304 ARDOUR::Session::VersionMismatch.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_format_mismatch, this, _1, _2), gui_context());
306 /* handle dialog requests */
308 ARDOUR::Session::Dialog.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_dialog, this, _1), gui_context());
310 /* handle pending state with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
312 ARDOUR::Session::AskAboutPendingState.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::pending_state_dialog, this));
314 /* handle Audio/MIDI setup when session requires it */
316 ARDOUR::Session::AudioEngineSetupRequired.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::do_audio_midi_setup, this, _1));
318 /* handle sr mismatch with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
320 ARDOUR::Session::AskAboutSampleRateMismatch.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::sr_mismatch_dialog, this, _1, _2));
322 /* handle requests to quit (coming from JACK session) */
324 ARDOUR::Session::Quit.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::finish, this), gui_context ());
326 /* tell the user about feedback */
328 ARDOUR::Session::FeedbackDetected.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::feedback_detected, this), gui_context ());
329 ARDOUR::Session::SuccessfulGraphSort.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::successful_graph_sort, this), gui_context ());
331 /* handle requests to deal with missing files */
333 ARDOUR::Session::MissingFile.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::missing_file, this, _1, _2, _3));
335 /* and ambiguous files */
337 ARDOUR::FileSource::AmbiguousFileName.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::ambiguous_file, this, _1, _2));
339 /* also plugin scan messages */
340 ARDOUR::PluginScanMessage.connect (forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::plugin_scan_dialog, this, _1, _2, _3), gui_context());
341 ARDOUR::PluginScanTimeout.connect (forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::plugin_scan_timeout, this, _1), gui_context());
343 ARDOUR::GUIIdle.connect (forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::gui_idle_handler, this), gui_context());
345 Config->ParameterChanged.connect ( forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::set_flat_buttons, this), gui_context() );
348 /* lets get this party started */
350 setup_gtk_ardour_enums ();
353 SessionEvent::create_per_thread_pool ("GUI", 512);
355 /* we like keyboards */
357 keyboard = new ArdourKeyboard(*this);
359 XMLNode* node = ARDOUR_UI::instance()->keyboard_settings();
361 keyboard->set_state (*node, Stateful::loading_state_version);
364 /* we don't like certain modifiers */
365 Bindings::set_ignored_state (GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD3_MASK);
369 TimeAxisViewItem::set_constant_heights ();
371 /* Set this up so that our window proxies can register actions */
373 ActionManager::init ();
375 /* The following must happen after ARDOUR::init() so that Config is set up */
377 const XMLNode* ui_xml = Config->extra_xml (X_("UI"));
380 key_editor.set_state (*ui_xml);
381 rc_option_editor.set_state (*ui_xml);
382 session_option_editor.set_state (*ui_xml);
383 speaker_config_window.set_state (*ui_xml);
384 about.set_state (*ui_xml);
385 add_route_dialog.set_state (*ui_xml);
386 add_video_dialog.set_state (*ui_xml);
387 route_params.set_state (*ui_xml);
388 bundle_manager.set_state (*ui_xml);
389 location_ui.set_state (*ui_xml);
390 big_clock_window.set_state (*ui_xml);
391 audio_port_matrix.set_state (*ui_xml);
392 midi_port_matrix.set_state (*ui_xml);
393 export_video_dialog.set_state (*ui_xml);
396 WM::Manager::instance().register_window (&key_editor);
397 WM::Manager::instance().register_window (&rc_option_editor);
398 WM::Manager::instance().register_window (&session_option_editor);
399 WM::Manager::instance().register_window (&speaker_config_window);
400 WM::Manager::instance().register_window (&about);
401 WM::Manager::instance().register_window (&add_route_dialog);
402 WM::Manager::instance().register_window (&add_video_dialog);
403 WM::Manager::instance().register_window (&route_params);
404 WM::Manager::instance().register_window (&audio_midi_setup);
405 WM::Manager::instance().register_window (&export_video_dialog);
406 WM::Manager::instance().register_window (&bundle_manager);
407 WM::Manager::instance().register_window (&location_ui);
408 WM::Manager::instance().register_window (&big_clock_window);
409 WM::Manager::instance().register_window (&audio_port_matrix);
410 WM::Manager::instance().register_window (&midi_port_matrix);
412 /* Trigger setting up the color scheme and loading the GTK RC file */
414 ARDOUR_UI::config()->load_rc_file (false);
416 _process_thread = new ProcessThread ();
417 _process_thread->init ();
419 DPIReset.connect (sigc::mem_fun (*this, &ARDOUR_UI::resize_text_widgets));
424 GlobalPortMatrixWindow*
425 ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
430 return new GlobalPortMatrixWindow (_session, type);
434 ARDOUR_UI::attach_to_engine ()
436 AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
437 ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
441 ARDOUR_UI::engine_stopped ()
443 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_stopped)
444 ActionManager::set_sensitive (ActionManager::engine_sensitive_actions, false);
445 ActionManager::set_sensitive (ActionManager::engine_opposite_sensitive_actions, true);
449 ARDOUR_UI::engine_running ()
451 if (first_time_engine_run) {
453 first_time_engine_run = false;
456 update_disk_space ();
458 update_sample_rate (AudioEngine::instance()->sample_rate());
459 update_timecode_format ();
463 ARDOUR_UI::engine_halted (const char* reason, bool free_reason)
465 if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
466 /* we can't rely on the original string continuing to exist when we are called
467 again in the GUI thread, so make a copy and note that we need to
470 char *copy = strdup (reason);
471 Gtkmm2ext::UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_halted, this, copy, true));
475 ActionManager::set_sensitive (ActionManager::engine_sensitive_actions, false);
476 ActionManager::set_sensitive (ActionManager::engine_opposite_sensitive_actions, true);
478 update_sample_rate (0);
482 /* if the reason is a non-empty string, it means that the backend was shutdown
483 rather than just Ardour.
486 if (strlen (reason)) {
487 msgstr = string_compose (_("The audio backend was shutdown because:\n\n%1"), reason);
489 msgstr = string_compose (_("\
490 The audio backend has either been shutdown or it\n\
491 disconnected %1 because %1\n\
492 was not fast enough. Try to restart\n\
493 the audio backend and save the session."), PROGRAM_NAME);
496 MessageDialog msg (*editor, msgstr);
497 pop_back_splash (msg);
501 free (const_cast<char*> (reason));
506 ARDOUR_UI::post_engine ()
508 /* Things to be done once (and once ONLY) after we have a backend running in the AudioEngine
510 #ifdef AUDIOUNIT_SUPPORT
512 if (AUPluginInfo::au_get_crashlog(au_msg)) {
513 popup_error(_("Audio Unit Plugin Scan Failed. Automatic AU scanning has been disabled. Please see the log window for further details."));
514 error << _("Audio Unit Plugin Scan Failed:") << endmsg;
515 info << au_msg << endmsg;
519 ARDOUR::init_post_engine ();
521 /* connect to important signals */
523 AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
524 AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
525 AudioEngine::instance()->BufferSizeChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
526 AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
527 AudioEngine::instance()->BecameSilent.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::audioengine_became_silent, this), gui_context());
531 if (setup_windows ()) {
532 throw failed_constructor ();
535 /* Do this after setup_windows (), as that's when the _status_bar_visibility is created */
536 XMLNode* n = Config->extra_xml (X_("UI"));
538 _status_bar_visibility.set_state (*n);
541 check_memory_locking();
543 /* this is the first point at which all the keybindings are available */
545 if (ARDOUR_COMMAND_LINE::show_key_actions) {
546 vector<string> names;
547 vector<string> paths;
548 vector<string> tooltips;
550 vector<AccelKey> bindings;
552 ActionManager::get_all_actions (names, paths, tooltips, keys, bindings);
554 vector<string>::iterator n;
555 vector<string>::iterator k;
556 vector<string>::iterator p;
557 for (n = names.begin(), k = keys.begin(), p = paths.begin(); n != names.end(); ++n, ++k, ++p) {
558 cout << "Action: '" << (*n) << "' bound to '" << (*k) << "' Path: '" << (*p) << "'" << endl;
561 halt_connection.disconnect ();
562 AudioEngine::instance()->stop ();
566 /* this being a GUI and all, we want peakfiles */
568 AudioFileSource::set_build_peakfiles (true);
569 AudioFileSource::set_build_missing_peakfiles (true);
571 /* set default clock modes */
573 if (Profile->get_sae()) {
574 primary_clock->set_mode (AudioClock::BBT);
575 secondary_clock->set_mode (AudioClock::MinSec);
577 primary_clock->set_mode (AudioClock::Timecode);
578 secondary_clock->set_mode (AudioClock::BBT);
581 /* start the time-of-day-clock */
584 /* OS X provides a nearly-always visible wallclock, so don't be stupid */
585 update_wall_clock ();
586 Glib::signal_timeout().connect_seconds (sigc::mem_fun(*this, &ARDOUR_UI::update_wall_clock), 1);
591 Config->ParameterChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
592 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
593 Config->map_parameters (pc);
595 ui_config->map_parameters (pc);
599 ARDOUR_UI::~ARDOUR_UI ()
601 ui_config->save_state();
605 if (getenv ("ARDOUR_RUNNING_UNDER_VALGRIND")) {
606 // don't bother at 'real' exit. the OS cleans up for us.
608 delete primary_clock;
609 delete secondary_clock;
610 delete _process_thread;
611 delete gui_object_state;
612 FastMeter::flush_pattern_cache ();
617 ARDOUR_UI::pop_back_splash (Gtk::Window& win)
619 if (Splash::instance()) {
620 Splash::instance()->pop_back_for (win);
625 ARDOUR_UI::configure_timeout ()
627 if (last_configure_time == 0) {
628 /* no configure events yet */
632 /* force a gap of 0.5 seconds since the last configure event
635 if (get_microseconds() - last_configure_time < 500000) {
638 have_configure_timeout = false;
639 save_ardour_state ();
645 ARDOUR_UI::configure_handler (GdkEventConfigure* /*conf*/)
647 if (have_configure_timeout) {
648 last_configure_time = get_microseconds();
650 Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
651 have_configure_timeout = true;
658 ARDOUR_UI::set_transport_controllable_state (const XMLNode& node)
660 const XMLProperty* prop;
662 if ((prop = node.property ("roll")) != 0) {
663 roll_controllable->set_id (prop->value());
665 if ((prop = node.property ("stop")) != 0) {
666 stop_controllable->set_id (prop->value());
668 if ((prop = node.property ("goto-start")) != 0) {
669 goto_start_controllable->set_id (prop->value());
671 if ((prop = node.property ("goto-end")) != 0) {
672 goto_end_controllable->set_id (prop->value());
674 if ((prop = node.property ("auto-loop")) != 0) {
675 auto_loop_controllable->set_id (prop->value());
677 if ((prop = node.property ("play-selection")) != 0) {
678 play_selection_controllable->set_id (prop->value());
680 if ((prop = node.property ("rec")) != 0) {
681 rec_controllable->set_id (prop->value());
683 if ((prop = node.property ("shuttle")) != 0) {
684 shuttle_box->controllable()->set_id (prop->value());
689 ARDOUR_UI::get_transport_controllable_state ()
691 XMLNode* node = new XMLNode(X_("TransportControllables"));
694 roll_controllable->id().print (buf, sizeof (buf));
695 node->add_property (X_("roll"), buf);
696 stop_controllable->id().print (buf, sizeof (buf));
697 node->add_property (X_("stop"), buf);
698 goto_start_controllable->id().print (buf, sizeof (buf));
699 node->add_property (X_("goto_start"), buf);
700 goto_end_controllable->id().print (buf, sizeof (buf));
701 node->add_property (X_("goto_end"), buf);
702 auto_loop_controllable->id().print (buf, sizeof (buf));
703 node->add_property (X_("auto_loop"), buf);
704 play_selection_controllable->id().print (buf, sizeof (buf));
705 node->add_property (X_("play_selection"), buf);
706 rec_controllable->id().print (buf, sizeof (buf));
707 node->add_property (X_("rec"), buf);
708 shuttle_box->controllable()->id().print (buf, sizeof (buf));
709 node->add_property (X_("shuttle"), buf);
715 ARDOUR_UI::save_session_at_its_request (std::string snapshot_name)
718 _session->save_state (snapshot_name);
723 ARDOUR_UI::autosave_session ()
725 if (g_main_depth() > 1) {
726 /* inside a recursive main loop,
727 give up because we may not be able to
733 if (!Config->get_periodic_safety_backups()) {
738 _session->maybe_write_autosave();
745 ARDOUR_UI::update_autosave ()
747 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_autosave)
749 if (_session && _session->dirty()) {
750 if (_autosave_connection.connected()) {
751 _autosave_connection.disconnect();
754 _autosave_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &ARDOUR_UI::autosave_session),
755 Config->get_periodic_safety_backup_interval() * 1000);
758 if (_autosave_connection.connected()) {
759 _autosave_connection.disconnect();
765 ARDOUR_UI::check_announcements ()
768 string _annc_filename;
771 _annc_filename = PROGRAM_NAME "_announcements_osx_";
773 _annc_filename = PROGRAM_NAME "_announcements_linux_";
775 _annc_filename.append (VERSIONSTRING);
777 std::string path = Glib::build_filename (user_config_directory(), _annc_filename);
778 std::ifstream announce_file (path.c_str());
779 if ( announce_file.fail() )
780 _announce_string = "";
782 std::stringstream oss;
783 oss << announce_file.rdbuf();
784 _announce_string = oss.str();
787 pingback (VERSIONSTRING, path);
792 ARDOUR_UI::starting ()
794 Application* app = Application::instance ();
796 bool brand_new_user = ArdourStartup::required ();
798 app->ShouldQuit.connect (sigc::mem_fun (*this, &ARDOUR_UI::queue_finish));
799 app->ShouldLoad.connect (sigc::mem_fun (*this, &ARDOUR_UI::load_from_application_api));
801 if (ARDOUR_COMMAND_LINE::check_announcements) {
802 check_announcements ();
807 /* we need to create this early because it may need to set the
808 * audio backend end up.
812 audio_midi_setup.get (true);
814 std::cerr << "audio-midi engine setup failed."<< std::endl;
818 if ((nsm_url = g_getenv ("NSM_URL")) != 0) {
819 nsm = new NSM_Client;
820 if (!nsm->init (nsm_url)) {
821 /* TODO this needs fixing!
822 * waf's obj.target for distro versions: eg ardour4, ardourvst4
823 * Ardour4, Mixbus3 for bundled versions + full path on OSX & windows
824 * argv[0] does not apply since we need the wrapper-script (not the binary itself)
825 * No idea how to address all these.
827 nsm->announce (PROGRAM_NAME, ":dirty:", "ardour4");
830 // wait for announce reply from nsm server
831 for ( i = 0; i < 5000; ++i) {
835 if (nsm->is_active()) {
840 error << _("NSM server did not announce itself") << endmsg;
843 // wait for open command from nsm server
844 for ( i = 0; i < 5000; ++i) {
847 if (nsm->client_id ()) {
853 error << _("NSM: no client ID provided") << endmsg;
857 if (_session && nsm) {
858 _session->set_nsm_state( nsm->is_active() );
860 error << _("NSM: no session created") << endmsg;
864 // nsm requires these actions disabled
865 vector<string> action_names;
866 action_names.push_back("SaveAs");
867 action_names.push_back("Rename");
868 action_names.push_back("New");
869 action_names.push_back("Open");
870 action_names.push_back("Recent");
871 action_names.push_back("Close");
873 for (vector<string>::const_iterator n = action_names.begin(); n != action_names.end(); ++n) {
874 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), (*n).c_str());
876 act->set_sensitive (false);
883 error << _("NSM: initialization failed") << endmsg;
889 if (brand_new_user) {
894 switch (s.response ()) {
895 case Gtk::RESPONSE_OK:
902 #ifdef NO_PLUGIN_STATE
904 ARDOUR::RecentSessions rs;
905 ARDOUR::read_recent_sessions (rs);
907 string path = Glib::build_filename (user_config_directory(), ".iknowaboutfreeversion");
909 if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS) && !rs.empty()) {
911 /* already used Ardour, have sessions ... warn about plugin state */
913 ArdourDialog d (_("Free/Demo Version Warning"), true);
915 Button b (string_compose (_("Subscribe and support development of %1"), PROGRAM_NAME));
916 CheckButton c (_("Don't warn me about this again"));
918 l.set_markup (string_compose (_("<span weight=\"bold\" size=\"large\">%1</span>\n\n<b>%2</b>\n\n<i>%3</i>\n\n%4"),
919 string_compose (_("This is a free/demo version of %1"), PROGRAM_NAME),
920 _("It will not restore OR save any plugin settings"),
921 _("If you load an existing session with plugin settings\n"
922 "they will not be used and will be lost."),
923 _("To get full access to updates without this limitation\n"
924 "consider becoming a subscriber for a low cost every month.")));
925 l.set_justify (JUSTIFY_CENTER);
927 b.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::launch_subscribe));
929 d.get_vbox()->pack_start (l, true, true);
930 d.get_vbox()->pack_start (b, false, false, 12);
931 d.get_vbox()->pack_start (c, false, false, 12);
933 d.add_button (_("Quit now"), RESPONSE_CANCEL);
934 d.add_button (string_compose (_("Continue using %1"), PROGRAM_NAME), RESPONSE_OK);
938 c.signal_toggled().connect (sigc::hide_return (sigc::bind (sigc::ptr_fun (toggle_file_existence), path)));
940 if (d.run () != RESPONSE_OK) {
946 /* go get a session */
948 const bool new_session_required = (ARDOUR_COMMAND_LINE::new_session || brand_new_user);
950 if (get_session_parameters (false, new_session_required, ARDOUR_COMMAND_LINE::load_template)) {
951 std::cerr << "Cannot get session parameters."<< std::endl;
958 goto_editor_window ();
960 WM::Manager::instance().show_visible ();
962 /* We have to do this here since goto_editor_window() ends up calling show_all() on the
963 * editor window, and we may want stuff to be hidden.
965 _status_bar_visibility.update ();
967 BootMessage (string_compose (_("%1 is ready for use"), PROGRAM_NAME));
972 ARDOUR_UI::check_memory_locking ()
974 #if defined(__APPLE__) || defined(PLATFORM_WINDOWS)
975 /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
979 XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"));
981 if (AudioEngine::instance()->is_realtime() && memory_warning_node == 0) {
983 struct rlimit limits;
985 long pages, page_size;
987 size_t pages_len=sizeof(pages);
988 if ((page_size = getpagesize()) < 0 ||
989 sysctlbyname("hw.availpages", &pages, &pages_len, NULL, 0))
991 if ((page_size = sysconf (_SC_PAGESIZE)) < 0 ||(pages = sysconf (_SC_PHYS_PAGES)) < 0)
996 ram = (int64_t) pages * (int64_t) page_size;
999 if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
1003 if (limits.rlim_cur != RLIM_INFINITY) {
1005 if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
1009 _("WARNING: Your system has a limit for maximum amount of locked memory. "
1010 "This might cause %1 to run out of memory before your system "
1011 "runs out of memory. \n\n"
1012 "You can view the memory limit with 'ulimit -l', "
1013 "and it is normally controlled by %2"),
1016 X_("/etc/login.conf")
1018 X_(" /etc/security/limits.conf")
1022 msg.set_default_response (RESPONSE_OK);
1024 VBox* vbox = msg.get_vbox();
1026 CheckButton cb (_("Do not show this window again"));
1027 hbox.pack_start (cb, true, false);
1028 vbox->pack_start (hbox);
1033 pop_back_splash (msg);
1035 editor->ensure_float (msg);
1038 if (cb.get_active()) {
1039 XMLNode node (X_("no-memory-warning"));
1040 Config->add_instant_xml (node);
1045 #endif // !__APPLE__
1050 ARDOUR_UI::queue_finish ()
1052 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::idle_finish));
1056 ARDOUR_UI::idle_finish ()
1059 return false; /* do not call again */
1066 ARDOUR_UI::instance()->video_timeline->sync_session_state();
1068 if (_session->dirty()) {
1069 vector<string> actions;
1070 actions.push_back (_("Don't quit"));
1071 actions.push_back (_("Just quit"));
1072 actions.push_back (_("Save and quit"));
1073 switch (ask_about_saving_session(actions)) {
1078 /* use the default name */
1079 if (save_state_canfail ("")) {
1080 /* failed - don't quit */
1081 MessageDialog msg (*editor,
1082 string_compose (_("\
1083 %1 was unable to save your session.\n\n\
1084 If you still wish to quit, please use the\n\n\
1085 \"Just quit\" option."), PROGRAM_NAME));
1086 pop_back_splash(msg);
1096 second_connection.disconnect ();
1097 point_one_second_connection.disconnect ();
1098 point_zero_something_second_connection.disconnect();
1099 fps_connection.disconnect();
1102 delete ARDOUR_UI::instance()->video_timeline;
1103 ARDOUR_UI::instance()->video_timeline = NULL;
1104 stop_video_server();
1106 /* Save state before deleting the session, as that causes some
1107 windows to be destroyed before their visible state can be
1110 save_ardour_state ();
1112 close_all_dialogs ();
1115 _session->set_clean ();
1116 _session->remove_pending_capture_state ();
1121 halt_connection.disconnect ();
1122 AudioEngine::instance()->stop ();
1123 #ifdef WINDOWS_VST_SUPPORT
1124 fst_stop_threading();
1130 ARDOUR_UI::ask_about_saving_session (const vector<string>& actions)
1132 ArdourDialog window (_("Unsaved Session"));
1133 Gtk::HBox dhbox; // the hbox for the image and text
1134 Gtk::Label prompt_label;
1135 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG));
1139 assert (actions.size() >= 3);
1141 window.add_button (actions[0], RESPONSE_REJECT);
1142 window.add_button (actions[1], RESPONSE_APPLY);
1143 window.add_button (actions[2], RESPONSE_ACCEPT);
1145 window.set_default_response (RESPONSE_ACCEPT);
1147 Gtk::Button noquit_button (msg);
1148 noquit_button.set_name ("EditorGTKButton");
1152 if (_session->snap_name() == _session->name()) {
1153 prompt = string_compose(_("The session \"%1\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
1154 _session->snap_name());
1156 prompt = string_compose(_("The snapshot \"%1\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
1157 _session->snap_name());
1160 prompt_label.set_text (prompt);
1161 prompt_label.set_name (X_("PrompterLabel"));
1162 prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP);
1164 dimage->set_alignment(ALIGN_CENTER, ALIGN_TOP);
1165 dhbox.set_homogeneous (false);
1166 dhbox.pack_start (*dimage, false, false, 5);
1167 dhbox.pack_start (prompt_label, true, false, 5);
1168 window.get_vbox()->pack_start (dhbox);
1170 window.set_name (_("Prompter"));
1171 window.set_modal (true);
1172 window.set_resizable (false);
1175 prompt_label.show();
1180 ResponseType r = (ResponseType) window.run();
1185 case RESPONSE_ACCEPT: // save and get out of here
1187 case RESPONSE_APPLY: // get out of here
1198 ARDOUR_UI::every_second ()
1201 update_buffer_load ();
1202 update_disk_space ();
1203 update_timecode_format ();
1205 if (nsm && nsm->is_active ()) {
1208 if (!_was_dirty && _session->dirty ()) {
1212 else if (_was_dirty && !_session->dirty ()){
1220 ARDOUR_UI::every_point_one_seconds ()
1222 // TODO get rid of this..
1223 // ShuttleControl is updated directly via TransportStateChange signal
1227 ARDOUR_UI::every_point_zero_something_seconds ()
1229 // august 2007: actual update frequency: 25Hz (40ms), not 100Hz
1231 if (editor_meter && ARDOUR_UI::config()->get_show_editor_meter()) {
1232 float mpeak = editor_meter->update_meters();
1233 if (mpeak > editor_meter_max_peak) {
1234 if (mpeak >= ARDOUR_UI::config()->get_meter_peak()) {
1235 editor_meter_peak_display.set_active_state ( Gtkmm2ext::ExplicitActive );
1242 ARDOUR_UI::set_fps_timeout_connection ()
1244 unsigned int interval = 40;
1245 if (!_session) return;
1246 if (_session->timecode_frames_per_second() != 0) {
1247 /* ideally we'll use a select() to sleep and not accumulate
1248 * idle time to provide a regular periodic signal.
1249 * See linux_vst_gui_support.cc 'elapsed_time_ms'.
1250 * However, that'll require a dedicated thread and cross-thread
1251 * signals to the GUI Thread..
1253 interval = floor(500. /* update twice per FPS, since Glib::signal_timeout is very irregular */
1254 * _session->frame_rate() / _session->nominal_frame_rate()
1255 / _session->timecode_frames_per_second()
1257 #ifdef PLATFORM_WINDOWS
1258 // the smallest windows scheduler time-slice is ~15ms.
1259 // periodic GUI timeouts shorter than that will cause
1260 // WaitForSingleObject to spinlock (100% of one CPU Core)
1261 // and gtk never enters idle mode.
1262 // also changing timeBeginPeriod(1) does not affect that in
1263 // any beneficial way, so we just limit the max rate for now.
1264 interval = std::max(30u, interval); // at most ~33Hz.
1266 interval = std::max(8u, interval); // at most 120Hz.
1269 fps_connection.disconnect();
1270 Timers::set_fps_interval (interval);
1274 ARDOUR_UI::update_sample_rate (framecnt_t)
1278 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_sample_rate, ignored)
1280 if (!AudioEngine::instance()->connected()) {
1282 snprintf (buf, sizeof (buf), "%s", _("Audio: <span foreground=\"red\">none</span>"));
1286 framecnt_t rate = AudioEngine::instance()->sample_rate();
1289 /* no sample rate available */
1290 snprintf (buf, sizeof (buf), "%s", _("Audio: <span foreground=\"red\">none</span>"));
1293 if (fmod (rate, 1000.0) != 0.0) {
1294 snprintf (buf, sizeof (buf), _("Audio: <span foreground=\"green\">%.1f kHz / %4.1f ms</span>"),
1295 (float) rate / 1000.0f,
1296 (AudioEngine::instance()->usecs_per_cycle() / 1000.0f));
1298 snprintf (buf, sizeof (buf), _("Audio: <span foreground=\"green\">%" PRId64 " kHz / %4.1f ms</span>"),
1300 (AudioEngine::instance()->usecs_per_cycle() / 1000.0f));
1304 sample_rate_label.set_markup (buf);
1308 ARDOUR_UI::update_format ()
1311 format_label.set_text ("");
1316 s << _("File:") << X_(" <span foreground=\"green\">");
1318 switch (_session->config.get_native_file_header_format ()) {
1344 switch (_session->config.get_native_file_data_format ()) {
1358 format_label.set_markup (s.str ());
1362 ARDOUR_UI::update_cpu_load ()
1366 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1367 should also be changed.
1370 double const c = AudioEngine::instance()->get_dsp_load ();
1371 snprintf (buf, sizeof (buf), _("DSP: <span foreground=\"%s\">%5.1f%%</span>"), c >= 90 ? X_("red") : X_("green"), c);
1372 cpu_load_label.set_markup (buf);
1376 ARDOUR_UI::update_buffer_load ()
1380 uint32_t const playback = _session ? _session->playback_load () : 100;
1381 uint32_t const capture = _session ? _session->capture_load () : 100;
1383 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1384 should also be changed.
1390 _("Buffers: <span foreground=\"green\">p:</span><span foreground=\"%s\">%" PRIu32 "%%</span> "
1391 "<span foreground=\"green\">c:</span><span foreground=\"%s\">%" PRIu32 "%%</span>"),
1392 playback <= 5 ? X_("red") : X_("green"),
1394 capture <= 5 ? X_("red") : X_("green"),
1398 buffer_load_label.set_markup (buf);
1400 buffer_load_label.set_text ("");
1405 ARDOUR_UI::count_recenabled_streams (Route& route)
1407 Track* track = dynamic_cast<Track*>(&route);
1408 if (track && track->record_enabled()) {
1409 rec_enabled_streams += track->n_inputs().n_total();
1414 ARDOUR_UI::update_disk_space()
1416 if (_session == 0) {
1420 boost::optional<framecnt_t> opt_frames = _session->available_capture_duration();
1422 framecnt_t fr = _session->frame_rate();
1425 /* skip update - no SR available */
1430 /* Available space is unknown */
1431 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">Unknown</span>"));
1432 } else if (opt_frames.get_value_or (0) == max_framecnt) {
1433 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
1435 rec_enabled_streams = 0;
1436 _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false);
1438 framecnt_t frames = opt_frames.get_value_or (0);
1440 if (rec_enabled_streams) {
1441 frames /= rec_enabled_streams;
1448 hrs = frames / (fr * 3600);
1451 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">>24 hrs</span>"));
1453 frames -= hrs * fr * 3600;
1454 mins = frames / (fr * 60);
1455 frames -= mins * fr * 60;
1458 bool const low = (hrs == 0 && mins <= 30);
1462 _("Disk: <span foreground=\"%s\">%02dh:%02dm:%02ds</span>"),
1463 low ? X_("red") : X_("green"),
1469 disk_space_label.set_markup (buf);
1473 ARDOUR_UI::update_timecode_format ()
1479 TimecodeSlave* tcslave;
1480 SyncSource sync_src = Config->get_sync_source();
1482 if ((sync_src == LTC || sync_src == MTC) && (tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
1483 matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
1488 snprintf (buf, sizeof (buf), S_("Timecode|TC: <span foreground=\"%s\">%s</span>"),
1489 matching ? X_("green") : X_("red"),
1490 Timecode::timecode_format_name (_session->config.get_timecode_format()).c_str());
1492 snprintf (buf, sizeof (buf), "TC: n/a");
1495 timecode_format_label.set_markup (buf);
1499 ARDOUR_UI::update_wall_clock ()
1503 static int last_min = -1;
1506 tm_now = localtime (&now);
1507 if (last_min != tm_now->tm_min) {
1509 sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
1510 wall_clock_label.set_text (buf);
1511 last_min = tm_now->tm_min;
1518 ARDOUR_UI::redisplay_recent_sessions ()
1520 std::vector<std::string> session_directories;
1521 RecentSessionsSorter cmp;
1523 recent_session_display.set_model (Glib::RefPtr<TreeModel>(0));
1524 recent_session_model->clear ();
1526 ARDOUR::RecentSessions rs;
1527 ARDOUR::read_recent_sessions (rs);
1530 recent_session_display.set_model (recent_session_model);
1534 // sort them alphabetically
1535 sort (rs.begin(), rs.end(), cmp);
1537 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
1538 session_directories.push_back ((*i).second);
1541 for (vector<std::string>::const_iterator i = session_directories.begin();
1542 i != session_directories.end(); ++i)
1544 std::vector<std::string> state_file_paths;
1546 // now get available states for this session
1548 get_state_files_in_directory (*i, state_file_paths);
1550 vector<string> states;
1551 vector<const gchar*> item;
1552 string fullpath = *i;
1554 /* remove any trailing / */
1556 if (fullpath[fullpath.length() - 1] == '/') {
1557 fullpath = fullpath.substr (0, fullpath.length() - 1);
1560 /* check whether session still exists */
1561 if (!Glib::file_test(fullpath.c_str(), Glib::FILE_TEST_EXISTS)) {
1562 /* session doesn't exist */
1566 /* now get available states for this session */
1567 states = Session::possible_states (fullpath);
1569 if (states.empty()) {
1570 /* no state file? */
1574 std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
1576 Gtk::TreeModel::Row row = *(recent_session_model->append());
1578 row[recent_session_columns.fullpath] = fullpath;
1579 row[recent_session_columns.tip] = Glib::Markup::escape_text (fullpath);
1581 if (state_file_names.size() > 1) {
1582 // multiple session files in the session directory - show the directory name.
1583 row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
1586 for (std::vector<std::string>::iterator i2 = state_file_names.begin();
1587 i2 != state_file_names.end(); ++i2)
1590 Gtk::TreeModel::Row child_row = *(recent_session_model->append (row.children()));
1592 child_row[recent_session_columns.visible_name] = *i2;
1593 child_row[recent_session_columns.fullpath] = fullpath;
1594 child_row[recent_session_columns.tip] = Glib::Markup::escape_text (fullpath);
1597 // only a single session file in the directory - show its actual name.
1598 row[recent_session_columns.visible_name] = state_file_names.front ();
1602 recent_session_display.set_tooltip_column(1); // recent_session_columns.tip
1603 recent_session_display.set_model (recent_session_model);
1607 ARDOUR_UI::build_session_selector ()
1609 session_selector_window = new ArdourDialog (_("Recent Sessions"));
1611 Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow);
1613 session_selector_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1614 session_selector_window->add_button (Stock::OPEN, RESPONSE_ACCEPT);
1615 session_selector_window->set_default_response (RESPONSE_ACCEPT);
1616 recent_session_model = TreeStore::create (recent_session_columns);
1617 recent_session_display.set_model (recent_session_model);
1618 recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
1619 recent_session_display.set_headers_visible (false);
1620 recent_session_display.get_selection()->set_mode (SELECTION_BROWSE);
1621 recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
1623 scroller->add (recent_session_display);
1624 scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1626 session_selector_window->set_name ("SessionSelectorWindow");
1627 session_selector_window->set_size_request (200, 400);
1628 session_selector_window->get_vbox()->pack_start (*scroller);
1630 recent_session_display.show();
1635 ARDOUR_UI::recent_session_row_activated (const TreePath& /*path*/, TreeViewColumn* /*col*/)
1637 session_selector_window->response (RESPONSE_ACCEPT);
1641 ARDOUR_UI::open_recent_session ()
1643 bool can_return = (_session != 0);
1645 if (session_selector_window == 0) {
1646 build_session_selector ();
1649 redisplay_recent_sessions ();
1653 ResponseType r = (ResponseType) session_selector_window->run ();
1656 case RESPONSE_ACCEPT:
1660 session_selector_window->hide();
1667 if (recent_session_display.get_selection()->count_selected_rows() == 0) {
1671 session_selector_window->hide();
1673 Gtk::TreeModel::iterator i = recent_session_display.get_selection()->get_selected();
1675 if (i == recent_session_model->children().end()) {
1679 std::string path = (*i)[recent_session_columns.fullpath];
1680 std::string state = (*i)[recent_session_columns.visible_name];
1682 _session_is_new = false;
1684 if (load_session (path, state) == 0) {
1693 ARDOUR_UI::check_audioengine ()
1695 if (!AudioEngine::instance()->connected()) {
1696 MessageDialog msg (string_compose (
1697 _("%1 is not connected to any audio backend.\n"
1698 "You cannot open or close sessions in this condition"),
1700 pop_back_splash (msg);
1708 ARDOUR_UI::open_session ()
1710 if (!check_audioengine()) {
1715 /* popup selector window */
1717 if (open_session_selector == 0) {
1719 /* ardour sessions are folders */
1721 open_session_selector = new Gtk::FileChooserDialog (_("Open Session"), FILE_CHOOSER_ACTION_OPEN);
1722 open_session_selector->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1723 open_session_selector->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
1724 open_session_selector->set_default_response(Gtk::RESPONSE_ACCEPT);
1727 string session_parent_dir = Glib::path_get_dirname(_session->path());
1728 string::size_type last_dir_sep = session_parent_dir.rfind(G_DIR_SEPARATOR);
1729 session_parent_dir = session_parent_dir.substr(0, last_dir_sep);
1730 open_session_selector->set_current_folder(session_parent_dir);
1732 open_session_selector->set_current_folder(Config->get_default_session_parent_dir());
1735 string default_session_folder = Config->get_default_session_parent_dir();
1737 /* add_shortcut_folder throws an exception if the folder being added already has a shortcut */
1738 open_session_selector->add_shortcut_folder (default_session_folder);
1740 catch (Glib::Error & e) {
1741 std::cerr << "open_session_selector->add_shortcut_folder (" << default_session_folder << ") threw Glib::Error " << e.what() << std::endl;
1744 FileFilter session_filter;
1745 session_filter.add_pattern (string_compose(X_("*%1"), ARDOUR::statefile_suffix));
1746 session_filter.set_name (string_compose (_("%1 sessions"), PROGRAM_NAME));
1747 open_session_selector->add_filter (session_filter);
1748 open_session_selector->set_filter (session_filter);
1751 int response = open_session_selector->run();
1752 open_session_selector->hide ();
1755 case RESPONSE_ACCEPT:
1758 open_session_selector->hide();
1762 open_session_selector->hide();
1763 string session_path = open_session_selector->get_filename();
1767 if (session_path.length() > 0) {
1768 if (ARDOUR::find_session (session_path, path, name, isnew) == 0) {
1769 _session_is_new = isnew;
1770 load_session (path, name);
1777 ARDOUR_UI::session_add_mixed_track (const ChanCount& input, const ChanCount& output, RouteGroup* route_group,
1778 uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
1780 list<boost::shared_ptr<MidiTrack> > tracks;
1782 if (_session == 0) {
1783 warning << _("You cannot add a track without a session already loaded.") << endmsg;
1788 tracks = _session->new_midi_track (input, output, instrument, ARDOUR::Normal, route_group, how_many, name_template);
1790 if (tracks.size() != how_many) {
1791 error << string_compose(P_("could not create %1 new mixed track", "could not create %1 new mixed tracks", how_many), how_many) << endmsg;
1796 MessageDialog msg (*editor,
1797 string_compose (_("There are insufficient ports available\n\
1798 to create a new track or bus.\n\
1799 You should save %1, exit and\n\
1800 restart with more ports."), PROGRAM_NAME));
1807 ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
1809 ChanCount one_midi_channel;
1810 one_midi_channel.set (DataType::MIDI, 1);
1813 session_add_mixed_track (one_midi_channel, one_midi_channel, route_group, how_many, name_template, instrument);
1818 ARDOUR_UI::session_add_audio_route (
1820 int32_t input_channels,
1821 int32_t output_channels,
1822 ARDOUR::TrackMode mode,
1823 RouteGroup* route_group,
1825 string const & name_template
1828 list<boost::shared_ptr<AudioTrack> > tracks;
1831 if (_session == 0) {
1832 warning << _("You cannot add a track or bus without a session already loaded.") << endmsg;
1838 tracks = _session->new_audio_track (input_channels, output_channels, mode, route_group, how_many, name_template);
1840 if (tracks.size() != how_many) {
1841 error << string_compose (P_("could not create %1 new audio track", "could not create %1 new audio tracks", how_many), how_many)
1847 routes = _session->new_audio_route (input_channels, output_channels, route_group, how_many, name_template);
1849 if (routes.size() != how_many) {
1850 error << string_compose (P_("could not create %1 new audio bus", "could not create %1 new audio busses", how_many), how_many)
1857 MessageDialog msg (*editor,
1858 string_compose (_("There are insufficient ports available\n\
1859 to create a new track or bus.\n\
1860 You should save %1, exit and\n\
1861 restart with more ports."), PROGRAM_NAME));
1862 pop_back_splash (msg);
1868 ARDOUR_UI::transport_goto_start ()
1871 _session->goto_start();
1873 /* force displayed area in editor to start no matter
1874 what "follow playhead" setting is.
1878 editor->center_screen (_session->current_start_frame ());
1884 ARDOUR_UI::transport_goto_zero ()
1887 _session->request_locate (0);
1889 /* force displayed area in editor to start no matter
1890 what "follow playhead" setting is.
1894 editor->reset_x_origin (0);
1900 ARDOUR_UI::transport_goto_wallclock ()
1902 if (_session && editor) {
1909 localtime_r (&now, &tmnow);
1911 int frame_rate = _session->frame_rate();
1913 if (frame_rate == 0) {
1914 /* no frame rate available */
1918 frames = tmnow.tm_hour * (60 * 60 * frame_rate);
1919 frames += tmnow.tm_min * (60 * frame_rate);
1920 frames += tmnow.tm_sec * frame_rate;
1922 _session->request_locate (frames, _session->transport_rolling ());
1924 /* force displayed area in editor to start no matter
1925 what "follow playhead" setting is.
1929 editor->center_screen (frames);
1935 ARDOUR_UI::transport_goto_end ()
1938 framepos_t const frame = _session->current_end_frame();
1939 _session->request_locate (frame);
1941 /* force displayed area in editor to start no matter
1942 what "follow playhead" setting is.
1946 editor->center_screen (frame);
1952 ARDOUR_UI::transport_stop ()
1958 if (_session->is_auditioning()) {
1959 _session->cancel_audition ();
1963 _session->request_stop (false, true);
1966 /** Check if any tracks are record enabled. If none are, record enable all of them.
1967 * @return true if track record-enabled status was changed, false otherwise.
1970 ARDOUR_UI::trx_record_enable_all_tracks ()
1976 boost::shared_ptr<RouteList> rl = _session->get_tracks ();
1977 bool none_record_enabled = true;
1979 for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
1980 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1983 if (t->record_enabled()) {
1984 none_record_enabled = false;
1989 if (none_record_enabled) {
1990 _session->set_record_enabled (rl, true, Session::rt_cleanup);
1993 return none_record_enabled;
1997 ARDOUR_UI::transport_record (bool roll)
2000 switch (_session->record_status()) {
2001 case Session::Disabled:
2002 if (_session->ntracks() == 0) {
2003 MessageDialog msg (*editor, _("Please create one or more tracks before trying to record.\nYou can do this with the \"Add Track or Bus\" option in the Session menu."));
2007 if (Profile->get_trx()) {
2008 roll = trx_record_enable_all_tracks ();
2010 _session->maybe_enable_record ();
2015 case Session::Recording:
2017 _session->request_stop();
2019 _session->disable_record (false, true);
2023 case Session::Enabled:
2024 _session->disable_record (false, true);
2030 ARDOUR_UI::transport_roll ()
2036 if (_session->is_auditioning()) {
2041 if (_session->config.get_external_sync()) {
2042 switch (Config->get_sync_source()) {
2046 /* transport controlled by the master */
2052 bool rolling = _session->transport_rolling();
2054 if (_session->get_play_loop()) {
2056 /* If loop playback is not a mode, then we should cancel
2057 it when this action is requested. If it is a mode
2058 we just leave it in place.
2061 if (!Config->get_loop_is_mode()) {
2062 /* XXX it is not possible to just leave seamless loop and keep
2063 playing at present (nov 4th 2009)
2065 if (!Config->get_seamless_loop()) {
2066 /* stop loop playback and stop rolling */
2067 _session->request_play_loop (false, true);
2068 } else if (rolling) {
2069 /* stop loop playback but keep rolling */
2070 _session->request_play_loop (false, false);
2074 } else if (_session->get_play_range () ) {
2075 /* stop playing a range if we currently are */
2076 _session->request_play_range (0, true);
2080 _session->request_transport_speed (1.0f);
2085 ARDOUR_UI::get_smart_mode() const
2087 return ( editor->get_smart_mode() );
2092 ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
2099 if (_session->is_auditioning()) {
2100 _session->cancel_audition ();
2104 if (_session->config.get_external_sync()) {
2105 switch (Config->get_sync_source()) {
2109 /* transport controlled by the master */
2114 bool rolling = _session->transport_rolling();
2115 bool affect_transport = true;
2117 if (rolling && roll_out_of_bounded_mode) {
2118 /* drop out of loop/range playback but leave transport rolling */
2119 if (_session->get_play_loop()) {
2120 if (Config->get_seamless_loop()) {
2121 /* the disk buffers contain copies of the loop - we can't
2122 just keep playing, so stop the transport. the user
2123 can restart as they wish.
2125 affect_transport = true;
2127 /* disk buffers are normal, so we can keep playing */
2128 affect_transport = false;
2130 _session->request_play_loop (false, affect_transport);
2131 } else if (_session->get_play_range ()) {
2132 affect_transport = false;
2133 _session->request_play_range (0, true);
2137 if (affect_transport) {
2139 _session->request_stop (with_abort, true);
2141 if (ARDOUR_UI::config()->get_follow_edits() && ( editor->get_selection().time.front().start == _session->transport_frame() ) ) { //if playhead is exactly at the start of a range, we can assume it was placed there by follow_edits
2142 _session->request_play_range (&editor->get_selection().time, true);
2143 _session->set_requested_return_frame( editor->get_selection().time.front().start ); //force an auto-return here
2145 _session->request_transport_speed (1.0f);
2151 ARDOUR_UI::toggle_session_auto_loop ()
2153 Location * looploc = _session->locations()->auto_loop_location();
2155 if (!_session || !looploc) {
2159 if (_session->get_play_loop()) {
2161 /* looping enabled, our job is to disable it */
2163 _session->request_play_loop (false);
2167 /* looping not enabled, our job is to enable it.
2169 loop-is-NOT-mode: this action always starts the transport rolling.
2170 loop-IS-mode: this action simply sets the loop play mechanism, but
2171 does not start transport.
2173 if (Config->get_loop_is_mode()) {
2174 _session->request_play_loop (true, false);
2176 _session->request_play_loop (true, true);
2180 //show the loop markers
2181 looploc->set_hidden (false, this);
2185 ARDOUR_UI::transport_play_selection ()
2191 editor->play_selection ();
2195 ARDOUR_UI::transport_play_preroll ()
2200 editor->play_with_preroll ();
2204 ARDOUR_UI::transport_rewind (int option)
2206 float current_transport_speed;
2209 current_transport_speed = _session->transport_speed();
2211 if (current_transport_speed >= 0.0f) {
2214 _session->request_transport_speed (-1.0f);
2217 _session->request_transport_speed (-4.0f);
2220 _session->request_transport_speed (-0.5f);
2225 _session->request_transport_speed (current_transport_speed * 1.5f);
2231 ARDOUR_UI::transport_forward (int option)
2237 float current_transport_speed = _session->transport_speed();
2239 if (current_transport_speed <= 0.0f) {
2242 _session->request_transport_speed (1.0f);
2245 _session->request_transport_speed (4.0f);
2248 _session->request_transport_speed (0.5f);
2253 _session->request_transport_speed (current_transport_speed * 1.5f);
2258 ARDOUR_UI::toggle_record_enable (uint32_t rid)
2264 boost::shared_ptr<Route> r;
2266 if ((r = _session->route_by_remote_id (rid)) != 0) {
2270 if ((t = dynamic_cast<Track*>(r.get())) != 0) {
2271 t->set_record_enabled (!t->record_enabled(), this);
2277 ARDOUR_UI::map_transport_state ()
2280 auto_loop_button.unset_active_state ();
2281 play_selection_button.unset_active_state ();
2282 roll_button.unset_active_state ();
2283 stop_button.set_active_state (Gtkmm2ext::ExplicitActive);
2287 shuttle_box->map_transport_state ();
2289 float sp = _session->transport_speed();
2295 if (_session->get_play_range()) {
2297 play_selection_button.set_active_state (Gtkmm2ext::ExplicitActive);
2298 roll_button.unset_active_state ();
2299 auto_loop_button.unset_active_state ();
2301 } else if (_session->get_play_loop ()) {
2303 auto_loop_button.set_active (true);
2304 play_selection_button.set_active (false);
2305 if (Config->get_loop_is_mode()) {
2306 roll_button.set_active (true);
2308 roll_button.set_active (false);
2313 roll_button.set_active (true);
2314 play_selection_button.set_active (false);
2315 auto_loop_button.set_active (false);
2318 if (ARDOUR_UI::config()->get_follow_edits()) {
2319 /* light up both roll and play-selection if they are joined */
2320 roll_button.set_active (true);
2321 play_selection_button.set_active (true);
2324 stop_button.set_active (false);
2328 stop_button.set_active (true);
2329 roll_button.set_active (false);
2330 play_selection_button.set_active (false);
2331 if (Config->get_loop_is_mode ()) {
2332 auto_loop_button.set_active (_session->get_play_loop());
2334 auto_loop_button.set_active (false);
2336 update_disk_space ();
2341 ARDOUR_UI::blink_handler (bool blink_on)
2343 transport_rec_enable_blink (blink_on);
2344 solo_blink (blink_on);
2345 sync_blink (blink_on);
2346 audition_blink (blink_on);
2347 feedback_blink (blink_on);
2348 error_blink (blink_on);
2352 ARDOUR_UI::update_clocks ()
2354 if (!_session) return;
2356 if (editor && !editor->dragging_playhead()) {
2357 Clock (_session->audible_frame(), false, editor->get_preferred_edit_position (true)); /* EMIT_SIGNAL */
2362 ARDOUR_UI::start_clocking ()
2364 if (ui_config->get_super_rapid_clock_update()) {
2365 clock_signal_connection = Timers::fps_connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
2367 clock_signal_connection = Timers::rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
2372 ARDOUR_UI::stop_clocking ()
2374 clock_signal_connection.disconnect ();
2378 ARDOUR_UI::save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar)
2382 snprintf (buf, sizeof (buf), _("Copied %" PRId64 " of %" PRId64), cnt, total);
2384 label->set_text (buf);
2385 bar->set_fraction (fraction);
2387 /* process events, redraws, etc. */
2389 while (gtk_events_pending()) {
2390 gtk_main_iteration ();
2393 return true; /* continue with save-as */
2397 ARDOUR_UI::save_session_as ()
2405 switch (sad.run()) {
2406 case Gtk::RESPONSE_OK:
2412 ArdourDialog progress_dialog(_("Save As"), true);
2414 Gtk::ProgressBar progress_bar;
2416 progress_dialog.get_vbox()->pack_start (label);
2417 progress_dialog.get_vbox()->pack_start (progress_bar);
2419 progress_bar.show ();
2423 sa.new_parent_folder = sad.new_parent_folder ();
2424 sa.new_name = sad.new_name ();
2425 sa.switch_to = sad.switch_to();
2426 sa.copy_media = sad.copy_media();
2427 sa.copy_external = sad.copy_external();
2429 /* this signal will be emitted from within this, the calling thread,
2430 * after every file is copied. It provides information on percentage
2431 * complete (in terms of total data to copy), the number of files
2432 * copied so far, and the total number to copy.
2437 sa.Progress.connect_same_thread (c, boost::bind (&ARDOUR_UI::save_as_progress_update, this, _1, _2, _3, &label, &progress_bar));
2439 progress_dialog.show_all ();
2440 progress_dialog.present ();
2442 if (_session->save_as (sa)) {
2444 MessageDialog msg (string_compose (_("Save As failed: %1"), sa.failure_message));
2449 /** Ask the user for the name of a new snapshot and then take it.
2453 ARDOUR_UI::snapshot_session (bool switch_to_it)
2455 ArdourPrompter prompter (true);
2458 prompter.set_name ("Prompter");
2459 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2461 prompter.set_title (_("Save as..."));
2462 prompter.set_prompt (_("New session name"));
2464 prompter.set_title (_("Take Snapshot"));
2465 prompter.set_prompt (_("Name of new snapshot"));
2468 if (!switch_to_it) {
2471 struct tm local_time;
2474 localtime_r (&n, &local_time);
2475 strftime (timebuf, sizeof(timebuf), "%FT%H.%M.%S", &local_time);
2476 prompter.set_initial_text (timebuf);
2480 switch (prompter.run()) {
2481 case RESPONSE_ACCEPT:
2483 prompter.get_result (snapname);
2485 bool do_save = (snapname.length() != 0);
2488 char illegal = Session::session_name_is_legal(snapname);
2490 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2491 "snapshot names may not contain a '%1' character"), illegal));
2497 vector<std::string> p;
2498 get_state_files_in_directory (_session->session_directory().root_path(), p);
2499 vector<string> n = get_file_names_no_extension (p);
2500 if (find (n.begin(), n.end(), snapname) != n.end()) {
2502 ArdourDialog confirm (_("Confirm Snapshot Overwrite"), true);
2503 Label m (_("A snapshot already exists with that name. Do you want to overwrite it?"));
2504 confirm.get_vbox()->pack_start (m, true, true);
2505 confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2506 confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
2507 confirm.show_all ();
2508 switch (confirm.run()) {
2509 case RESPONSE_CANCEL:
2515 save_state (snapname, switch_to_it);
2525 /** Ask the user for a new session name and then rename the session to it.
2529 ARDOUR_UI::rename_session ()
2535 ArdourPrompter prompter (true);
2538 prompter.set_name ("Prompter");
2539 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2540 prompter.set_title (_("Rename Session"));
2541 prompter.set_prompt (_("New session name"));
2544 switch (prompter.run()) {
2545 case RESPONSE_ACCEPT:
2547 prompter.get_result (name);
2549 bool do_rename = (name.length() != 0);
2552 char illegal = Session::session_name_is_legal (name);
2555 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2556 "session names may not contain a '%1' character"), illegal));
2561 switch (_session->rename (name)) {
2563 MessageDialog msg (_("That name is already in use by another directory/folder. Please try again."));
2564 msg.set_position (WIN_POS_MOUSE);
2572 MessageDialog msg (_("Renaming this session failed.\nThings could be seriously messed up at this point"));
2573 msg.set_position (WIN_POS_MOUSE);
2589 ARDOUR_UI::save_state (const string & name, bool switch_to_it)
2591 XMLNode* node = new XMLNode (X_("UI"));
2593 WM::Manager::instance().add_state (*node);
2595 node->add_child_nocopy (gui_object_state->get_state());
2597 _session->add_extra_xml (*node);
2599 if (export_video_dialog) {
2600 _session->add_extra_xml (export_video_dialog->get_state());
2603 save_state_canfail (name, switch_to_it);
2607 ARDOUR_UI::save_state_canfail (string name, bool switch_to_it)
2612 if (name.length() == 0) {
2613 name = _session->snap_name();
2616 if ((ret = _session->save_state (name, false, switch_to_it)) != 0) {
2621 save_ardour_state (); /* XXX cannot fail? yeah, right ... */
2626 ARDOUR_UI::primary_clock_value_changed ()
2629 _session->request_locate (primary_clock->current_time ());
2634 ARDOUR_UI::big_clock_value_changed ()
2637 _session->request_locate (big_clock->current_time ());
2642 ARDOUR_UI::secondary_clock_value_changed ()
2645 _session->request_locate (secondary_clock->current_time ());
2650 ARDOUR_UI::transport_rec_enable_blink (bool onoff)
2652 if (_session == 0) {
2656 if (_session->step_editing()) {
2660 Session::RecordState const r = _session->record_status ();
2661 bool const h = _session->have_rec_enabled_track ();
2663 if (r == Session::Enabled || (r == Session::Recording && !h)) {
2665 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2667 rec_button.set_active_state (Gtkmm2ext::Off);
2669 } else if (r == Session::Recording && h) {
2670 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2672 rec_button.unset_active_state ();
2677 ARDOUR_UI::save_template ()
2679 ArdourPrompter prompter (true);
2682 if (!check_audioengine()) {
2686 prompter.set_name (X_("Prompter"));
2687 prompter.set_title (_("Save Template"));
2688 prompter.set_prompt (_("Name for template:"));
2689 prompter.set_initial_text(_session->name() + _("-template"));
2690 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2692 switch (prompter.run()) {
2693 case RESPONSE_ACCEPT:
2694 prompter.get_result (name);
2696 if (name.length()) {
2697 _session->save_template (name);
2707 ARDOUR_UI::edit_metadata ()
2709 SessionMetadataEditor dialog;
2710 dialog.set_session (_session);
2711 dialog.grab_focus ();
2716 ARDOUR_UI::import_metadata ()
2718 SessionMetadataImporter dialog;
2719 dialog.set_session (_session);
2724 ARDOUR_UI::ask_about_loading_existing_session (const std::string& session_path)
2726 std::string str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
2728 MessageDialog msg (str,
2730 Gtk::MESSAGE_WARNING,
2731 Gtk::BUTTONS_YES_NO,
2735 msg.set_name (X_("OpenExistingDialog"));
2736 msg.set_title (_("Open Existing Session"));
2737 msg.set_wmclass (X_("existing_session"), PROGRAM_NAME);
2738 msg.set_position (Gtk::WIN_POS_CENTER);
2739 pop_back_splash (msg);
2741 switch (msg.run()) {
2750 ARDOUR_UI::build_session_from_dialog (SessionDialog& sd, const std::string& session_path, const std::string& session_name)
2752 BusProfile bus_profile;
2754 if (nsm || Profile->get_sae()) {
2756 bus_profile.master_out_channels = 2;
2757 bus_profile.input_ac = AutoConnectPhysical;
2758 bus_profile.output_ac = AutoConnectMaster;
2759 bus_profile.requested_physical_in = 0; // use all available
2760 bus_profile.requested_physical_out = 0; // use all available
2764 /* get settings from advanced section of NSD */
2766 if (sd.create_master_bus()) {
2767 bus_profile.master_out_channels = (uint32_t) sd.master_channel_count();
2769 bus_profile.master_out_channels = 0;
2772 if (sd.connect_inputs()) {
2773 bus_profile.input_ac = AutoConnectPhysical;
2775 bus_profile.input_ac = AutoConnectOption (0);
2778 bus_profile.output_ac = AutoConnectOption (0);
2780 if (sd.connect_outputs ()) {
2781 if (sd.connect_outs_to_master()) {
2782 bus_profile.output_ac = AutoConnectMaster;
2783 } else if (sd.connect_outs_to_physical()) {
2784 bus_profile.output_ac = AutoConnectPhysical;
2788 bus_profile.requested_physical_in = (uint32_t) sd.input_limit_count();
2789 bus_profile.requested_physical_out = (uint32_t) sd.output_limit_count();
2792 if (build_session (session_path, session_name, bus_profile)) {
2800 ARDOUR_UI::load_from_application_api (const std::string& path)
2802 ARDOUR_COMMAND_LINE::session_name = path;
2804 if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
2805 /* /path/to/foo => /path/to/foo, foo */
2806 load_session (path, basename_nosuffix (path));
2808 /* /path/to/foo/foo.ardour => /path/to/foo, foo */
2809 load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
2813 /** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */
2815 ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, string load_template)
2817 string session_name;
2818 string session_path;
2819 string template_name;
2821 bool likely_new = false;
2822 bool cancel_not_quit;
2824 /* deal with any existing DIRTY session now, rather than later. don't
2825 * treat a non-dirty session this way, so that it stays visible
2826 * as we bring up the new session dialog.
2829 if (_session && ARDOUR_UI::instance()->video_timeline) {
2830 ARDOUR_UI::instance()->video_timeline->sync_session_state();
2833 /* if there is already a session, relabel the button
2834 on the SessionDialog so that we don't Quit directly
2836 cancel_not_quit = (_session != 0);
2838 if (_session && _session->dirty()) {
2839 if (unload_session (false)) {
2840 /* unload cancelled by user */
2843 ARDOUR_COMMAND_LINE::session_name = "";
2846 if (!load_template.empty()) {
2847 should_be_new = true;
2848 template_name = load_template;
2851 session_name = basename_nosuffix (ARDOUR_COMMAND_LINE::session_name);
2852 session_path = ARDOUR_COMMAND_LINE::session_name;
2854 if (!session_path.empty()) {
2855 if (Glib::file_test (session_path.c_str(), Glib::FILE_TEST_EXISTS)) {
2856 if (Glib::file_test (session_path.c_str(), Glib::FILE_TEST_IS_REGULAR)) {
2857 /* session/snapshot file, change path to be dir */
2858 session_path = Glib::path_get_dirname (session_path);
2863 SessionDialog session_dialog (should_be_new, session_name, session_path, load_template, cancel_not_quit);
2867 if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
2869 /* if they named a specific statefile, use it, otherwise they are
2870 just giving a session folder, and we want to use it as is
2871 to find the session.
2874 string::size_type suffix = ARDOUR_COMMAND_LINE::session_name.find (statefile_suffix);
2876 if (suffix != string::npos) {
2877 session_path = Glib::path_get_dirname (ARDOUR_COMMAND_LINE::session_name);
2878 session_name = ARDOUR_COMMAND_LINE::session_name.substr (0, suffix);
2879 session_name = Glib::path_get_basename (session_name);
2881 session_path = ARDOUR_COMMAND_LINE::session_name;
2882 session_name = Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name);
2887 session_dialog.clear_given ();
2890 if (should_be_new || session_name.empty()) {
2891 /* need the dialog to get info from user */
2893 cerr << "run dialog\n";
2895 switch (session_dialog.run()) {
2896 case RESPONSE_ACCEPT:
2899 if (quit_on_cancel) {
2900 // JE - Currently (July 2014) this section can only get reached if the
2901 // user quits from the main 'Session Setup' dialog (i.e. reaching this
2902 // point does NOT indicate an abnormal termination). Therefore, let's
2903 // behave gracefully (i.e. let's do some cleanup) before we call exit()
2905 pthread_cancel_all ();
2913 session_dialog.hide ();
2916 /* if we run the startup dialog again, offer more than just "new session" */
2918 should_be_new = false;
2920 session_name = session_dialog.session_name (likely_new);
2921 session_path = session_dialog.session_folder ();
2927 string::size_type suffix = session_name.find (statefile_suffix);
2929 if (suffix != string::npos) {
2930 session_name = session_name.substr (0, suffix);
2933 /* this shouldn't happen, but we catch it just in case it does */
2935 if (session_name.empty()) {
2939 if (session_dialog.use_session_template()) {
2940 template_name = session_dialog.session_template_name();
2941 _session_is_new = true;
2944 if (session_name[0] == G_DIR_SEPARATOR ||
2945 #ifdef PLATFORM_WINDOWS
2946 (session_name.length() > 3 && session_name[1] == ':' && session_name[2] == G_DIR_SEPARATOR)
2948 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == G_DIR_SEPARATOR) ||
2949 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == G_DIR_SEPARATOR)
2954 /* absolute path or cwd-relative path specified for session name: infer session folder
2955 from what was given.
2958 session_path = Glib::path_get_dirname (session_name);
2959 session_name = Glib::path_get_basename (session_name);
2963 session_path = session_dialog.session_folder();
2965 char illegal = Session::session_name_is_legal (session_name);
2968 MessageDialog msg (session_dialog,
2969 string_compose (_("To ensure compatibility with various systems\n"
2970 "session names may not contain a '%1' character"),
2973 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2978 if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
2981 if (likely_new && !nsm) {
2983 std::string existing = Glib::build_filename (session_path, session_name);
2985 if (!ask_about_loading_existing_session (existing)) {
2986 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2991 _session_is_new = false;
2996 pop_back_splash (session_dialog);
2997 MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
2999 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
3003 char illegal = Session::session_name_is_legal(session_name);
3006 pop_back_splash (session_dialog);
3007 MessageDialog msg (session_dialog, string_compose(_("To ensure compatibility with various systems\n"
3008 "session names may not contain a '%1' character"), illegal));
3010 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
3014 _session_is_new = true;
3017 if (likely_new && template_name.empty()) {
3019 ret = build_session_from_dialog (session_dialog, session_path, session_name);
3023 ret = load_session (session_path, session_name, template_name);
3026 /* not connected to the AudioEngine, so quit to avoid an infinite loop */
3030 if (!ARDOUR_COMMAND_LINE::immediate_save.empty()) {
3031 _session->save_state (ARDOUR_COMMAND_LINE::immediate_save, false);
3035 /* clear this to avoid endless attempts to load the
3039 ARDOUR_COMMAND_LINE::session_name = "";
3047 ARDOUR_UI::close_session()
3049 if (!check_audioengine()) {
3053 if (unload_session (true)) {
3057 ARDOUR_COMMAND_LINE::session_name = "";
3059 if (get_session_parameters (true, false)) {
3063 goto_editor_window ();
3066 /** @param snap_name Snapshot name (without .ardour suffix).
3067 * @return -2 if the load failed because we are not connected to the AudioEngine.
3070 ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, std::string mix_template)
3072 Session *new_session;
3077 unload_status = unload_session ();
3079 if (unload_status < 0) {
3081 } else if (unload_status > 0) {
3087 session_loaded = false;
3089 loading_message (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
3092 new_session = new Session (*AudioEngine::instance(), path, snap_name, 0, mix_template);
3095 /* this one is special */
3097 catch (AudioEngine::PortRegistrationFailure& err) {
3099 MessageDialog msg (err.what(),
3102 Gtk::BUTTONS_CLOSE);
3104 msg.set_title (_("Port Registration Error"));
3105 msg.set_secondary_text (_("Click the Close button to try again."));
3106 msg.set_position (Gtk::WIN_POS_CENTER);
3107 pop_back_splash (msg);
3110 int response = msg.run ();
3115 case RESPONSE_CANCEL:
3125 MessageDialog msg (string_compose(
3126 _("Session \"%1 (snapshot %2)\" did not load successfully"),
3132 msg.set_title (_("Loading Error"));
3133 msg.set_position (Gtk::WIN_POS_CENTER);
3134 pop_back_splash (msg);
3143 list<string> const u = new_session->unknown_processors ();
3145 MissingPluginDialog d (_session, u);
3150 if (!new_session->writable()) {
3151 MessageDialog msg (_("This session has been opened in read-only mode.\n\nYou will not be able to record or save."),
3156 msg.set_title (_("Read-only Session"));
3157 msg.set_position (Gtk::WIN_POS_CENTER);
3158 pop_back_splash (msg);
3165 /* Now the session been created, add the transport controls */
3166 new_session->add_controllable(roll_controllable);
3167 new_session->add_controllable(stop_controllable);
3168 new_session->add_controllable(goto_start_controllable);
3169 new_session->add_controllable(goto_end_controllable);
3170 new_session->add_controllable(auto_loop_controllable);
3171 new_session->add_controllable(play_selection_controllable);
3172 new_session->add_controllable(rec_controllable);
3174 set_session (new_session);
3176 session_loaded = true;
3178 goto_editor_window ();
3181 _session->set_clean ();
3184 #ifdef WINDOWS_VST_SUPPORT
3185 fst_stop_threading();
3190 #ifdef WINDOWS_VST_SUPPORT
3191 fst_start_threading();
3200 ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name, BusProfile& bus_profile)
3202 Session *new_session;
3205 session_loaded = false;
3206 x = unload_session ();
3214 _session_is_new = true;
3217 new_session = new Session (*AudioEngine::instance(), path, snap_name, &bus_profile);
3222 MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
3223 pop_back_splash (msg);
3228 /* Give the new session the default GUI state, if such things exist */
3231 n = Config->instant_xml (X_("Editor"));
3233 n->remove_nodes_and_delete ("Selection"); // no not apply selection to new sessions.
3234 new_session->add_instant_xml (*n, false);
3236 n = Config->instant_xml (X_("Mixer"));
3238 new_session->add_instant_xml (*n, false);
3241 /* Put the playhead at 0 and scroll fully left */
3242 n = new_session->instant_xml (X_("Editor"));
3244 n->add_property (X_("playhead"), X_("0"));
3245 n->add_property (X_("left-frame"), X_("0"));
3248 set_session (new_session);
3250 session_loaded = true;
3252 new_session->save_state(new_session->name());
3258 ARDOUR_UI::launch_chat ()
3261 open_uri("http://webchat.freenode.net/?channels=ardour-osx");
3262 #elif defined PLATFORM_WINDOWS
3263 open_uri("http://webchat.freenode.net/?channels=ardour-windows");
3265 open_uri("http://webchat.freenode.net/?channels=ardour");
3270 ARDOUR_UI::launch_manual ()
3272 PBD::open_uri (Config->get_tutorial_manual_url());
3276 ARDOUR_UI::launch_reference ()
3278 PBD::open_uri (Config->get_reference_manual_url());
3282 ARDOUR_UI::launch_tracker ()
3284 PBD::open_uri ("http://tracker.ardour.org/bug_report_page.php");
3288 ARDOUR_UI::launch_subscribe ()
3290 PBD::open_uri ("https://community.ardour.org/s/subscribe");
3294 ARDOUR_UI::launch_cheat_sheet ()
3297 PBD::open_uri ("http://manual.ardour.org/files/a3_mnemonic_cheat_sheet_osx.pdf");
3299 PBD::open_uri ("http://manual.ardour.org/files/a3_mnemonic_cheatsheet.pdf");
3304 ARDOUR_UI::launch_website ()
3306 PBD::open_uri ("http://ardour.org");
3310 ARDOUR_UI::launch_website_dev ()
3312 PBD::open_uri ("http://ardour.org/development.html");
3316 ARDOUR_UI::launch_forums ()
3318 PBD::open_uri ("https://community.ardour.org/forums");
3322 ARDOUR_UI::launch_howto_report ()
3324 PBD::open_uri ("http://ardour.org/reporting_bugs");
3328 ARDOUR_UI::loading_message (const std::string& msg)
3330 if (ARDOUR_COMMAND_LINE::no_splash) {
3338 splash->message (msg);
3342 ARDOUR_UI::show_splash ()
3346 splash = new Splash;
3356 ARDOUR_UI::hide_splash ()
3363 ARDOUR_UI::display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete)
3367 removed = rep.paths.size();
3370 MessageDialog msgd (*editor,
3371 _("No files were ready for clean-up"),
3375 msgd.set_title (_("Clean-up"));
3376 msgd.set_secondary_text (_("If this seems suprising, \n\
3377 check for any existing snapshots.\n\
3378 These may still include regions that\n\
3379 require some unused files to continue to exist."));
3385 ArdourDialog results (_("Clean-up"), true, false);
3387 struct CleanupResultsModelColumns : public Gtk::TreeModel::ColumnRecord {
3388 CleanupResultsModelColumns() {
3392 Gtk::TreeModelColumn<std::string> visible_name;
3393 Gtk::TreeModelColumn<std::string> fullpath;
3397 CleanupResultsModelColumns results_columns;
3398 Glib::RefPtr<Gtk::ListStore> results_model;
3399 Gtk::TreeView results_display;
3401 results_model = ListStore::create (results_columns);
3402 results_display.set_model (results_model);
3403 results_display.append_column (list_title, results_columns.visible_name);
3405 results_display.set_name ("CleanupResultsList");
3406 results_display.set_headers_visible (true);
3407 results_display.set_headers_clickable (false);
3408 results_display.set_reorderable (false);
3410 Gtk::ScrolledWindow list_scroller;
3413 Gtk::HBox dhbox; // the hbox for the image and text
3414 Gtk::HBox ddhbox; // the hbox we eventually pack into the dialog's vbox
3415 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG));
3417 dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
3419 const string dead_directory = _session->session_directory().dead_path();
3422 %1 - number of files removed
3423 %2 - location of "dead"
3424 %3 - size of files affected
3425 %4 - prefix for "bytes" to produce sensible results (e.g. mega, kilo, giga)
3428 const char* bprefix;
3429 double space_adjusted = 0;
3431 if (rep.space < 1000) {
3433 space_adjusted = rep.space;
3434 } else if (rep.space < 1000000) {
3435 bprefix = _("kilo");
3436 space_adjusted = floorf((float)rep.space / 1000.0);
3437 } else if (rep.space < 1000000 * 1000) {
3438 bprefix = _("mega");
3439 space_adjusted = floorf((float)rep.space / (1000.0 * 1000.0));
3441 bprefix = _("giga");
3442 space_adjusted = floorf((float)rep.space / (1000.0 * 1000 * 1000.0));
3446 txt.set_markup (string_compose (P_("\
3447 The following file was deleted from %2,\n\
3448 releasing %3 %4bytes of disk space", "\
3449 The following %1 files were deleted from %2,\n\
3450 releasing %3 %4bytes of disk space", removed),
3451 removed, Glib::Markup::escape_text (dead_directory), space_adjusted, bprefix, PROGRAM_NAME));
3453 txt.set_markup (string_compose (P_("\
3454 The following file was not in use and \n\
3455 has been moved to: %2\n\n\
3456 After a restart of %5\n\n\
3457 <span face=\"mono\">Session -> Clean-up -> Flush Wastebasket</span>\n\n\
3458 will release an additional %3 %4bytes of disk space.\n", "\
3459 The following %1 files were not in use and \n\
3460 have been moved to: %2\n\n\
3461 After a restart of %5\n\n\
3462 <span face=\"mono\">Session -> Clean-up -> Flush Wastebasket</span>\n\n\
3463 will release an additional %3 %4bytes of disk space.\n", removed),
3464 removed, Glib::Markup::escape_text (dead_directory), space_adjusted, bprefix, PROGRAM_NAME));
3467 dhbox.pack_start (*dimage, true, false, 5);
3468 dhbox.pack_start (txt, true, false, 5);
3470 for (vector<string>::iterator i = rep.paths.begin(); i != rep.paths.end(); ++i) {
3471 TreeModel::Row row = *(results_model->append());
3472 row[results_columns.visible_name] = *i;
3473 row[results_columns.fullpath] = *i;
3476 list_scroller.add (results_display);
3477 list_scroller.set_size_request (-1, 150);
3478 list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
3480 dvbox.pack_start (dhbox, true, false, 5);
3481 dvbox.pack_start (list_scroller, true, false, 5);
3482 ddhbox.pack_start (dvbox, true, false, 5);
3484 results.get_vbox()->pack_start (ddhbox, true, false, 5);
3485 results.add_button (Stock::CLOSE, RESPONSE_CLOSE);
3486 results.set_default_response (RESPONSE_CLOSE);
3487 results.set_position (Gtk::WIN_POS_MOUSE);
3489 results_display.show();
3490 list_scroller.show();
3497 //results.get_vbox()->show();
3498 results.set_resizable (false);
3505 ARDOUR_UI::cleanup ()
3507 if (_session == 0) {
3508 /* shouldn't happen: menu item is insensitive */
3513 MessageDialog checker (_("Are you sure you want to clean-up?"),
3515 Gtk::MESSAGE_QUESTION,
3518 checker.set_title (_("Clean-up"));
3520 checker.set_secondary_text(_("Clean-up is a destructive operation.\n\
3521 ALL undo/redo information will be lost if you clean-up.\n\
3522 Clean-up will move all unused files to a \"dead\" location."));
3524 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3525 checker.add_button (_("Clean-up"), RESPONSE_ACCEPT);
3526 checker.set_default_response (RESPONSE_CANCEL);
3528 checker.set_name (_("CleanupDialog"));
3529 checker.set_wmclass (X_("ardour_cleanup"), PROGRAM_NAME);
3530 checker.set_position (Gtk::WIN_POS_MOUSE);
3532 switch (checker.run()) {
3533 case RESPONSE_ACCEPT:
3539 ARDOUR::CleanupReport rep;
3541 editor->prepare_for_cleanup ();
3543 /* do not allow flush until a session is reloaded */
3545 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket"));
3547 act->set_sensitive (false);
3550 if (_session->cleanup_sources (rep)) {
3551 editor->finish_cleanup ();
3555 editor->finish_cleanup ();
3558 display_cleanup_results (rep, _("Cleaned Files"), false);
3562 ARDOUR_UI::flush_trash ()
3564 if (_session == 0) {
3565 /* shouldn't happen: menu item is insensitive */
3569 ARDOUR::CleanupReport rep;
3571 if (_session->cleanup_trash_sources (rep)) {
3575 display_cleanup_results (rep, _("deleted file"), true);
3579 ARDOUR_UI::setup_order_hint (AddRouteDialog::InsertAt place)
3581 uint32_t order_hint = UINT32_MAX;
3583 if (editor->get_selection().tracks.empty()) {
3588 we want the new routes to have their order keys set starting from
3589 the highest order key in the selection + 1 (if available).
3592 if (place == AddRouteDialog::AfterSelection) {
3593 RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView*> (editor->get_selection().tracks.back());
3595 order_hint = rtav->route()->order_key();
3598 } else if (place == AddRouteDialog::BeforeSelection) {
3599 RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView*> (editor->get_selection().tracks.front());
3601 order_hint = rtav->route()->order_key();
3603 } else if (place == AddRouteDialog::First) {
3606 /* leave order_hint at UINT32_MAX */
3609 if (order_hint == UINT32_MAX) {
3610 /** AddRouteDialog::Last or selection with first/last not a RouteTimeAxisView
3611 * not setting an order hint will place new routes last.
3616 _session->set_order_hint (order_hint);
3618 /* create a gap in the existing route order keys to accomodate new routes.*/
3619 boost::shared_ptr <RouteList> rd = _session->get_routes();
3620 for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) {
3621 boost::shared_ptr<Route> rt (*ri);
3623 if (rt->is_monitor()) {
3627 if (rt->order_key () >= order_hint) {
3628 rt->set_order_key (rt->order_key () + add_route_dialog->count());
3634 ARDOUR_UI::add_route (Gtk::Window* /* ignored */)
3642 if (add_route_dialog->is_visible()) {
3643 /* we're already doing this */
3647 ResponseType r = (ResponseType) add_route_dialog->run ();
3649 add_route_dialog->hide();
3652 case RESPONSE_ACCEPT:
3659 if ((count = add_route_dialog->count()) <= 0) {
3663 setup_order_hint(add_route_dialog->insert_at());
3665 string template_path = add_route_dialog->track_template();
3666 DisplaySuspender ds;
3668 if (!template_path.empty()) {
3669 if (add_route_dialog->name_template_is_default()) {
3670 _session->new_route_from_template (count, template_path, string());
3672 _session->new_route_from_template (count, template_path, add_route_dialog->name_template());
3677 ChanCount input_chan= add_route_dialog->channels ();
3678 ChanCount output_chan;
3679 string name_template = add_route_dialog->name_template ();
3680 PluginInfoPtr instrument = add_route_dialog->requested_instrument ();
3681 RouteGroup* route_group = add_route_dialog->route_group ();
3682 AutoConnectOption oac = Config->get_output_auto_connect();
3684 if (oac & AutoConnectMaster) {
3685 output_chan.set (DataType::AUDIO, (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan.n_audio()));
3686 output_chan.set (DataType::MIDI, 0);
3688 output_chan = input_chan;
3691 /* XXX do something with name template */
3693 switch (add_route_dialog->type_wanted()) {
3694 case AddRouteDialog::AudioTrack:
3695 session_add_audio_track (input_chan.n_audio(), output_chan.n_audio(), add_route_dialog->mode(), route_group, count, name_template);
3697 case AddRouteDialog::MidiTrack:
3698 session_add_midi_track (route_group, count, name_template, instrument);
3700 case AddRouteDialog::MixedTrack:
3701 session_add_mixed_track (input_chan, output_chan, route_group, count, name_template, instrument);
3703 case AddRouteDialog::AudioBus:
3704 session_add_audio_bus (input_chan.n_audio(), output_chan.n_audio(), route_group, count, name_template);
3710 ARDOUR_UI::stop_video_server (bool ask_confirm)
3712 if (!video_server_process && ask_confirm) {
3713 warning << string_compose (_("Video-Server was not launched by %1. The request to stop it is ignored."), PROGRAM_NAME) << endmsg;
3715 if (video_server_process) {
3717 ArdourDialog confirm (_("Stop Video-Server"), true);
3718 Label m (_("Do you really want to stop the Video Server?"));
3719 confirm.get_vbox()->pack_start (m, true, true);
3720 confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3721 confirm.add_button (_("Yes, Stop It"), Gtk::RESPONSE_ACCEPT);
3722 confirm.show_all ();
3723 if (confirm.run() == RESPONSE_CANCEL) {
3727 delete video_server_process;
3728 video_server_process =0;
3733 ARDOUR_UI::start_video_server_menu (Gtk::Window* float_window)
3735 ARDOUR_UI::start_video_server( float_window, true);
3739 ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg)
3745 if (ARDOUR_UI::instance()->video_timeline->check_server()) {
3746 if (video_server_process) {
3747 popup_error(_("The Video Server is already started."));
3749 popup_error(_("An external Video Server is configured and can be reached. Not starting a new instance."));
3755 while (!ARDOUR_UI::instance()->video_timeline->check_server()) {
3757 warning << _("Could not connect to the Video Server. Start it or configure its access URL in Preferences.") << endmsg;
3759 VideoServerDialog *video_server_dialog = new VideoServerDialog (_session);
3761 video_server_dialog->set_transient_for (*float_window);
3764 if (!Config->get_show_video_server_dialog() && firsttime < 2) {
3765 video_server_dialog->hide();
3767 ResponseType r = (ResponseType) video_server_dialog->run ();
3768 video_server_dialog->hide();
3769 if (r != RESPONSE_ACCEPT) { return false; }
3770 if (video_server_dialog->show_again()) {
3771 Config->set_show_video_server_dialog(false);
3775 std::string icsd_exec = video_server_dialog->get_exec_path();
3776 std::string icsd_docroot = video_server_dialog->get_docroot();
3777 if (icsd_docroot.empty()) {
3778 #ifndef PLATFORM_WINDOWS
3779 icsd_docroot = X_("/");
3781 icsd_docroot = X_("C:\\");
3786 if (g_lstat (icsd_docroot.c_str(), &sb) != 0 || !S_ISDIR(sb.st_mode)) {
3787 warning << _("Specified docroot is not an existing directory.") << endmsg;
3790 #ifndef PLATFORM_WINDOWS
3791 if ( (g_lstat (icsd_exec.c_str(), &sb) != 0)
3792 || (sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 ) {
3793 warning << _("Given Video Server is not an executable file.") << endmsg;
3797 if ( (g_lstat (icsd_exec.c_str(), &sb) != 0)
3798 || (sb.st_mode & (S_IXUSR)) == 0 ) {
3799 warning << _("Given Video Server is not an executable file.") << endmsg;
3805 argp=(char**) calloc(9,sizeof(char*));
3806 argp[0] = strdup(icsd_exec.c_str());
3807 argp[1] = strdup("-P");
3808 argp[2] = (char*) calloc(16,sizeof(char)); snprintf(argp[2], 16, "%s", video_server_dialog->get_listenaddr().c_str());
3809 argp[3] = strdup("-p");
3810 argp[4] = (char*) calloc(6,sizeof(char)); snprintf(argp[4], 6, "%i", video_server_dialog->get_listenport());
3811 argp[5] = strdup("-C");
3812 argp[6] = (char*) calloc(6,sizeof(char)); snprintf(argp[6], 6, "%i", video_server_dialog->get_cachesize());
3813 argp[7] = strdup(icsd_docroot.c_str());
3815 stop_video_server();
3817 if (icsd_docroot == X_("/") || icsd_docroot == X_("C:\\")) {
3818 Config->set_video_advanced_setup(false);
3820 std::ostringstream osstream;
3821 osstream << "http://localhost:" << video_server_dialog->get_listenport() << "/";
3822 Config->set_video_server_url(osstream.str());
3823 Config->set_video_server_docroot(icsd_docroot);
3824 Config->set_video_advanced_setup(true);
3827 if (video_server_process) {
3828 delete video_server_process;
3831 video_server_process = new ARDOUR::SystemExec(icsd_exec, argp);
3832 if (video_server_process->start()) {
3833 warning << _("Cannot launch the video-server") << endmsg;
3836 int timeout = 120; // 6 sec
3837 while (!ARDOUR_UI::instance()->video_timeline->check_server()) {
3838 Glib::usleep (50000);
3840 if (--timeout <= 0 || !video_server_process->is_running()) break;
3843 warning << _("Video-server was started but does not respond to requests...") << endmsg;
3845 if (!ARDOUR_UI::instance()->video_timeline->check_server_docroot()) {
3846 delete video_server_process;
3847 video_server_process = 0;
3855 ARDOUR_UI::add_video (Gtk::Window* float_window)
3861 if (!start_video_server(float_window, false)) {
3862 warning << _("Could not connect to the Video Server. Start it or configure its access URL in Preferences.") << endmsg;
3867 add_video_dialog->set_transient_for (*float_window);
3870 if (add_video_dialog->is_visible()) {
3871 /* we're already doing this */
3875 ResponseType r = (ResponseType) add_video_dialog->run ();
3876 add_video_dialog->hide();
3877 if (r != RESPONSE_ACCEPT) { return; }
3879 bool local_file, orig_local_file;
3880 std::string path = add_video_dialog->file_name(local_file);
3882 std::string orig_path = path;
3883 orig_local_file = local_file;
3885 bool auto_set_session_fps = add_video_dialog->auto_set_session_fps();
3887 if (local_file && !Glib::file_test(path, Glib::FILE_TEST_EXISTS)) {
3888 warning << string_compose(_("could not open %1"), path) << endmsg;
3891 if (!local_file && path.length() == 0) {
3892 warning << _("no video-file selected") << endmsg;
3896 switch (add_video_dialog->import_option()) {
3897 case VTL_IMPORT_TRANSCODE:
3899 TranscodeVideoDialog *transcode_video_dialog;
3900 transcode_video_dialog = new TranscodeVideoDialog (_session, path);
3901 ResponseType r = (ResponseType) transcode_video_dialog->run ();
3902 transcode_video_dialog->hide();
3903 if (r != RESPONSE_ACCEPT) {
3904 delete transcode_video_dialog;
3907 if (!transcode_video_dialog->get_audiofile().empty()) {
3908 editor->embed_audio_from_video(
3909 transcode_video_dialog->get_audiofile(),
3910 video_timeline->get_offset(),
3911 (transcode_video_dialog->import_option() != VTL_IMPORT_NO_VIDEO)
3914 switch (transcode_video_dialog->import_option()) {
3915 case VTL_IMPORT_TRANSCODED:
3916 path = transcode_video_dialog->get_filename();
3919 case VTL_IMPORT_REFERENCE:
3922 delete transcode_video_dialog;
3925 delete transcode_video_dialog;
3929 case VTL_IMPORT_NONE:
3933 /* strip _session->session_directory().video_path() from video file if possible */
3934 if (local_file && !path.compare(0, _session->session_directory().video_path().size(), _session->session_directory().video_path())) {
3935 path=path.substr(_session->session_directory().video_path().size());
3936 if (path.at(0) == G_DIR_SEPARATOR) {
3937 path=path.substr(1);
3941 video_timeline->set_update_session_fps(auto_set_session_fps);
3942 if (video_timeline->video_file_info(path, local_file)) {
3943 XMLNode* node = new XMLNode(X_("Videotimeline"));
3944 node->add_property (X_("Filename"), path);
3945 node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0"));
3946 node->add_property (X_("LocalFile"), local_file?X_("1"):X_("0"));
3947 if (orig_local_file) {
3948 node->add_property (X_("OriginalVideoFile"), orig_path);
3950 node->remove_property (X_("OriginalVideoFile"));
3952 _session->add_extra_xml (*node);
3953 _session->set_dirty ();
3955 _session->maybe_update_session_range(
3956 std::max(video_timeline->get_offset(), (ARDOUR::frameoffset_t) 0),
3957 std::max(video_timeline->get_offset() + video_timeline->get_duration(), (ARDOUR::frameoffset_t) 0));
3960 if (add_video_dialog->launch_xjadeo() && local_file) {
3961 editor->set_xjadeo_sensitive(true);
3962 editor->toggle_xjadeo_proc(1);
3964 editor->toggle_xjadeo_proc(0);
3966 editor->toggle_ruler_video(true);
3971 ARDOUR_UI::remove_video ()
3973 video_timeline->close_session();
3974 editor->toggle_ruler_video(false);
3977 video_timeline->set_offset_locked(false);
3978 video_timeline->set_offset(0);
3980 /* delete session state */
3981 XMLNode* node = new XMLNode(X_("Videotimeline"));
3982 _session->add_extra_xml(*node);
3983 node = new XMLNode(X_("Videomonitor"));
3984 _session->add_extra_xml(*node);
3985 node = new XMLNode(X_("Videoexport"));
3986 _session->add_extra_xml(*node);
3987 stop_video_server();
3991 ARDOUR_UI::flush_videotimeline_cache (bool localcacheonly)
3993 if (localcacheonly) {
3994 video_timeline->vmon_update();
3996 video_timeline->flush_cache();
3998 editor->queue_visual_videotimeline_update();
4002 ARDOUR_UI::export_video (bool range)
4004 if (ARDOUR::Config->get_show_video_export_info()) {
4005 ExportVideoInfobox infobox (_session);
4006 Gtk::ResponseType rv = (Gtk::ResponseType) infobox.run();
4007 if (infobox.show_again()) {
4008 ARDOUR::Config->set_show_video_export_info(false);
4011 case GTK_RESPONSE_YES:
4012 PBD::open_uri (ARDOUR::Config->get_reference_manual_url() + "/video-timeline/operations/#export");
4018 export_video_dialog->set_session (_session);
4019 export_video_dialog->apply_state(editor->get_selection().time, range);
4020 export_video_dialog->run ();
4021 export_video_dialog->hide ();
4025 ARDOUR_UI::mixer_settings () const
4030 node = _session->instant_xml(X_("Mixer"));
4032 node = Config->instant_xml(X_("Mixer"));
4036 node = new XMLNode (X_("Mixer"));
4043 ARDOUR_UI::editor_settings () const
4048 node = _session->instant_xml(X_("Editor"));
4050 node = Config->instant_xml(X_("Editor"));
4054 if (getenv("ARDOUR_INSTANT_XML_PATH")) {
4055 node = Config->instant_xml(getenv("ARDOUR_INSTANT_XML_PATH"));
4060 node = new XMLNode (X_("Editor"));
4067 ARDOUR_UI::keyboard_settings () const
4071 node = Config->extra_xml(X_("Keyboard"));
4074 node = new XMLNode (X_("Keyboard"));
4081 ARDOUR_UI::create_xrun_marker (framepos_t where)
4084 Location *location = new Location (*_session, where, where, _("xrun"), Location::IsMark);
4085 _session->locations()->add (location);
4090 ARDOUR_UI::halt_on_xrun_message ()
4092 cerr << "HALT on xrun\n";
4093 MessageDialog msg (*editor, _("Recording was stopped because your system could not keep up."));
4098 ARDOUR_UI::xrun_handler (framepos_t where)
4104 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::xrun_handler, where)
4106 if (_session && Config->get_create_xrun_marker() && _session->actively_recording()) {
4107 create_xrun_marker(where);
4110 if (_session && Config->get_stop_recording_on_xrun() && _session->actively_recording()) {
4111 halt_on_xrun_message ();
4116 ARDOUR_UI::disk_overrun_handler ()
4118 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_overrun_handler)
4120 if (!have_disk_speed_dialog_displayed) {
4121 have_disk_speed_dialog_displayed = true;
4122 MessageDialog* msg = new MessageDialog (*editor, string_compose (_("\
4123 The disk system on your computer\n\
4124 was not able to keep up with %1.\n\
4126 Specifically, it failed to write data to disk\n\
4127 quickly enough to keep up with recording.\n"), PROGRAM_NAME));
4128 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
4134 /* TODO: this is getting elaborate enough to warrant being split into a dedicated class */
4135 static MessageDialog *scan_dlg = NULL;
4136 static ProgressBar *scan_pbar = NULL;
4137 static HBox *scan_tbox = NULL;
4140 ARDOUR_UI::cancel_plugin_scan ()
4142 PluginManager::instance().cancel_plugin_scan();
4146 ARDOUR_UI::cancel_plugin_timeout ()
4148 PluginManager::instance().cancel_plugin_timeout();
4153 ARDOUR_UI::plugin_scan_timeout (int timeout)
4155 if (!scan_dlg || !scan_dlg->is_mapped() || !scan_pbar) {
4159 scan_pbar->set_fraction ((float) timeout / (float) Config->get_vst_scan_timeout());
4168 ARDOUR_UI::plugin_scan_dialog (std::string type, std::string plugin, bool can_cancel)
4170 if (type == X_("closeme") && !(scan_dlg && scan_dlg->is_mapped())) {
4174 const bool cancelled = PluginManager::instance().cancelled();
4175 if (type != X_("closeme") && !ui_config->get_show_plugin_scan_window()) {
4176 if (cancelled && scan_dlg->is_mapped()) {
4181 if (cancelled || !can_cancel) {
4186 static Gtk::Button *cancel_button;
4187 static Gtk::Button *timeout_button;
4189 scan_dlg = new MessageDialog("", false, MESSAGE_INFO, BUTTONS_NONE); // TODO manage
4190 VBox* vbox = scan_dlg->get_vbox();
4191 vbox->set_size_request(400,-1);
4192 scan_dlg->set_title (_("Scanning for plugins"));
4194 cancel_button = manage(new Gtk::Button(_("Cancel plugin scan")));
4195 cancel_button->set_name ("EditorGTKButton");
4196 cancel_button->signal_clicked().connect ( mem_fun (*this, &ARDOUR_UI::cancel_plugin_scan) );
4197 cancel_button->show();
4199 scan_dlg->get_vbox()->pack_start ( *cancel_button, PACK_SHRINK);
4201 scan_tbox = manage( new HBox() );
4203 timeout_button = manage(new Gtk::Button(_("Stop Timeout")));
4204 timeout_button->set_name ("EditorGTKButton");
4205 timeout_button->signal_clicked().connect ( mem_fun (*this, &ARDOUR_UI::cancel_plugin_timeout) );
4206 timeout_button->show();
4208 scan_pbar = manage(new ProgressBar());
4209 scan_pbar->set_orientation(Gtk::PROGRESS_RIGHT_TO_LEFT);
4210 scan_pbar->set_text(_("Scan Timeout"));
4213 scan_tbox->pack_start (*scan_pbar, PACK_EXPAND_WIDGET, 4);
4214 scan_tbox->pack_start (*timeout_button, PACK_SHRINK, 4);
4216 scan_dlg->get_vbox()->pack_start (*scan_tbox, PACK_SHRINK, 4);
4219 assert(scan_dlg && scan_tbox && cancel_button);
4221 if (type == X_("closeme")) {
4224 scan_dlg->set_message(type + ": " + Glib::path_get_basename(plugin));
4227 if (!can_cancel || !cancelled) {
4230 cancel_button->set_sensitive(can_cancel && !cancelled);
4236 ARDOUR_UI::gui_idle_handler ()
4239 /* due to idle calls, gtk_events_pending() may always return true */
4240 while (gtk_events_pending() && --timeout) {
4241 gtk_main_iteration ();
4246 ARDOUR_UI::disk_underrun_handler ()
4248 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_underrun_handler)
4250 if (!have_disk_speed_dialog_displayed) {
4251 have_disk_speed_dialog_displayed = true;
4252 MessageDialog* msg = new MessageDialog (
4253 *editor, string_compose (_("The disk system on your computer\n\
4254 was not able to keep up with %1.\n\
4256 Specifically, it failed to read data from disk\n\
4257 quickly enough to keep up with playback.\n"), PROGRAM_NAME));
4258 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
4264 ARDOUR_UI::disk_speed_dialog_gone (int /*ignored_response*/, MessageDialog* msg)
4266 have_disk_speed_dialog_displayed = false;
4271 ARDOUR_UI::session_dialog (std::string msg)
4273 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::session_dialog, msg)
4278 d = new MessageDialog (*editor, msg, false, MESSAGE_INFO, BUTTONS_OK, true);
4280 d = new MessageDialog (msg, false, MESSAGE_INFO, BUTTONS_OK, true);
4289 ARDOUR_UI::pending_state_dialog ()
4291 HBox* hbox = manage (new HBox());
4292 Image* image = manage (new Image (Stock::DIALOG_QUESTION, ICON_SIZE_DIALOG));
4293 ArdourDialog dialog (_("Crash Recovery"), true);
4294 Label message (string_compose (_("\
4295 This session appears to have been in the\n\
4296 middle of recording when %1 or\n\
4297 the computer was shutdown.\n\
4299 %1 can recover any captured audio for\n\
4300 you, or it can ignore it. Please decide\n\
4301 what you would like to do.\n"), PROGRAM_NAME));
4302 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
4303 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
4304 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
4305 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
4306 dialog.add_button (_("Ignore crash data"), RESPONSE_REJECT);
4307 dialog.add_button (_("Recover from crash"), RESPONSE_ACCEPT);
4308 dialog.set_default_response (RESPONSE_ACCEPT);
4309 dialog.set_position (WIN_POS_CENTER);
4314 switch (dialog.run ()) {
4315 case RESPONSE_ACCEPT:
4323 ARDOUR_UI::sr_mismatch_dialog (framecnt_t desired, framecnt_t actual)
4325 HBox* hbox = new HBox();
4326 Image* image = new Image (Stock::DIALOG_WARNING, ICON_SIZE_DIALOG);
4327 ArdourDialog dialog (_("Sample Rate Mismatch"), true);
4328 Label message (string_compose (_("\
4329 This session was created with a sample rate of %1 Hz, but\n\
4330 %2 is currently running at %3 Hz. If you load this session,\n\
4331 audio may be played at the wrong sample rate.\n"), desired, PROGRAM_NAME, actual));
4333 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
4334 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
4335 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
4336 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
4337 dialog.add_button (_("Do not load session"), RESPONSE_REJECT);
4338 dialog.add_button (_("Load session anyway"), RESPONSE_ACCEPT);
4339 dialog.set_default_response (RESPONSE_ACCEPT);
4340 dialog.set_position (WIN_POS_CENTER);
4345 switch (dialog.run()) {
4346 case RESPONSE_ACCEPT:
4356 ARDOUR_UI::disconnect_from_engine ()
4358 /* drop connection to AudioEngine::Halted so that we don't act
4359 * as if the engine unexpectedly shut down
4362 halt_connection.disconnect ();
4364 if (AudioEngine::instance()->stop ()) {
4365 MessageDialog msg (*editor, _("Could not disconnect from Audio/MIDI engine"));
4369 AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
4372 update_sample_rate (0);
4377 ARDOUR_UI::reconnect_to_engine ()
4379 if (AudioEngine::instance()->start ()) {
4380 // TODO somehow make this the topmost window (above any dialogs currently visible)
4382 MessageDialog msg (*editor, _("Could not reconnect to the Audio/MIDI engine"));
4385 MessageDialog msg (_("Could not reconnect to the Audio/MIDI engine"));
4391 update_sample_rate (0);
4396 ARDOUR_UI::use_config ()
4398 XMLNode* node = Config->extra_xml (X_("TransportControllables"));
4400 set_transport_controllable_state (*node);
4405 ARDOUR_UI::update_transport_clocks (framepos_t pos)
4407 if (ui_config->get_primary_clock_delta_edit_cursor()) {
4408 primary_clock->set (pos, false, editor->get_preferred_edit_position (true));
4410 primary_clock->set (pos);
4413 if (ui_config->get_secondary_clock_delta_edit_cursor()) {
4414 secondary_clock->set (pos, false, editor->get_preferred_edit_position (true));
4416 secondary_clock->set (pos);
4419 if (big_clock_window) {
4420 big_clock->set (pos);
4422 ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor(pos);
4426 ARDOUR_UI::step_edit_status_change (bool yn)
4428 // XXX should really store pre-step edit status of things
4429 // we make insensitive
4432 rec_button.set_active_state (Gtkmm2ext::ImplicitActive);
4433 rec_button.set_sensitive (false);
4435 rec_button.unset_active_state ();;
4436 rec_button.set_sensitive (true);
4441 ARDOUR_UI::record_state_changed ()
4443 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed);
4445 if (!_session || !big_clock_window) {
4446 /* why bother - the clock isn't visible */
4450 if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) {
4451 big_clock->set_active (true);
4453 big_clock->set_active (false);
4458 ARDOUR_UI::first_idle ()
4461 _session->allow_auto_play (true);
4465 editor->first_idle();
4468 Keyboard::set_can_save_keybindings (true);
4473 ARDOUR_UI::store_clock_modes ()
4475 XMLNode* node = new XMLNode(X_("ClockModes"));
4477 for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
4478 XMLNode* child = new XMLNode (X_("Clock"));
4480 child->add_property (X_("name"), (*x)->name());
4481 child->add_property (X_("mode"), enum_2_string ((*x)->mode()));
4482 child->add_property (X_("on"), ((*x)->off() ? X_("no") : X_("yes")));
4484 node->add_child_nocopy (*child);
4487 _session->add_extra_xml (*node);
4488 _session->set_dirty ();
4491 ARDOUR_UI::TransportControllable::TransportControllable (std::string name, ARDOUR_UI& u, ToggleType tp)
4492 : Controllable (name), ui (u), type(tp)
4498 ARDOUR_UI::TransportControllable::set_value (double val)
4501 /* do nothing: these are radio-style actions */
4505 const char *action = 0;
4509 action = X_("Roll");
4512 action = X_("Stop");
4515 action = X_("GotoStart");
4518 action = X_("GotoEnd");
4521 action = X_("Loop");
4524 action = X_("PlaySelection");
4527 action = X_("Record");
4537 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", action);
4545 ARDOUR_UI::TransportControllable::get_value (void) const
4572 ARDOUR_UI::setup_profile ()
4574 if (gdk_screen_width() < 1200 || getenv ("ARDOUR_NARROW_SCREEN")) {
4575 Profile->set_small_screen ();
4578 if (g_getenv ("ARDOUR_SAE")) {
4579 Profile->set_sae ();
4580 Profile->set_single_package ();
4583 if (g_getenv ("TRX")) {
4584 Profile->set_trx ();
4587 if (g_getenv ("MIXBUS")) {
4588 Profile->set_mixbus ();
4593 ARDOUR_UI::missing_file (Session*s, std::string str, DataType type)
4595 MissingFileDialog dialog (s, str, type);
4600 int result = dialog.run ();
4607 return 1; // quit entire session load
4610 result = dialog.get_action ();
4616 ARDOUR_UI::ambiguous_file (std::string file, std::vector<std::string> hits)
4618 AmbiguousFileDialog dialog (file, hits);
4624 return dialog.get_which ();
4627 /** Allocate our thread-local buffers */
4629 ARDOUR_UI::get_process_buffers ()
4631 _process_thread->get_buffers ();
4634 /** Drop our thread-local buffers */
4636 ARDOUR_UI::drop_process_buffers ()
4638 _process_thread->drop_buffers ();
4642 ARDOUR_UI::feedback_detected ()
4644 _feedback_exists = true;
4648 ARDOUR_UI::successful_graph_sort ()
4650 _feedback_exists = false;
4654 ARDOUR_UI::midi_panic ()
4657 _session->midi_panic();
4662 ARDOUR_UI::session_format_mismatch (std::string xml_path, std::string backup_path)
4664 const char* start_big = "<span size=\"x-large\" weight=\"bold\">";
4665 const char* end_big = "</span>";
4666 const char* start_mono = "<tt>";
4667 const char* end_mono = "</tt>";
4669 MessageDialog msg (string_compose (_("%4This is a session from an older version of %3%5\n\n"
4670 "%3 has copied the old session file\n\n%6%1%7\n\nto\n\n%6%2%7\n\n"
4671 "From now on, use the -2000 version with older versions of %3"),
4672 xml_path, backup_path, PROGRAM_NAME,
4674 start_mono, end_mono), true);
4681 ARDOUR_UI::reset_peak_display ()
4683 if (!_session || !_session->master_out() || !editor_meter) return;
4684 editor_meter->clear_meters();
4685 editor_meter_max_peak = -INFINITY;
4686 editor_meter_peak_display.set_active_state ( Gtkmm2ext::Off );
4690 ARDOUR_UI::reset_group_peak_display (RouteGroup* group)
4692 if (!_session || !_session->master_out()) return;
4693 if (group == _session->master_out()->route_group()) {
4694 reset_peak_display ();
4699 ARDOUR_UI::reset_route_peak_display (Route* route)
4701 if (!_session || !_session->master_out()) return;
4702 if (_session->master_out().get() == route) {
4703 reset_peak_display ();
4708 ARDOUR_UI::do_audio_midi_setup (uint32_t desired_sample_rate)
4710 audio_midi_setup->set_desired_sample_rate (desired_sample_rate);
4711 audio_midi_setup->set_position (WIN_POS_CENTER);
4713 switch (audio_midi_setup->run()) {
4714 case Gtk::RESPONSE_OK:
4716 case Gtk::RESPONSE_APPLY:
4725 ARDOUR_UI::transport_numpad_timeout ()
4727 _numpad_locate_happening = false;
4728 if (_numpad_timeout_connection.connected() )
4729 _numpad_timeout_connection.disconnect();
4734 ARDOUR_UI::transport_numpad_decimal ()
4736 _numpad_timeout_connection.disconnect();
4738 if (_numpad_locate_happening) {
4739 if (editor) editor->goto_nth_marker(_pending_locate_num - 1);
4740 _numpad_locate_happening = false;
4742 _pending_locate_num = 0;
4743 _numpad_locate_happening = true;
4744 _numpad_timeout_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::transport_numpad_timeout), 2*1000);
4749 ARDOUR_UI::transport_numpad_event (int num)
4751 if ( _numpad_locate_happening ) {
4752 _pending_locate_num = _pending_locate_num*10 + num;
4755 case 0: toggle_roll(false, false); break;
4756 case 1: transport_rewind(1); break;
4757 case 2: transport_forward(1); break;
4758 case 3: transport_record(true); break;
4759 case 4: toggle_session_auto_loop(); break;
4760 case 5: transport_record(false); toggle_session_auto_loop(); break;
4761 case 6: toggle_punch(); break;
4762 case 7: toggle_click(); break;
4763 case 8: toggle_auto_return(); break;
4764 case 9: toggle_follow_edits(); break;
4770 ARDOUR_UI::set_flat_buttons ()
4772 CairoWidget::set_flat_buttons( config()->get_flat_buttons() );
4776 ARDOUR_UI::audioengine_became_silent ()
4778 MessageDialog msg (string_compose (_("This is a free/demo copy of %1. It has just switched to silent mode."), PROGRAM_NAME),
4780 Gtk::MESSAGE_WARNING,
4784 msg.set_title (string_compose (_("%1 is now silent"), PROGRAM_NAME));
4786 Gtk::Label pay_label (string_compose (_("Please consider paying for a copy of %1 - you can pay whatever you want."), PROGRAM_NAME));
4787 Gtk::Label subscribe_label (_("Better yet become a subscriber - subscriptions start at US$1 per month."));
4788 Gtk::Button pay_button (_("Pay for a copy (via the web)"));
4789 Gtk::Button subscribe_button (_("Become a subscriber (via the web)"));
4790 Gtk::HBox pay_button_box;
4791 Gtk::HBox subscribe_button_box;
4793 pay_button_box.pack_start (pay_button, true, false);
4794 subscribe_button_box.pack_start (subscribe_button, true, false);
4796 bool (*openuri)(const char*) = PBD::open_uri; /* this forces selection of the const char* variant of PBD::open_uri(), which we need to avoid ambiguity below */
4798 pay_button.signal_clicked().connect (sigc::hide_return (sigc::bind (sigc::ptr_fun (openuri), (const char*) "https://ardour.org/download")));
4799 subscribe_button.signal_clicked().connect (sigc::hide_return (sigc::bind (sigc::ptr_fun (openuri), (const char*) "https://community.ardour.org/s/subscribe")));
4801 msg.get_vbox()->pack_start (pay_label);
4802 msg.get_vbox()->pack_start (pay_button_box);
4803 msg.get_vbox()->pack_start (subscribe_label);
4804 msg.get_vbox()->pack_start (subscribe_button_box);
4806 msg.get_vbox()->show_all ();
4808 msg.add_button (_("Remain silent"), Gtk::RESPONSE_CANCEL);
4809 msg.add_button (_("Save and quit"), Gtk::RESPONSE_NO);
4810 msg.add_button (_("Give me more time"), Gtk::RESPONSE_YES);
4815 case Gtk::RESPONSE_YES:
4816 AudioEngine::instance()->reset_silence_countdown ();
4819 case Gtk::RESPONSE_NO:
4821 save_state_canfail ("");
4825 case Gtk::RESPONSE_CANCEL:
4827 /* don't reset, save session and exit */