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");
107 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
110 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
111 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
112 Config->set_native_file_header_format (hf);
118 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
124 action = X_("FileDataFormatFloat");
127 action = X_("FileDataFormat24bit");
131 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
134 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
135 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
136 Config->set_native_file_data_format (sf);
142 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
147 case AutoConnectPhysical:
148 action = X_("InputAutoConnectPhysical");
151 action = X_("InputAutoConnectManual");
154 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
157 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
159 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
160 Config->set_input_auto_connect (option);
166 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
171 case AutoConnectPhysical:
172 action = X_("OutputAutoConnectPhysical");
174 case AutoConnectMaster:
175 action = X_("OutputAutoConnectMaster");
178 action = X_("OutputAutoConnectManual");
181 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
184 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
186 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
187 Config->set_output_auto_connect (option);
193 ARDOUR_UI::set_solo_model (SoloModel model)
195 const char* action = 0;
199 action = X_("SoloViaBus");
203 action = X_("SoloInPlace");
206 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
210 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
213 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
215 if (ract && ract->get_active() && Config->get_solo_model() != model) {
216 Config->set_solo_model (model);
223 ARDOUR_UI::set_monitor_model (MonitorModel model)
225 const char* action = 0;
228 case HardwareMonitoring:
229 action = X_("UseHardwareMonitoring");
232 case SoftwareMonitoring:
233 action = X_("UseSoftwareMonitoring");
235 case ExternalMonitoring:
236 action = X_("UseExternalMonitoring");
240 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
244 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
247 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
249 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
250 Config->set_monitoring_model (model);
257 ARDOUR_UI::toggle_auto_input ()
259 ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
263 ARDOUR_UI::toggle_auto_play ()
265 ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
269 ARDOUR_UI::toggle_auto_return ()
271 ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
275 ARDOUR_UI::toggle_click ()
277 ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
281 ARDOUR_UI::toggle_session_auto_loop ()
284 if (session->get_play_loop()) {
285 if (session->transport_rolling()) {
288 session->request_play_loop (false);
291 session->request_play_loop (true);
297 ARDOUR_UI::toggle_punch_in ()
299 ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
303 ARDOUR_UI::toggle_punch_out ()
305 ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
309 ARDOUR_UI::toggle_video_sync()
311 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
313 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
314 Config->set_use_video_sync (tact->get_active());
319 ARDOUR_UI::toggle_editing_space()
321 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
323 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
324 if (tact->get_active()) {
325 maximise_editing_space ();
327 restore_editing_space ();
333 ARDOUR_UI::toggle_StopPluginsWithTransport()
335 ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
339 ARDOUR_UI::toggle_LatchedRecordEnable()
341 ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
345 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
347 ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
351 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
353 ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
357 ARDOUR_UI::toggle_StopRecordingOnXrun()
359 ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
363 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
365 ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
369 ARDOUR_UI::toggle_GainReduceFastTransport()
371 ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
375 ARDOUR_UI::toggle_LatchedSolo()
377 ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
381 ARDOUR_UI::mtc_port_changed ()
386 if (session->mtc_port()) {
395 positional_sync_strings.clear ();
396 positional_sync_strings.push_back (slave_source_to_string (None));
398 positional_sync_strings.push_back (slave_source_to_string (MTC));
400 positional_sync_strings.push_back (slave_source_to_string (JACK));
402 set_popdown_strings (sync_option_combo, positional_sync_strings);
406 ARDOUR_UI::setup_session_options ()
410 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
415 ARDOUR_UI::map_solo_model ()
419 if (Config->get_solo_model() == InverseMute) {
420 on = X_("SoloInPlace");
422 on = X_("SoloViaBus");
425 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
427 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
429 if (tact && !tact->get_active()) {
430 tact->set_active (true);
436 ARDOUR_UI::map_monitor_model ()
440 switch (Config->get_monitoring_model()) {
441 case HardwareMonitoring:
442 on = X_("UseHardwareMonitoring");
444 case SoftwareMonitoring:
445 on = X_("UseSoftwareMonitoring");
447 case ExternalMonitoring:
448 on = X_("UseExternalMonitoring");
452 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
454 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
456 if (tact && !tact->get_active()) {
457 tact->set_active (true);
463 ARDOUR_UI::map_file_header_format ()
465 const char* action = 0;
467 switch (Config->get_native_file_header_format()) {
469 action = X_("FileHeaderFormatBWF");
473 action = X_("FileHeaderFormatWAVE");
477 action = X_("FileHeaderFormatWAVE64");
481 action = X_("FileHeaderFormatiXML");
485 action = X_("FileHeaderFormatRF64");
489 action = X_("FileHeaderFormatCAF");
493 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"),
494 Config->get_native_file_header_format()) << endmsg;
499 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
502 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
504 if (tact && !tact->get_active()) {
505 tact->set_active (true);
511 ARDOUR_UI::map_file_data_format ()
513 const char* action = 0;
515 switch (Config->get_native_file_data_format()) {
517 action = X_("FileDataFormatFloat");
521 action = X_("FileDataFormat24bit");
525 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"),
526 Config->get_native_file_data_format()) << endmsg;
531 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
534 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
536 if (tact && !tact->get_active()) {
537 tact->set_active (true);
543 ARDOUR_UI::map_input_auto_connect ()
547 if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
548 on = "InputAutoConnectManual";
550 on = "InputAutoConnectPhysical";
553 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
555 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
557 if (tact && !tact->get_active()) {
558 tact->set_active (true);
564 ARDOUR_UI::map_output_auto_connect ()
568 if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
569 on = "OutputAutoConnectManual";
570 } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
571 on = "OutputAutoConnectPhysical";
573 on = "OutputAutoConnectMaster";
576 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
578 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
580 if (tact && !tact->get_active()) {
581 tact->set_active (true);
587 ARDOUR_UI::map_meter_falloff ()
589 const char* action = X_("MeterFalloffMedium");
591 float val = Config->get_meter_falloff ();
592 MeterFalloff code = meter_falloff_from_float(val);
595 case MeterFalloffOff:
596 action = X_("MeterFalloffOff");
598 case MeterFalloffSlowest:
599 action = X_("MeterFalloffSlowest");
601 case MeterFalloffSlow:
602 action = X_("MeterFalloffSlow");
604 case MeterFalloffMedium:
605 action = X_("MeterFalloffMedium");
607 case MeterFalloffFast:
608 action = X_("MeterFalloffFast");
610 case MeterFalloffFaster:
611 action = X_("MeterFalloffFaster");
613 case MeterFalloffFastest:
614 action = X_("MeterFalloffFastest");
618 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
621 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
622 if (ract && !ract->get_active()) {
623 ract->set_active (true);
629 ARDOUR_UI::map_meter_hold ()
631 const char* action = X_("MeterHoldMedium");
633 /* XXX hack alert. Fix this. Please */
635 float val = Config->get_meter_hold ();
636 MeterHold code = (MeterHold) (int) (floor (val));
640 action = X_("MeterHoldOff");
643 action = X_("MeterHoldShort");
645 case MeterHoldMedium:
646 action = X_("MeterHoldMedium");
649 action = X_("MeterHoldLong");
653 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
656 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
657 if (ract && !ract->get_active()) {
658 ract->set_active (true);
664 ARDOUR_UI::set_meter_hold (MeterHold val)
666 const char* action = 0;
669 fval = meter_hold_to_float (val);
673 action = X_("MeterHoldOff");
676 action = X_("MeterHoldShort");
678 case MeterHoldMedium:
679 action = X_("MeterHoldMedium");
682 action = X_("MeterHoldLong");
686 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
689 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
690 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
691 Config->set_meter_hold (fval);
697 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
699 const char* action = 0;
702 fval = meter_falloff_to_float (val);
705 case MeterFalloffOff:
706 action = X_("MeterFalloffOff");
708 case MeterFalloffSlowest:
709 action = X_("MeterFalloffSlowest");
711 case MeterFalloffSlow:
712 action = X_("MeterFalloffSlow");
714 case MeterFalloffMedium:
715 action = X_("MeterFalloffMedium");
717 case MeterFalloffFast:
718 action = X_("MeterFalloffFast");
720 case MeterFalloffFaster:
721 action = X_("MeterFalloffFaster");
723 case MeterFalloffFastest:
724 action = X_("MeterFalloffFastest");
728 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
731 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
732 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
733 Config->set_meter_falloff (fval);
739 ARDOUR_UI::parameter_changed (const char* parameter_name)
741 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
743 if (PARAM_IS ("slave-source")) {
745 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
747 } else if (PARAM_IS ("send-mtc")) {
749 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
751 } else if (PARAM_IS ("send-mmc")) {
753 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
755 } else if (PARAM_IS ("mmc-control")) {
756 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
757 } else if (PARAM_IS ("midi-feedback")) {
758 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
759 } else if (PARAM_IS ("midi-control")) {
760 ActionManager::map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
761 } else if (PARAM_IS ("do-not-record-plugins")) {
762 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
763 } else if (PARAM_IS ("latched-record-enable")) {
764 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
765 } else if (PARAM_IS ("solo-latched")) {
766 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
767 } else if (PARAM_IS ("solo-model")) {
769 } else if (PARAM_IS ("auto-play")) {
770 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
771 } else if (PARAM_IS ("auto-return")) {
772 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
773 } else if (PARAM_IS ("auto-input")) {
774 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
775 } else if (PARAM_IS ("punch-out")) {
776 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
777 } else if (PARAM_IS ("punch-in")) {
778 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
779 } else if (PARAM_IS ("clicking")) {
780 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
781 } else if (PARAM_IS ("jack-time-master")) {
782 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
783 } else if (PARAM_IS ("plugins-stop-with-transport")) {
784 ActionManager::map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
785 } else if (PARAM_IS ("latched-record-enable")) {
786 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
787 } else if (PARAM_IS ("verify-remove-last-capture")) {
788 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
789 } else if (PARAM_IS ("stop-recording-on-xrun")) {
790 ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
791 } else if (PARAM_IS ("stop-at-session-end")) {
792 ActionManager::map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
793 } else if (PARAM_IS ("monitoring-model")) {
794 map_monitor_model ();
795 } else if (PARAM_IS ("use-video-sync")) {
796 ActionManager::map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
797 } else if (PARAM_IS ("quieten-at-speed")) {
798 ActionManager::map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
799 } else if (PARAM_IS ("shuttle-behaviour")) {
801 switch (Config->get_shuttle_behaviour ()) {
803 shuttle_style_button.set_active_text (_("sprung"));
805 shuttle_box.queue_draw ();
807 if (session->transport_rolling()) {
808 shuttle_fract = SHUTTLE_FRACT_SPEED1;
809 session->request_transport_speed (1.0);
814 shuttle_style_button.set_active_text (_("wheel"));
818 } else if (PARAM_IS ("shuttle-units")) {
820 switch (Config->get_shuttle_units()) {
822 shuttle_units_button.set_label("% ");
825 shuttle_units_button.set_label(_("ST"));
828 } else if (PARAM_IS ("input-auto-connect")) {
829 map_input_auto_connect ();
830 } else if (PARAM_IS ("output-auto-connect")) {
831 map_output_auto_connect ();
832 } else if (PARAM_IS ("native-file-header-format")) {
833 map_file_header_format ();
834 } else if (PARAM_IS ("native-file-data-format")) {
835 map_file_data_format ();
836 } else if (PARAM_IS ("meter-hold")) {
838 } else if (PARAM_IS ("meter-falloff")) {
839 map_meter_falloff ();
840 } else if (PARAM_IS ("verify-remove-last-capture")) {
841 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
842 } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
844 primary_clock.set (session->audible_frame(), true);
845 secondary_clock.set (session->audible_frame(), true);
847 primary_clock.set (0, true);
848 secondary_clock.set (0, true);