2 Copyright (C) 2005 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 <pbd/convert.h>
22 #include <pbd/stacktrace.h>
24 #include <gtkmm2ext/utils.h>
26 #include <ardour/configuration.h>
27 #include <ardour/session.h>
28 #include <ardour/audioengine.h>
30 #include "ardour_ui.h"
32 #include "gui_thread.h"
37 using namespace Gtkmm2ext;
38 using namespace ARDOUR;
43 ARDOUR_UI::toggle_time_master ()
45 ActionManager::toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
49 ARDOUR_UI::toggle_send_mtc ()
51 ActionManager::toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
55 ARDOUR_UI::toggle_send_mmc ()
57 ActionManager::toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
61 ARDOUR_UI::toggle_use_mmc ()
63 ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
67 ARDOUR_UI::toggle_use_midi_control ()
69 ActionManager::toggle_config_state ("options", "UseMIDIcontrol", &Configuration::set_midi_control, &Configuration::get_midi_control);
73 ARDOUR_UI::toggle_send_midi_feedback ()
75 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
79 ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
85 action = X_("FileHeaderFormatBWF");
88 action = X_("FileHeaderFormatWAVE");
91 action = X_("FileHeaderFormatWAVE64");
94 action = X_("FileHeaderFormatiXML");
97 action = X_("FileHeaderFormatRF64");
100 action = X_("FileHeaderFormatCAF");
103 action = X_("FileHeaderFormatAIFF");
106 fatal << string_compose (_("programming error: %1"), "illegal file header format in ::set_native_file_header_format") << endmsg;
110 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
113 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
114 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
115 Config->set_native_file_header_format (hf);
121 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
127 action = X_("FileDataFormatFloat");
130 action = X_("FileDataFormat24bit");
133 fatal << string_compose (_("programming error: %1"), "illegal file data format in ::set_native_file_data_format") << endmsg;
137 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
140 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
141 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
142 Config->set_native_file_data_format (sf);
148 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
153 case AutoConnectPhysical:
154 action = X_("InputAutoConnectPhysical");
157 action = X_("InputAutoConnectManual");
160 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
163 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
165 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
166 Config->set_input_auto_connect (option);
172 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
177 case AutoConnectPhysical:
178 action = X_("OutputAutoConnectPhysical");
180 case AutoConnectMaster:
181 action = X_("OutputAutoConnectMaster");
184 action = X_("OutputAutoConnectManual");
187 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
190 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
192 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
193 Config->set_output_auto_connect (option);
199 ARDOUR_UI::set_solo_model (SoloModel model)
201 const char* action = 0;
205 action = X_("SoloViaBus");
209 action = X_("SoloInPlace");
212 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
216 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
219 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
221 if (ract && ract->get_active() && Config->get_solo_model() != model) {
222 Config->set_solo_model (model);
229 ARDOUR_UI::set_monitor_model (MonitorModel model)
231 const char* action = 0;
234 case HardwareMonitoring:
235 action = X_("UseHardwareMonitoring");
238 case SoftwareMonitoring:
239 action = X_("UseSoftwareMonitoring");
241 case ExternalMonitoring:
242 action = X_("UseExternalMonitoring");
246 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
250 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
253 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
255 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
256 Config->set_monitoring_model (model);
263 ARDOUR_UI::toggle_auto_input ()
265 ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
269 ARDOUR_UI::toggle_auto_play ()
271 ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
275 ARDOUR_UI::toggle_auto_return ()
277 ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
281 ARDOUR_UI::toggle_click ()
283 ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
287 ARDOUR_UI::toggle_session_auto_loop ()
290 if (session->get_play_loop()) {
291 if (session->transport_rolling()) {
294 session->request_play_loop (false);
297 session->request_play_loop (true);
303 ARDOUR_UI::toggle_punch_in ()
305 ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
309 ARDOUR_UI::toggle_punch_out ()
311 ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
315 ARDOUR_UI::toggle_video_sync()
317 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
319 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
320 Config->set_use_video_sync (tact->get_active());
325 ARDOUR_UI::toggle_editing_space()
327 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
329 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
330 if (tact->get_active()) {
331 maximise_editing_space ();
333 restore_editing_space ();
339 ARDOUR_UI::toggle_StopPluginsWithTransport()
341 ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
345 ARDOUR_UI::toggle_LatchedRecordEnable()
347 ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
351 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
353 ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
357 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
359 ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
363 ARDOUR_UI::toggle_StopRecordingOnXrun()
365 ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
369 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
371 ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
375 ARDOUR_UI::toggle_GainReduceFastTransport()
377 ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
381 ARDOUR_UI::toggle_LatchedSolo()
383 ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
387 ARDOUR_UI::mtc_port_changed ()
392 if (session->mtc_port()) {
401 positional_sync_strings.clear ();
402 positional_sync_strings.push_back (slave_source_to_string (None));
404 positional_sync_strings.push_back (slave_source_to_string (MTC));
406 positional_sync_strings.push_back (slave_source_to_string (JACK));
408 set_popdown_strings (sync_option_combo, positional_sync_strings);
412 ARDOUR_UI::setup_session_options ()
416 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
421 ARDOUR_UI::map_solo_model ()
425 if (Config->get_solo_model() == InverseMute) {
426 on = X_("SoloInPlace");
428 on = X_("SoloViaBus");
431 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
433 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
435 if (tact && !tact->get_active()) {
436 tact->set_active (true);
442 ARDOUR_UI::map_monitor_model ()
446 switch (Config->get_monitoring_model()) {
447 case HardwareMonitoring:
448 on = X_("UseHardwareMonitoring");
450 case SoftwareMonitoring:
451 on = X_("UseSoftwareMonitoring");
453 case ExternalMonitoring:
454 on = X_("UseExternalMonitoring");
458 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
460 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
462 if (tact && !tact->get_active()) {
463 tact->set_active (true);
469 ARDOUR_UI::map_file_header_format ()
471 const char* action = 0;
473 switch (Config->get_native_file_header_format()) {
475 action = X_("FileHeaderFormatBWF");
479 action = X_("FileHeaderFormatWAVE");
483 action = X_("FileHeaderFormatWAVE64");
487 action = X_("FileHeaderFormatiXML");
491 action = X_("FileHeaderFormatRF64");
495 action = X_("FileHeaderFormatCAF");
499 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"),
500 Config->get_native_file_header_format()) << endmsg;
505 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
508 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
510 if (tact && !tact->get_active()) {
511 tact->set_active (true);
517 ARDOUR_UI::map_file_data_format ()
519 const char* action = 0;
521 switch (Config->get_native_file_data_format()) {
523 action = X_("FileDataFormatFloat");
527 action = X_("FileDataFormat24bit");
531 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"),
532 Config->get_native_file_data_format()) << endmsg;
537 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
540 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
542 if (tact && !tact->get_active()) {
543 tact->set_active (true);
549 ARDOUR_UI::map_input_auto_connect ()
553 if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
554 on = "InputAutoConnectManual";
556 on = "InputAutoConnectPhysical";
559 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
561 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
563 if (tact && !tact->get_active()) {
564 tact->set_active (true);
570 ARDOUR_UI::map_output_auto_connect ()
574 if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
575 on = "OutputAutoConnectManual";
576 } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
577 on = "OutputAutoConnectPhysical";
579 on = "OutputAutoConnectMaster";
582 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
584 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
586 if (tact && !tact->get_active()) {
587 tact->set_active (true);
593 ARDOUR_UI::map_meter_falloff ()
595 const char* action = X_("MeterFalloffMedium");
597 float val = Config->get_meter_falloff ();
598 MeterFalloff code = meter_falloff_from_float(val);
601 case MeterFalloffOff:
602 action = X_("MeterFalloffOff");
604 case MeterFalloffSlowest:
605 action = X_("MeterFalloffSlowest");
607 case MeterFalloffSlow:
608 action = X_("MeterFalloffSlow");
610 case MeterFalloffMedium:
611 action = X_("MeterFalloffMedium");
613 case MeterFalloffFast:
614 action = X_("MeterFalloffFast");
616 case MeterFalloffFaster:
617 action = X_("MeterFalloffFaster");
619 case MeterFalloffFastest:
620 action = X_("MeterFalloffFastest");
624 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
627 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
628 if (ract && !ract->get_active()) {
629 ract->set_active (true);
635 ARDOUR_UI::map_meter_hold ()
637 const char* action = X_("MeterHoldMedium");
639 /* XXX hack alert. Fix this. Please */
641 float val = Config->get_meter_hold ();
642 MeterHold code = (MeterHold) (int) (floor (val));
646 action = X_("MeterHoldOff");
649 action = X_("MeterHoldShort");
651 case MeterHoldMedium:
652 action = X_("MeterHoldMedium");
655 action = X_("MeterHoldLong");
659 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
662 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
663 if (ract && !ract->get_active()) {
664 ract->set_active (true);
670 ARDOUR_UI::set_meter_hold (MeterHold val)
672 const char* action = 0;
675 fval = meter_hold_to_float (val);
679 action = X_("MeterHoldOff");
682 action = X_("MeterHoldShort");
684 case MeterHoldMedium:
685 action = X_("MeterHoldMedium");
688 action = X_("MeterHoldLong");
692 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
695 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
696 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
697 Config->set_meter_hold (fval);
703 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
705 const char* action = 0;
708 fval = meter_falloff_to_float (val);
711 case MeterFalloffOff:
712 action = X_("MeterFalloffOff");
714 case MeterFalloffSlowest:
715 action = X_("MeterFalloffSlowest");
717 case MeterFalloffSlow:
718 action = X_("MeterFalloffSlow");
720 case MeterFalloffMedium:
721 action = X_("MeterFalloffMedium");
723 case MeterFalloffFast:
724 action = X_("MeterFalloffFast");
726 case MeterFalloffFaster:
727 action = X_("MeterFalloffFaster");
729 case MeterFalloffFastest:
730 action = X_("MeterFalloffFastest");
734 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
737 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
738 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
739 Config->set_meter_falloff (fval);
745 ARDOUR_UI::parameter_changed (const char* parameter_name)
747 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
749 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
751 if (PARAM_IS ("slave-source")) {
753 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
755 } else if (PARAM_IS ("send-mtc")) {
757 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
759 } else if (PARAM_IS ("send-mmc")) {
761 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
763 } else if (PARAM_IS ("mmc-control")) {
764 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
765 } else if (PARAM_IS ("midi-feedback")) {
766 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
767 } else if (PARAM_IS ("midi-control")) {
768 ActionManager::map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
769 } else if (PARAM_IS ("do-not-record-plugins")) {
770 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
771 } else if (PARAM_IS ("latched-record-enable")) {
772 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
773 } else if (PARAM_IS ("solo-latched")) {
774 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
775 } else if (PARAM_IS ("solo-model")) {
777 } else if (PARAM_IS ("auto-play")) {
778 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
779 } else if (PARAM_IS ("auto-return")) {
780 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
781 } else if (PARAM_IS ("auto-input")) {
782 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
783 } else if (PARAM_IS ("punch-out")) {
784 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
785 } else if (PARAM_IS ("punch-in")) {
786 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
787 } else if (PARAM_IS ("clicking")) {
788 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
789 } else if (PARAM_IS ("jack-time-master")) {
790 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
791 } else if (PARAM_IS ("plugins-stop-with-transport")) {
792 ActionManager::map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
793 } else if (PARAM_IS ("latched-record-enable")) {
794 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
795 } else if (PARAM_IS ("verify-remove-last-capture")) {
796 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
797 } else if (PARAM_IS ("stop-recording-on-xrun")) {
798 ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
799 } else if (PARAM_IS ("stop-at-session-end")) {
800 ActionManager::map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
801 } else if (PARAM_IS ("monitoring-model")) {
802 map_monitor_model ();
803 } else if (PARAM_IS ("use-video-sync")) {
804 ActionManager::map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
805 } else if (PARAM_IS ("quieten-at-speed")) {
806 ActionManager::map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
807 } else if (PARAM_IS ("shuttle-behaviour")) {
809 switch (Config->get_shuttle_behaviour ()) {
811 shuttle_style_button.set_active_text (_("sprung"));
813 shuttle_box.queue_draw ();
815 if (session->transport_rolling()) {
816 shuttle_fract = SHUTTLE_FRACT_SPEED1;
817 session->request_transport_speed (1.0);
822 shuttle_style_button.set_active_text (_("wheel"));
826 } else if (PARAM_IS ("shuttle-units")) {
828 switch (Config->get_shuttle_units()) {
830 shuttle_units_button.set_label("% ");
833 shuttle_units_button.set_label(_("ST"));
836 } else if (PARAM_IS ("input-auto-connect")) {
837 map_input_auto_connect ();
838 } else if (PARAM_IS ("output-auto-connect")) {
839 map_output_auto_connect ();
840 } else if (PARAM_IS ("native-file-header-format")) {
841 map_file_header_format ();
842 } else if (PARAM_IS ("native-file-data-format")) {
843 map_file_data_format ();
844 } else if (PARAM_IS ("meter-hold")) {
846 } else if (PARAM_IS ("meter-falloff")) {
847 map_meter_falloff ();
848 } else if (PARAM_IS ("verify-remove-last-capture")) {
849 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
850 } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
852 primary_clock.set (session->audible_frame(), true);
853 secondary_clock.set (session->audible_frame(), true);
855 primary_clock.set (0, true);
856 secondary_clock.set (0, true);