2 Copyright (C) 1999-2002 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 #define __STDC_FORMAT_MACROS 1
34 #include <gtkmm/messagedialog.h>
35 #include <gtkmm/accelmap.h>
37 #include <pbd/error.h>
38 #include <pbd/compose.h>
39 #include <pbd/pathscanner.h>
40 #include <pbd/failed_constructor.h>
41 #include <pbd/enumwriter.h>
42 #include <gtkmm2ext/gtk_ui.h>
43 #include <gtkmm2ext/utils.h>
44 #include <gtkmm2ext/click_box.h>
45 #include <gtkmm2ext/fastmeter.h>
46 #include <gtkmm2ext/stop_signal.h>
47 #include <gtkmm2ext/popup.h>
49 #include <midi++/port.h>
50 #include <midi++/mmc.h>
52 #include <ardour/ardour.h>
53 #include <ardour/port.h>
54 #include <ardour/audioengine.h>
55 #include <ardour/playlist.h>
56 #include <ardour/utils.h>
57 #include <ardour/audio_diskstream.h>
58 #include <ardour/audiofilesource.h>
59 #include <ardour/recent_sessions.h>
60 #include <ardour/session_route.h>
61 #include <ardour/port.h>
62 #include <ardour/audio_track.h>
63 #include <ardour/midi_track.h>
66 #include "ardour_ui.h"
67 #include "public_editor.h"
68 #include "audio_clock.h"
73 #include "keyboard_target.h"
74 #include "add_route_dialog.h"
75 #include "new_session_dialog.h"
78 #include "gui_thread.h"
79 #include "color_manager.h"
83 using namespace ARDOUR;
85 using namespace Gtkmm2ext;
89 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
91 sigc::signal<void,bool> ARDOUR_UI::Blink;
92 sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
93 sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
94 sigc::signal<void,nframes_t> ARDOUR_UI::Clock;
96 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
98 : Gtkmm2ext::UI ("ardour", argcp, argvp, rcfile),
100 primary_clock (X_("primary"), false, X_("TransportClockDisplay"), true, false, true),
101 secondary_clock (X_("secondary"), false, X_("SecondaryClockDisplay"), true, false, true),
102 preroll_clock (X_("preroll"), false, X_("PreRollClock"), true, true),
103 postroll_clock (X_("postroll"), false, X_("PostRollClock"), true, true),
107 adjuster_table (3, 3),
111 preroll_button (_("pre\nroll")),
112 postroll_button (_("post\nroll")),
116 big_clock (X_("bigclock"), false, "BigClockNonRecording", true, false, true),
120 time_master_button (_("time\nmaster")),
122 shuttle_units_button (_("% ")),
124 punch_in_button (_("Punch In")),
125 punch_out_button (_("Punch Out")),
126 auto_return_button (_("Auto Return")),
127 auto_play_button (_("Autuo Play")),
128 auto_input_button (_("Auto Input")),
129 click_button (_("Click")),
130 auditioning_alert_button (_("AUDITION")),
131 solo_alert_button (_("SOLO")),
134 using namespace Gtk::Menu_Helpers;
140 if (theArdourUI == 0) {
146 color_manager = new ColorManager();
148 std::string color_file = ARDOUR::find_config_file("ardour.colors");
150 color_manager->load (color_file);
155 _session_is_new = false;
156 big_clock_window = 0;
157 session_selector_window = 0;
158 last_key_press_time = 0;
159 connection_editor = 0;
160 add_route_dialog = 0;
164 open_session_selector = 0;
165 have_configure_timeout = false;
166 have_disk_overrun_displayed = false;
167 have_disk_underrun_displayed = false;
168 _will_create_new_session_automatically = false;
169 session_loaded = false;
170 last_speed_displayed = -1.0f;
171 keybindings_path = ARDOUR::find_config_file ("ardour.bindings");
173 can_save_keybindings = false;
174 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::first_idle));
176 last_configure_time.tv_sec = 0;
177 last_configure_time.tv_usec = 0;
179 shuttle_grabbed = false;
181 shuttle_max_speed = 8.0f;
183 shuttle_style_menu = 0;
184 shuttle_unit_menu = 0;
186 gettimeofday (&last_peak_grab, 0);
187 gettimeofday (&last_shuttle_request, 0);
189 ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
190 ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
192 /* handle pending state with a dialog */
194 ARDOUR::Session::AskAboutPendingState.connect (mem_fun(*this, &ARDOUR_UI::pending_state_dialog));
196 /* have to wait for AudioEngine and Configuration before proceeding */
200 ARDOUR_UI::set_engine (AudioEngine& e)
204 engine->Stopped.connect (mem_fun(*this, &ARDOUR_UI::engine_stopped));
205 engine->Running.connect (mem_fun(*this, &ARDOUR_UI::engine_running));
206 engine->Halted.connect (mem_fun(*this, &ARDOUR_UI::engine_halted));
207 engine->SampleRateChanged.connect (mem_fun(*this, &ARDOUR_UI::update_sample_rate));
209 ActionManager::init ();
210 new_session_dialog = new NewSessionDialog();
214 keyboard = new Keyboard;
216 if (setup_windows ()) {
217 throw failed_constructor ();
220 if (GTK_ARDOUR::show_key_actions) {
221 vector<string> names;
222 vector<string> paths;
224 vector<AccelKey> bindings;
226 ActionManager::get_all_actions (names, paths, keys, bindings);
228 vector<string>::iterator n;
229 vector<string>::iterator k;
230 for (n = names.begin(), k = keys.begin(); n != names.end(); ++n, ++k) {
231 cerr << "Action: " << (*n) << " bound to " << (*k) << endl;
237 /* start with timecode, metering enabled
240 blink_timeout_tag = -1;
242 /* the global configuration object is now valid */
246 /* this being a GUI and all, we want peakfiles */
248 AudioFileSource::set_build_peakfiles (true);
249 AudioFileSource::set_build_missing_peakfiles (true);
251 if (AudioSource::start_peak_thread ()) {
252 throw failed_constructor();
255 /* listen to clock mode changes */
257 AudioClock::ModeChanged.connect (mem_fun (*this, &ARDOUR_UI::store_clock_modes));
259 /* start the time-of-day-clock */
261 update_wall_clock ();
262 Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::update_wall_clock), 60000);
264 update_disk_space ();
266 update_sample_rate (engine->frame_rate());
268 starting.connect (mem_fun(*this, &ARDOUR_UI::startup));
269 stopping.connect (mem_fun(*this, &ARDOUR_UI::shutdown));
272 ARDOUR_UI::~ARDOUR_UI ()
274 save_ardour_state ();
288 if (add_route_dialog) {
289 delete add_route_dialog;
292 AudioSource::stop_peak_thread ();
296 ARDOUR_UI::configure_timeout ()
301 if (last_configure_time.tv_sec == 0 && last_configure_time.tv_usec == 0) {
302 /* no configure events yet */
306 gettimeofday (&now, 0);
307 timersub (&now, &last_configure_time, &diff);
309 /* force a gap of 0.5 seconds since the last configure event
312 if (diff.tv_sec == 0 && diff.tv_usec < 500000) {
315 have_configure_timeout = false;
316 save_ardour_state ();
322 ARDOUR_UI::configure_handler (GdkEventConfigure* conf)
324 if (have_configure_timeout) {
325 gettimeofday (&last_configure_time, 0);
327 Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
328 have_configure_timeout = true;
335 ARDOUR_UI::save_ardour_state ()
337 if (!keyboard || !mixer || !editor) {
341 /* XXX this is all a bit dubious. add_extra_xml() uses
342 a different lifetime model from add_instant_xml().
345 XMLNode* node = new XMLNode (keyboard->get_state());
346 Config->add_extra_xml (*node);
347 Config->save_state();
349 XMLNode enode(static_cast<Stateful*>(editor)->get_state());
350 XMLNode mnode(mixer->get_state());
353 session->add_instant_xml (enode, session->path());
354 session->add_instant_xml (mnode, session->path());
356 Config->add_instant_xml (enode, get_user_ardour_path());
357 Config->add_instant_xml (mnode, get_user_ardour_path());
364 ARDOUR_UI::startup ()
372 if (session && session->dirty()) {
373 switch (ask_about_saving_session(_("quit"))) {
378 /* use the default name */
379 if (save_state_canfail ("")) {
380 /* failed - don't quit */
381 MessageDialog msg (*editor,
383 Ardour was unable to save your session.\n\n\
384 If you still wish to quit, please use the\n\n\
385 \"Just quit\" option."));
396 session->set_deletion_in_progress ();
399 Config->save_state();
404 ARDOUR_UI::ask_about_saving_session (const string & what)
406 ArdourDialog window (_("ardour: save session?"));
407 Gtk::HBox dhbox; // the hbox for the image and text
408 Gtk::Label prompt_label;
409 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG));
413 msg = string_compose(_("Don't %1"), what);
414 window.add_button (msg, RESPONSE_REJECT);
415 msg = string_compose(_("Just %1"), what);
416 window.add_button (msg, RESPONSE_APPLY);
417 msg = string_compose(_("Save and %1"), what);
418 window.add_button (msg, RESPONSE_ACCEPT);
420 window.set_default_response (RESPONSE_ACCEPT);
422 Gtk::Button noquit_button (msg);
423 noquit_button.set_name ("EditorGTKButton");
428 if (session->snap_name() == session->name()) {
431 type = _("snapshot");
433 prompt = string_compose(_("The %1\"%2\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
434 type, session->snap_name());
436 prompt_label.set_text (prompt);
437 prompt_label.set_name (X_("PrompterLabel"));
438 prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP);
440 dimage->set_alignment(ALIGN_CENTER, ALIGN_TOP)
442 dhbox.set_homogeneous (false);
443 dhbox.pack_start (*dimage, false, false, 5);
444 dhbox.pack_start (prompt_label, true, false, 5);
445 window.get_vbox()->pack_start (dhbox);
447 window.set_name (_("Prompter"));
448 window.set_position (Gtk::WIN_POS_MOUSE);
449 window.set_modal (true);
450 window.set_resizable (false);
453 save_the_session = 0;
455 window.set_keep_above (true);
458 ResponseType r = (ResponseType) window.run();
463 case RESPONSE_ACCEPT: // save and get out of here
465 case RESPONSE_APPLY: // get out of here
475 ARDOUR_UI::every_second ()
478 update_buffer_load ();
479 update_disk_space ();
484 ARDOUR_UI::every_point_one_seconds ()
486 update_speed_display ();
487 RapidScreenUpdate(); /* EMIT_SIGNAL */
492 ARDOUR_UI::every_point_zero_one_seconds ()
494 SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
499 ARDOUR_UI::update_sample_rate (nframes_t ignored)
503 ENSURE_GUI_THREAD (bind (mem_fun(*this, &ARDOUR_UI::update_sample_rate), ignored));
505 if (!engine->connected()) {
507 snprintf (buf, sizeof (buf), _("disconnected"));
511 nframes_t rate = engine->frame_rate();
513 if (fmod (rate, 1000.0) != 0.0) {
514 snprintf (buf, sizeof (buf), _("%.1f kHz / %4.1f msecs"),
515 (float) rate/1000.0f,
516 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
518 snprintf (buf, sizeof (buf), _("%u kHz / %4.1f msecs"),
520 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
524 sample_rate_label.set_text (buf);
528 ARDOUR_UI::update_cpu_load ()
531 snprintf (buf, sizeof (buf), _("DSP: %.1f%%"), engine->get_cpu_load());
532 cpu_load_label.set_text (buf);
536 ARDOUR_UI::update_buffer_load ()
541 snprintf (buf, sizeof (buf), _("Buffers p:%" PRIu32 "%% c:%" PRIu32 "%%"),
542 session->playback_load(), session->capture_load());
543 buffer_load_label.set_text (buf);
545 buffer_load_label.set_text ("");
550 ARDOUR_UI::count_recenabled_streams (Route& route)
552 Track* track = dynamic_cast<Track*>(&route);
553 if (track && track->diskstream()->record_enabled()) {
554 rec_enabled_streams += track->n_inputs().get_total();
559 ARDOUR_UI::update_disk_space()
565 nframes_t frames = session->available_capture_duration();
568 if (frames == max_frames) {
569 strcpy (buf, _("Disk: 24hrs+"));
574 nframes_t fr = session->frame_rate();
576 rec_enabled_streams = 0;
577 session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
579 if (rec_enabled_streams) {
580 frames /= rec_enabled_streams;
583 hrs = frames / (fr * 3600);
584 frames -= hrs * fr * 3600;
585 mins = frames / (fr * 60);
586 frames -= mins * fr * 60;
589 snprintf (buf, sizeof(buf), _("Disk: %02dh:%02dm:%02ds"), hrs, mins, secs);
592 disk_space_label.set_text (buf);
596 ARDOUR_UI::update_wall_clock ()
603 tm_now = localtime (&now);
605 sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
606 wall_clock_label.set_text (buf);
611 ARDOUR_UI::control_methods_adjusted ()
616 which_method = (int) online_control_button->adjustment.get_value();
617 switch (which_method) {
619 allow_mmc_and_local ();
628 fatal << _("programming error: impossible control method") << endmsg;
634 ARDOUR_UI::mmc_device_id_adjusted ()
639 int dev_id = (int) mmc_id_button->adjustment.get_value();
640 mmc->set_device_id (dev_id);
646 ARDOUR_UI::session_menu (GdkEventButton *ev)
648 session_popup_menu->popup (0, 0);
653 ARDOUR_UI::redisplay_recent_sessions ()
655 vector<string *> *sessions;
656 vector<string *>::iterator i;
657 RecentSessionsSorter cmp;
659 recent_session_display.set_model (Glib::RefPtr<TreeModel>(0));
660 recent_session_model->clear ();
663 ARDOUR::read_recent_sessions (rs);
666 recent_session_display.set_model (recent_session_model);
670 /* sort them alphabetically */
671 sort (rs.begin(), rs.end(), cmp);
672 sessions = new vector<string*>;
674 for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
675 sessions->push_back (new string ((*i).second));
678 for (i = sessions->begin(); i != sessions->end(); ++i) {
680 vector<string*>* states;
681 vector<const gchar*> item;
682 string fullpath = *(*i);
684 /* remove any trailing / */
686 if (fullpath[fullpath.length()-1] == '/') {
687 fullpath = fullpath.substr (0, fullpath.length()-1);
690 /* now get available states for this session */
692 if ((states = Session::possible_states (fullpath)) == 0) {
697 TreeModel::Row row = *(recent_session_model->append());
699 row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
700 row[recent_session_columns.fullpath] = fullpath;
702 if (states->size() > 1) {
704 /* add the children */
706 for (vector<string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
708 TreeModel::Row child_row = *(recent_session_model->append (row.children()));
710 child_row[recent_session_columns.visible_name] = **i2;
711 child_row[recent_session_columns.fullpath] = fullpath;
720 recent_session_display.set_model (recent_session_model);
725 ARDOUR_UI::build_session_selector ()
727 session_selector_window = new ArdourDialog ("session selector");
729 Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow);
731 session_selector_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
732 session_selector_window->add_button (Stock::OPEN, RESPONSE_ACCEPT);
733 session_selector_window->set_default_response (RESPONSE_ACCEPT);
734 recent_session_model = TreeStore::create (recent_session_columns);
735 recent_session_display.set_model (recent_session_model);
736 recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
737 recent_session_display.set_headers_visible (false);
738 recent_session_display.get_selection()->set_mode (SELECTION_SINGLE);
740 recent_session_display.signal_row_activated().connect (mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
742 scroller->add (recent_session_display);
743 scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
745 session_selector_window->set_name ("SessionSelectorWindow");
746 session_selector_window->set_size_request (200, 400);
747 session_selector_window->get_vbox()->pack_start (*scroller);
748 session_selector_window->show_all_children();
752 ARDOUR_UI::recent_session_row_activated (const TreePath& path, TreeViewColumn* col)
754 session_selector_window->response (RESPONSE_ACCEPT);
758 ARDOUR_UI::open_recent_session ()
760 /* popup selector window */
762 if (session_selector_window == 0) {
763 build_session_selector ();
766 redisplay_recent_sessions ();
768 ResponseType r = (ResponseType) session_selector_window->run ();
770 session_selector_window->hide();
773 case RESPONSE_ACCEPT:
779 Gtk::TreeModel::iterator i = recent_session_display.get_selection()->get_selected();
781 if (i == recent_session_model->children().end()) {
785 Glib::ustring path = (*i)[recent_session_columns.fullpath];
786 Glib::ustring state = (*i)[recent_session_columns.visible_name];
788 _session_is_new = false;
790 load_session (path, state);
794 ARDOUR_UI::filter_ardour_session_dirs (const FileFilter::Info& info)
798 if (stat (info.filename.c_str(), &statbuf) != 0) {
802 if (!S_ISDIR(statbuf.st_mode)) {
808 string session_file = info.filename;
810 session_file += Glib::path_get_basename (info.filename);
811 session_file += ".ardour";
813 if (stat (session_file.c_str(), &statbuf) != 0) {
817 return S_ISREG (statbuf.st_mode);
821 ARDOUR_UI::open_session ()
823 /* popup selector window */
825 if (open_session_selector == 0) {
827 /* ardour sessions are folders */
829 open_session_selector = new Gtk::FileChooserDialog (_("open session"), FILE_CHOOSER_ACTION_OPEN);
830 open_session_selector->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
831 open_session_selector->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
833 FileFilter session_filter;
834 session_filter.add_pattern ("*.ardour");
835 session_filter.set_name (_("Ardour sessions"));
836 open_session_selector->add_filter (session_filter);
837 open_session_selector->set_filter (session_filter);
840 int response = open_session_selector->run();
841 open_session_selector->hide ();
844 case RESPONSE_ACCEPT:
847 open_session_selector->hide();
851 open_session_selector->hide();
852 string session_path = open_session_selector->get_filename();
856 if (session_path.length() > 0) {
857 if (Session::find_session (session_path, path, name, isnew) == 0) {
858 _session_is_new = isnew;
859 load_session (path, name);
866 ARDOUR_UI::session_add_midi_route (bool disk, uint32_t how_many)
868 list<boost::shared_ptr<MidiTrack> > tracks;
871 warning << _("You cannot add a track without a session already loaded.") << endmsg;
878 tracks = session->new_midi_track (ARDOUR::Normal, how_many);
880 if (tracks.size() != how_many) {
882 error << _("could not create a new midi track") << endmsg;
884 error << string_compose (_("could not create %1 new midi tracks"), how_many) << endmsg;
888 if ((route = session->new_midi_route ()) == 0) {
889 error << _("could not create new midi bus") << endmsg;
895 MessageDialog msg (*editor,
896 _("There are insufficient JACK ports available\n\
897 to create a new track or bus.\n\
898 You should save Ardour, exit and\n\
899 restart JACK with more ports."));
906 ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many)
908 list<boost::shared_ptr<AudioTrack> > tracks;
909 Session::RouteList routes;
912 warning << _("You cannot add a track or bus without a session already loaded.") << endmsg;
918 tracks = session->new_audio_track (input_channels, output_channels, mode, how_many);
920 if (tracks.size() != how_many) {
922 error << _("could not create a new audio track") << endmsg;
924 error << string_compose (_("could not create %1 new audio tracks"), how_many) << endmsg;
930 routes = session->new_audio_route (input_channels, output_channels, how_many);
932 if (routes.size() != how_many) {
934 error << _("could not create a new audio track") << endmsg;
936 error << string_compose (_("could not create %1 new audio tracks"), how_many) << endmsg;
942 if (need_control_room_outs) {
948 route->set_stereo_control_outs (control_lr_channels);
949 route->control_outs()->set_stereo_pan (pans, this);
951 #endif /* CONTROLOUTS */
955 MessageDialog msg (*editor,
956 _("There are insufficient JACK ports available\n\
957 to create a new track or bus.\n\
958 You should save Ardour, exit and\n\
959 restart JACK with more ports."));
965 ARDOUR_UI::do_transport_locate (nframes_t new_position)
967 nframes_t _preroll = 0;
970 // XXX CONFIG_CHANGE FIX - requires AnyTime handling
971 // _preroll = session->convert_to_frames_at (new_position, Config->get_preroll());
973 if (new_position > _preroll) {
974 new_position -= _preroll;
979 session->request_locate (new_position);
984 ARDOUR_UI::transport_goto_start ()
987 session->goto_start();
990 /* force displayed area in editor to start no matter
991 what "follow playhead" setting is.
995 editor->reposition_x_origin (session->current_start_frame());
1001 ARDOUR_UI::transport_goto_zero ()
1004 session->request_locate (0);
1007 /* force displayed area in editor to start no matter
1008 what "follow playhead" setting is.
1012 editor->reposition_x_origin (0);
1018 ARDOUR_UI::transport_goto_end ()
1021 nframes_t frame = session->current_end_frame();
1022 session->request_locate (frame);
1024 /* force displayed area in editor to start no matter
1025 what "follow playhead" setting is.
1029 editor->reposition_x_origin (frame);
1035 ARDOUR_UI::transport_stop ()
1041 if (session->is_auditioning()) {
1042 session->cancel_audition ();
1046 if (session->get_play_loop ()) {
1047 session->request_play_loop (false);
1050 session->request_stop ();
1054 ARDOUR_UI::transport_stop_and_forget_capture ()
1057 session->request_stop (true);
1062 ARDOUR_UI::remove_last_capture()
1065 editor->remove_last_capture();
1070 ARDOUR_UI::transport_record ()
1073 switch (session->record_status()) {
1074 case Session::Disabled:
1075 if (session->ntracks() == 0) {
1076 MessageDialog msg (*editor, _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu."));
1080 session->maybe_enable_record ();
1082 case Session::Recording:
1083 case Session::Enabled:
1084 session->disable_record (true);
1090 ARDOUR_UI::transport_roll ()
1098 rolling = session->transport_rolling ();
1100 if (session->get_play_loop()) {
1101 session->request_play_loop (false);
1102 auto_loop_button.set_active (false);
1103 roll_button.set_active (true);
1104 } else if (session->get_play_range ()) {
1105 session->request_play_range (false);
1106 play_selection_button.set_active (false);
1107 } else if (rolling) {
1108 session->request_locate (session->last_transport_start(), true);
1111 session->request_transport_speed (1.0f);
1115 ARDOUR_UI::transport_loop()
1118 if (session->get_play_loop()) {
1119 if (session->transport_rolling()) {
1120 Location * looploc = session->locations()->auto_loop_location();
1122 session->request_locate (looploc->start(), true);
1127 session->request_play_loop (true);
1133 ARDOUR_UI::transport_play_selection ()
1139 if (!session->get_play_range()) {
1140 session->request_stop ();
1143 editor->play_selection ();
1147 ARDOUR_UI::transport_rewind (int option)
1149 float current_transport_speed;
1152 current_transport_speed = session->transport_speed();
1154 if (current_transport_speed >= 0.0f) {
1157 session->request_transport_speed (-1.0f);
1160 session->request_transport_speed (-4.0f);
1163 session->request_transport_speed (-0.5f);
1168 session->request_transport_speed (current_transport_speed * 1.5f);
1174 ARDOUR_UI::transport_forward (int option)
1176 float current_transport_speed;
1179 current_transport_speed = session->transport_speed();
1181 if (current_transport_speed <= 0.0f) {
1184 session->request_transport_speed (1.0f);
1187 session->request_transport_speed (4.0f);
1190 session->request_transport_speed (0.5f);
1195 session->request_transport_speed (current_transport_speed * 1.5f);
1201 ARDOUR_UI::toggle_record_enable (uint32_t dstream)
1207 boost::shared_ptr<Route> r;
1209 if ((r = session->route_by_remote_id (dstream)) != 0) {
1213 if ((t = dynamic_cast<Track*>(r.get())) != 0) {
1214 t->diskstream()->set_record_enabled (!t->diskstream()->record_enabled());
1223 ARDOUR_UI::queue_transport_change ()
1225 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &ARDOUR_UI::map_transport_state));
1229 ARDOUR_UI::map_transport_state ()
1231 float sp = session->transport_speed();
1234 transport_rolling ();
1235 } else if (sp < 0.0f) {
1236 transport_rewinding ();
1237 } else if (sp > 0.0f) {
1238 transport_forwarding ();
1240 transport_stopped ();
1245 ARDOUR_UI::allow_local_only ()
1251 ARDOUR_UI::allow_mmc_only ()
1257 ARDOUR_UI::allow_mmc_and_local ()
1263 ARDOUR_UI::GlobalClickBox::printer (char buf[32], Adjustment &adj, void *arg)
1265 snprintf (buf, sizeof(buf), "%s", ((GlobalClickBox *) arg)->strings[
1266 (int) adj.get_value()].c_str());
1270 ARDOUR_UI::engine_stopped ()
1272 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_stopped));
1273 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1274 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1278 ARDOUR_UI::engine_running ()
1280 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_running));
1281 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
1282 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
1286 ARDOUR_UI::engine_halted ()
1288 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_halted));
1290 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1291 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1293 update_sample_rate (0);
1295 MessageDialog msg (*editor,
1297 JACK has either been shutdown or it\n\
1298 disconnected Ardour because Ardour\n\
1299 was not fast enough. You can save the\n\
1300 session and/or try to reconnect to JACK ."));
1305 ARDOUR_UI::do_engine_start ()
1313 error << _("Unable to start the session running")
1323 ARDOUR_UI::start_engine ()
1325 if (do_engine_start () == 0) {
1326 if (session && _session_is_new) {
1327 /* we need to retain initial visual
1328 settings for a new session
1330 session->save_state ("");
1338 ARDOUR_UI::update_clocks ()
1340 if (!editor || !editor->dragging_playhead()) {
1341 Clock (session->audible_frame()); /* EMIT_SIGNAL */
1346 ARDOUR_UI::start_clocking ()
1348 clock_signal_connection = RapidScreenUpdate.connect (mem_fun(*this, &ARDOUR_UI::update_clocks));
1352 ARDOUR_UI::stop_clocking ()
1354 clock_signal_connection.disconnect ();
1358 ARDOUR_UI::toggle_clocking ()
1361 if (clock_button.get_active()) {
1370 ARDOUR_UI::_blink (void *arg)
1373 ((ARDOUR_UI *) arg)->blink ();
1380 Blink (blink_on = !blink_on); /* EMIT_SIGNAL */
1384 ARDOUR_UI::start_blinking ()
1386 /* Start the blink signal. Everybody with a blinking widget
1387 uses Blink to drive the widget's state.
1390 if (blink_timeout_tag < 0) {
1392 blink_timeout_tag = g_timeout_add (240, _blink, this);
1397 ARDOUR_UI::stop_blinking ()
1399 if (blink_timeout_tag >= 0) {
1400 g_source_remove (blink_timeout_tag);
1401 blink_timeout_tag = -1;
1406 ARDOUR_UI::name_io_setup (AudioEngine& engine,
1412 if (io.n_inputs().get_total() == 0) {
1417 /* XXX we're not handling multiple ports yet. */
1419 const char **connections = io.input(0)->get_connections();
1421 if (connections == 0 || connections[0] == '\0') {
1424 buf = connections[0];
1431 if (io.n_outputs().get_total() == 0) {
1436 /* XXX we're not handling multiple ports yet. */
1438 const char **connections = io.output(0)->get_connections();
1440 if (connections == 0 || connections[0] == '\0') {
1443 buf = connections[0];
1451 ARDOUR_UI::snapshot_session ()
1453 ArdourPrompter prompter (true);
1460 now = now.substr (20, 4) + now.substr (3, 16) + " (" + now.substr (0, 3) + ")";
1462 prompter.set_name ("Prompter");
1463 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
1464 prompter.set_prompt (_("Name of New Snapshot"));
1465 prompter.set_initial_text (now);
1467 switch (prompter.run()) {
1468 case RESPONSE_ACCEPT:
1469 prompter.get_result (snapname);
1470 if (snapname.length()){
1471 save_state (snapname);
1481 ARDOUR_UI::save_state (const string & name)
1483 (void) save_state_canfail (name);
1487 ARDOUR_UI::save_state_canfail (string name)
1492 if (name.length() == 0) {
1493 name = session->snap_name();
1496 if ((ret = session->save_state (name)) != 0) {
1500 save_ardour_state (); /* XXX cannot fail? yeah, right ... */
1505 ARDOUR_UI::restore_state (string name)
1508 if (name.length() == 0) {
1509 name = session->name();
1511 session->restore_state (name);
1516 ARDOUR_UI::primary_clock_value_changed ()
1519 session->request_locate (primary_clock.current_time ());
1524 ARDOUR_UI::secondary_clock_value_changed ()
1527 session->request_locate (secondary_clock.current_time ());
1532 ARDOUR_UI::rec_enable_button_blink (bool onoff, AudioDiskstream *dstream, Widget *w)
1534 if (session && dstream && dstream->record_enabled()) {
1536 Session::RecordState rs;
1538 rs = session->record_status ();
1541 case Session::Disabled:
1542 case Session::Enabled:
1543 if (w->get_state() != STATE_SELECTED) {
1544 w->set_state (STATE_SELECTED);
1548 case Session::Recording:
1549 if (w->get_state() != STATE_ACTIVE) {
1550 w->set_state (STATE_ACTIVE);
1556 if (w->get_state() != STATE_NORMAL) {
1557 w->set_state (STATE_NORMAL);
1563 ARDOUR_UI::transport_rec_enable_blink (bool onoff)
1569 switch (session->record_status()) {
1570 case Session::Enabled:
1572 rec_button.set_state (1);
1574 rec_button.set_state (0);
1578 case Session::Recording:
1579 rec_button.set_state (2);
1583 rec_button.set_state (0);
1589 ARDOUR_UI::hide_and_quit (GdkEventAny *ev, ArdourDialog *window)
1597 ARDOUR_UI::start_keyboard_prefix ()
1599 keyboard->start_prefix();
1603 ARDOUR_UI::save_template ()
1606 ArdourPrompter prompter (true);
1609 prompter.set_name (X_("Prompter"));
1610 prompter.set_prompt (_("Name for mix template:"));
1611 prompter.set_initial_text(session->name() + _("-template"));
1612 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
1614 switch (prompter.run()) {
1615 case RESPONSE_ACCEPT:
1616 prompter.get_result (name);
1618 if (name.length()) {
1619 session->save_template (name);
1629 ARDOUR_UI::new_session (std::string predetermined_path)
1631 string session_name;
1632 string session_path;
1634 int response = Gtk::RESPONSE_NONE;
1636 new_session_dialog->set_modal(true);
1637 new_session_dialog->set_name (predetermined_path);
1638 new_session_dialog->reset_recent();
1639 new_session_dialog->show();
1642 response = new_session_dialog->run ();
1644 _session_is_new = false;
1646 if (response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) {
1651 new_session_dialog->hide ();
1654 } else if (response == Gtk::RESPONSE_NONE) {
1656 /* Clear was pressed */
1657 new_session_dialog->reset();
1659 } else if (response == Gtk::RESPONSE_YES) {
1661 /* YES == OPEN, but there's no enum for that */
1663 session_name = new_session_dialog->session_name();
1665 if (session_name.empty()) {
1666 response = Gtk::RESPONSE_NONE;
1670 if (session_name[0] == '/' ||
1671 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1672 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1673 load_session (Glib::path_get_dirname (session_name), session_name);
1675 session_path = new_session_dialog->session_folder();
1676 load_session (session_path, session_name);
1679 } else if (response == Gtk::RESPONSE_OK) {
1681 session_name = new_session_dialog->session_name();
1683 if (new_session_dialog->get_current_page() == 1) {
1685 /* XXX this is a bit of a hack..
1686 i really want the new sesion dialog to return RESPONSE_YES
1687 if we're on page 1 (the load page)
1688 Unfortunately i can't see how atm..
1691 if (session_name.empty()) {
1692 response = Gtk::RESPONSE_NONE;
1696 if (session_name[0] == '/' ||
1697 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1698 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1699 load_session (Glib::path_get_dirname (session_name), session_name);
1701 session_path = new_session_dialog->session_folder();
1702 load_session (session_path, session_name);
1707 if (session_name.empty()) {
1708 response = Gtk::RESPONSE_NONE;
1712 if (session_name[0] == '/' ||
1713 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1714 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1716 session_path = Glib::path_get_dirname (session_name);
1717 session_name = Glib::path_get_basename (session_name);
1721 session_path = new_session_dialog->session_folder();
1725 //XXX This is needed because session constructor wants a
1726 //non-existant path. hopefully this will be fixed at some point.
1728 session_path = Glib::build_filename (session_path, session_name);
1730 if (g_file_test (session_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
1732 Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
1734 MessageDialog msg (str,
1736 Gtk::MESSAGE_WARNING,
1737 Gtk::BUTTONS_YES_NO,
1741 msg.set_name (X_("CleanupDialog"));
1742 msg.set_wmclass (X_("existing_session"), "Ardour");
1743 msg.set_position (Gtk::WIN_POS_MOUSE);
1745 switch (msg.run()) {
1747 load_session (session_path, session_name);
1751 response = RESPONSE_NONE;
1752 new_session_dialog->reset ();
1757 _session_is_new = true;
1759 std::string template_name = new_session_dialog->session_template_name();
1761 if (new_session_dialog->use_session_template()) {
1763 load_session (session_path, session_name, &template_name);
1769 AutoConnectOption iconnect;
1770 AutoConnectOption oconnect;
1772 if (new_session_dialog->create_control_bus()) {
1773 cchns = (uint32_t) new_session_dialog->control_channel_count();
1778 if (new_session_dialog->create_master_bus()) {
1779 mchns = (uint32_t) new_session_dialog->master_channel_count();
1784 if (new_session_dialog->connect_inputs()) {
1785 iconnect = AutoConnectPhysical;
1787 iconnect = AutoConnectOption (0);
1790 /// @todo some minor tweaks.
1792 if (new_session_dialog->connect_outs_to_master()) {
1793 oconnect = AutoConnectMaster;
1794 } else if (new_session_dialog->connect_outs_to_physical()) {
1795 oconnect = AutoConnectPhysical;
1797 oconnect = AutoConnectOption (0);
1800 uint32_t nphysin = (uint32_t) new_session_dialog->input_limit_count();
1801 uint32_t nphysout = (uint32_t) new_session_dialog->output_limit_count();
1803 build_session (session_path,
1811 engine->frame_rate() * 60 * 5);
1816 } while (response == Gtk::RESPONSE_NONE);
1820 new_session_dialog->get_window()->set_cursor();
1821 new_session_dialog->hide();
1825 ARDOUR_UI::close_session()
1832 ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template)
1834 Session *new_session;
1836 session_loaded = false;
1837 x = unload_session ();
1845 /* if it already exists, we must have write access */
1847 if (::access (path.c_str(), F_OK) == 0 && ::access (path.c_str(), W_OK)) {
1848 MessageDialog msg (*editor, _("You do not have write access to this session.\n"
1849 "This prevents the session from being loaded."));
1855 new_session = new Session (*engine, path, snap_name, mix_template);
1860 error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
1864 connect_to_session (new_session);
1866 Config->set_current_owner (ConfigVariableBase::Interface);
1868 session_loaded = true;
1870 goto_editor_window ();
1873 session->set_clean ();
1880 ARDOUR_UI::build_session (const string & path, const string & snap_name,
1881 uint32_t control_channels,
1882 uint32_t master_channels,
1883 AutoConnectOption input_connect,
1884 AutoConnectOption output_connect,
1887 nframes_t initial_length)
1889 Session *new_session;
1892 session_loaded = false;
1893 x = unload_session ();
1900 _session_is_new = true;
1903 new_session = new Session (*engine, path, snap_name, input_connect, output_connect,
1904 control_channels, master_channels, nphysin, nphysout, initial_length);
1909 error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
1913 connect_to_session (new_session);
1915 session_loaded = true;
1923 editor->show_window ();
1934 ARDOUR_UI::show_splash ()
1937 about = new About();
1938 about->signal_response().connect(mem_fun (*this, &ARDOUR_UI::about_signal_response) );
1945 ARDOUR_UI::about_signal_response(int response)
1951 ARDOUR_UI::hide_splash ()
1954 about->get_window()->set_cursor ();
1960 ARDOUR_UI::display_cleanup_results (Session::cleanup_report& rep, const gchar* list_title, const string & msg)
1964 removed = rep.paths.size();
1967 MessageDialog msgd (*editor,
1968 _("No audio files were ready for cleanup"),
1971 (Gtk::ButtonsType)(Gtk::BUTTONS_OK) );
1972 msgd.set_secondary_text (_("If this seems suprising, \n\
1973 check for any existing snapshots.\n\
1974 These may still include regions that\n\
1975 require some unused files to continue to exist."));
1981 ArdourDialog results (_("ardour: cleanup"), true, false);
1983 struct CleanupResultsModelColumns : public Gtk::TreeModel::ColumnRecord {
1984 CleanupResultsModelColumns() {
1988 Gtk::TreeModelColumn<Glib::ustring> visible_name;
1989 Gtk::TreeModelColumn<Glib::ustring> fullpath;
1993 CleanupResultsModelColumns results_columns;
1994 Glib::RefPtr<Gtk::ListStore> results_model;
1995 Gtk::TreeView results_display;
1997 results_model = ListStore::create (results_columns);
1998 results_display.set_model (results_model);
1999 results_display.append_column (list_title, results_columns.visible_name);
2001 results_display.set_name ("CleanupResultsList");
2002 results_display.set_headers_visible (true);
2003 results_display.set_headers_clickable (false);
2004 results_display.set_reorderable (false);
2006 Gtk::ScrolledWindow list_scroller;
2009 Gtk::HBox dhbox; // the hbox for the image and text
2010 Gtk::HBox ddhbox; // the hbox we eventually pack into the dialog's vbox
2011 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG));
2013 dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
2015 if (rep.space < 1048576.0f) {
2017 txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
2019 txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
2023 txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
2025 txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
2029 dhbox.pack_start (*dimage, true, false, 5);
2030 dhbox.pack_start (txt, true, false, 5);
2032 for (vector<string>::iterator i = rep.paths.begin(); i != rep.paths.end(); ++i) {
2033 TreeModel::Row row = *(results_model->append());
2034 row[results_columns.visible_name] = *i;
2035 row[results_columns.fullpath] = *i;
2038 list_scroller.add (results_display);
2039 list_scroller.set_size_request (-1, 150);
2040 list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2042 dvbox.pack_start (dhbox, true, false, 5);
2043 dvbox.pack_start (list_scroller, true, false, 5);
2044 ddhbox.pack_start (dvbox, true, false, 5);
2046 results.get_vbox()->pack_start (ddhbox, true, false, 5);
2047 results.add_button (Stock::CLOSE, RESPONSE_CLOSE);
2048 results.set_default_response (RESPONSE_CLOSE);
2049 results.set_position (Gtk::WIN_POS_MOUSE);
2050 results.show_all_children ();
2051 results.set_resizable (false);
2058 ARDOUR_UI::cleanup ()
2061 /* shouldn't happen: menu item is insensitive */
2066 MessageDialog checker (_("Are you sure you want to cleanup?"),
2068 Gtk::MESSAGE_QUESTION,
2069 (Gtk::ButtonsType)(Gtk::BUTTONS_NONE));
2071 checker.set_secondary_text(_("Cleanup is a destructive operation.\n\
2072 ALL undo/redo information will be lost if you cleanup.\n\
2073 After cleanup, unused audio files will be moved to a \
2074 \"dead sounds\" location."));
2076 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
2077 checker.add_button (_("Clean Up"), RESPONSE_ACCEPT);
2078 checker.set_default_response (RESPONSE_CANCEL);
2080 checker.set_name (_("CleanupDialog"));
2081 checker.set_wmclass (X_("ardour_cleanup"), "Ardour");
2082 checker.set_position (Gtk::WIN_POS_MOUSE);
2084 switch (checker.run()) {
2085 case RESPONSE_ACCEPT:
2091 Session::cleanup_report rep;
2093 editor->prepare_for_cleanup ();
2095 if (session->cleanup_sources (rep)) {
2099 display_cleanup_results (rep,
2102 The following %1 %2 not in use and \n\
2103 have been moved to:\n\
2105 Flushing the wastebasket will \n\
2106 release an additional\n\
2107 %4 %5bytes of disk space.\n"
2112 ARDOUR_UI::flush_trash ()
2115 /* shouldn't happen: menu item is insensitive */
2119 Session::cleanup_report rep;
2121 if (session->cleanup_trash_sources (rep)) {
2125 display_cleanup_results (rep,
2127 _("The following %1 %2 deleted from\n\
2129 releasing %4 %5bytes of disk space"));
2133 ARDOUR_UI::add_route ()
2141 if (add_route_dialog == 0) {
2142 add_route_dialog = new AddRouteDialog;
2143 editor->ensure_float (*add_route_dialog);
2146 if (add_route_dialog->is_visible()) {
2147 /* we're already doing this */
2151 ResponseType r = (ResponseType) add_route_dialog->run ();
2153 add_route_dialog->hide();
2156 case RESPONSE_ACCEPT:
2163 if ((count = add_route_dialog->count()) <= 0) {
2167 uint32_t input_chan = add_route_dialog->channels ();
2168 uint32_t output_chan;
2169 string name_template = add_route_dialog->name_template ();
2170 bool track = add_route_dialog->track ();
2172 AutoConnectOption oac = Config->get_output_auto_connect();
2174 if (oac & AutoConnectMaster) {
2175 output_chan = (session->master_out() ? session->master_out()->n_inputs().get(DataType::AUDIO) : input_chan);
2177 output_chan = input_chan;
2180 /* XXX do something with name template */
2182 if (add_route_dialog->type() == ARDOUR::DataType::MIDI) {
2184 session_add_midi_track(count);
2186 MessageDialog msg (*editor,
2187 _("Sorry, MIDI Busses are not supported at this time."));
2189 //session_add_midi_bus();
2193 session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), count);
2195 session_add_audio_bus (input_chan, output_chan, count);
2201 ARDOUR_UI::mixer_settings () const
2206 node = session->instant_xml(X_("Mixer"), session->path());
2208 node = Config->instant_xml(X_("Mixer"), get_user_ardour_path());
2212 node = new XMLNode (X_("Mixer"));
2219 ARDOUR_UI::editor_settings () const
2224 node = session->instant_xml(X_("Editor"), session->path());
2226 node = Config->instant_xml(X_("Editor"), get_user_ardour_path());
2230 node = new XMLNode (X_("Editor"));
2236 ARDOUR_UI::keyboard_settings () const
2240 node = Config->extra_xml(X_("Keyboard"));
2243 node = new XMLNode (X_("Keyboard"));
2249 ARDOUR_UI::halt_on_xrun_message ()
2251 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
2253 MessageDialog msg (*editor,
2254 _("Recording was stopped because your system could not keep up."));
2259 ARDOUR_UI::disk_overrun_handler ()
2261 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
2263 if (!have_disk_overrun_displayed) {
2264 have_disk_overrun_displayed = true;
2265 MessageDialog msg (*editor, X_("diskrate dialog"), _("\
2266 The disk system on your computer\n\
2267 was not able to keep up with Ardour.\n\
2269 Specifically, it failed to write data to disk\n\
2270 quickly enough to keep up with recording.\n"));
2272 have_disk_overrun_displayed = false;
2277 ARDOUR_UI::disk_underrun_handler ()
2279 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
2281 if (!have_disk_underrun_displayed) {
2282 have_disk_underrun_displayed = true;
2283 MessageDialog msg (*editor,
2284 (_("The disk system on your computer\n\
2285 was not able to keep up with Ardour.\n\
2287 Specifically, it failed to read data from disk\n\
2288 quickly enough to keep up with playback.\n")));
2290 have_disk_underrun_displayed = false;
2295 ARDOUR_UI::disk_underrun_message_gone ()
2297 have_disk_underrun_displayed = false;
2301 ARDOUR_UI::disk_overrun_message_gone ()
2303 have_disk_underrun_displayed = false;
2307 ARDOUR_UI::pending_state_dialog ()
2309 ArdourDialog dialog ("pending state dialog");
2311 This session appears to have been in\n\
2312 middle of recording when ardour or\n\
2313 the computer was shutdown.\n\
2315 Ardour can recover any captured audio for\n\
2316 you, or it can ignore it. Please decide\n\
2317 what you would like to do.\n"));
2319 dialog.get_vbox()->pack_start (message);
2320 dialog.add_button (_("Recover from crash"), RESPONSE_ACCEPT);
2321 dialog.add_button (_("Ignore crash data"), RESPONSE_REJECT);
2323 dialog.set_position (WIN_POS_CENTER);
2326 switch (dialog.run ()) {
2327 case RESPONSE_ACCEPT:
2335 ARDOUR_UI::disconnect_from_jack ()
2338 if( engine->disconnect_from_jack ()) {
2339 MessageDialog msg (*editor, _("Could not disconnect from JACK"));
2343 update_sample_rate (0);
2348 ARDOUR_UI::reconnect_to_jack ()
2351 if (engine->reconnect_to_jack ()) {
2352 MessageDialog msg (*editor, _("Could not reconnect to JACK"));
2356 update_sample_rate (0);
2361 ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
2363 engine->request_buffer_size (nframes);
2364 update_sample_rate (0);
2368 ARDOUR_UI::cmdline_new_session (string path)
2370 if (path[0] != '/') {
2371 char buf[PATH_MAX+1];
2374 getcwd (buf, sizeof (buf));
2383 _will_create_new_session_automatically = false; /* done it */
2384 return FALSE; /* don't call it again */
2388 ARDOUR_UI::use_config ()
2390 Glib::RefPtr<Action> act;
2392 switch (Config->get_native_file_data_format ()) {
2394 act = ActionManager::get_action (X_("options"), X_("FileDataFormatFloat"));
2397 act = ActionManager::get_action (X_("options"), X_("FileDataFormat24bit"));
2402 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
2403 ract->set_active ();
2406 switch (Config->get_native_file_header_format ()) {
2408 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatBWF"));
2411 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE"));
2414 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE64"));
2417 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatiXML"));
2420 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
2423 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatCAF"));
2426 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatAIFF"));
2431 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
2432 ract->set_active ();
2437 ARDOUR_UI::update_transport_clocks (nframes_t pos)
2439 primary_clock.set (pos);
2440 secondary_clock.set (pos);
2442 if (big_clock_window) {
2443 big_clock.set (pos);
2448 ARDOUR_UI::record_state_changed ()
2450 if (!session || !big_clock_window) {
2451 /* why bother - the clock isn't visible */
2455 switch (session->record_status()) {
2456 case Session::Recording:
2457 big_clock.set_name ("BigClockRecording");
2460 big_clock.set_name ("BigClockNonRecording");
2466 ARDOUR_UI::set_keybindings_path (string path)
2468 keybindings_path = path;
2472 ARDOUR_UI::save_keybindings ()
2474 if (can_save_keybindings) {
2475 AccelMap::save (keybindings_path);
2480 ARDOUR_UI::first_idle ()
2482 can_save_keybindings = true;
2487 ARDOUR_UI::store_clock_modes ()
2489 XMLNode* node = new XMLNode(X_("ClockModes"));
2491 for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
2492 node->add_property ((*x)->name().c_str(), enum_2_string ((*x)->mode()));
2495 session->add_extra_xml (*node);
2496 session->set_dirty ();