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>
23 #include <gtkmm2ext/utils.h>
25 #include <ardour/configuration.h>
26 #include <ardour/session.h>
27 #include <ardour/audioengine.h>
29 #include "ardour_ui.h"
31 #include "gui_thread.h"
36 using namespace Gtkmm2ext;
37 using namespace ARDOUR;
42 ARDOUR_UI::toggle_time_master ()
44 ActionManager::toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
48 ARDOUR_UI::toggle_send_mtc ()
50 ActionManager::toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
54 ARDOUR_UI::toggle_send_mmc ()
56 ActionManager::toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
60 ARDOUR_UI::toggle_use_mmc ()
62 ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
66 ARDOUR_UI::toggle_use_midi_control ()
68 ActionManager::toggle_config_state ("options", "UseMIDIcontrol", &Configuration::set_midi_control, &Configuration::get_midi_control);
72 ARDOUR_UI::toggle_send_midi_feedback ()
74 ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
78 ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
84 action = X_("FileHeaderFormatBWF");
87 action = X_("FileHeaderFormatWAVE");
90 action = X_("FileHeaderFormatWAVE64");
93 action = X_("FileHeaderFormatiXML");
96 action = X_("FileHeaderFormatRF64");
99 action = X_("FileHeaderFormatCAF");
102 action = X_("FileHeaderFormatAIFF");
106 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
109 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
110 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
111 Config->set_native_file_header_format (hf);
117 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
123 action = X_("FileDataFormatFloat");
126 action = X_("FileDataFormat24bit");
130 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
133 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
134 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
135 Config->set_native_file_data_format (sf);
141 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
146 case AutoConnectPhysical:
147 action = X_("InputAutoConnectPhysical");
150 action = X_("InputAutoConnectManual");
153 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
156 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
158 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
159 Config->set_input_auto_connect (option);
165 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
170 case AutoConnectPhysical:
171 action = X_("OutputAutoConnectPhysical");
173 case AutoConnectMaster:
174 action = X_("OutputAutoConnectMaster");
177 action = X_("OutputAutoConnectManual");
180 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
183 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
185 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
186 Config->set_output_auto_connect (option);
192 ARDOUR_UI::set_solo_model (SoloModel model)
194 const char* action = 0;
198 action = X_("SoloViaBus");
202 action = X_("SoloInPlace");
205 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
209 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
212 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
214 if (ract && ract->get_active() && Config->get_solo_model() != model) {
215 Config->set_solo_model (model);
222 ARDOUR_UI::set_monitor_model (MonitorModel model)
224 const char* action = 0;
227 case HardwareMonitoring:
228 action = X_("UseHardwareMonitoring");
231 case SoftwareMonitoring:
232 action = X_("UseSoftwareMonitoring");
234 case ExternalMonitoring:
235 action = X_("UseExternalMonitoring");
239 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
243 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
246 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
248 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
249 Config->set_monitoring_model (model);
256 ARDOUR_UI::toggle_auto_input ()
258 ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
262 ARDOUR_UI::toggle_auto_play ()
264 ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
268 ARDOUR_UI::toggle_auto_return ()
270 ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
274 ARDOUR_UI::toggle_click ()
276 ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
280 ARDOUR_UI::toggle_session_auto_loop ()
283 if (session->get_play_loop()) {
284 if (session->transport_rolling()) {
287 session->request_play_loop (false);
290 session->request_play_loop (true);
296 ARDOUR_UI::toggle_punch_in ()
298 ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
302 ARDOUR_UI::toggle_punch_out ()
304 ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
308 ARDOUR_UI::toggle_video_sync()
310 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
312 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
313 Config->set_use_video_sync (tact->get_active());
318 ARDOUR_UI::toggle_editing_space()
320 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
322 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
323 if (tact->get_active()) {
324 maximise_editing_space ();
326 restore_editing_space ();
332 ARDOUR_UI::toggle_StopPluginsWithTransport()
334 ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
338 ARDOUR_UI::toggle_LatchedRecordEnable()
340 ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
344 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
346 ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
350 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
352 ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
356 ARDOUR_UI::toggle_StopRecordingOnXrun()
358 ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
362 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
364 ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
368 ARDOUR_UI::toggle_GainReduceFastTransport()
370 ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
374 ARDOUR_UI::toggle_LatchedSolo()
376 ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
380 ARDOUR_UI::mtc_port_changed ()
385 if (session->mtc_port()) {
394 positional_sync_strings.clear ();
395 positional_sync_strings.push_back (slave_source_to_string (None));
397 positional_sync_strings.push_back (slave_source_to_string (MTC));
399 positional_sync_strings.push_back (slave_source_to_string (JACK));
401 set_popdown_strings (sync_option_combo, positional_sync_strings);
405 ARDOUR_UI::setup_session_options ()
409 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
414 ARDOUR_UI::map_solo_model ()
418 if (Config->get_solo_model() == InverseMute) {
419 on = X_("SoloInPlace");
421 on = X_("SoloViaBus");
424 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
426 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
428 if (tact && !tact->get_active()) {
429 tact->set_active (true);
435 ARDOUR_UI::map_monitor_model ()
439 switch (Config->get_monitoring_model()) {
440 case HardwareMonitoring:
441 on = X_("UseHardwareMonitoring");
443 case SoftwareMonitoring:
444 on = X_("UseSoftwareMonitoring");
446 case ExternalMonitoring:
447 on = X_("UseExternalMonitoring");
451 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
453 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
455 if (tact && !tact->get_active()) {
456 tact->set_active (true);
462 ARDOUR_UI::map_file_header_format ()
464 const char* action = 0;
466 switch (Config->get_native_file_header_format()) {
468 action = X_("FileHeaderFormatBWF");
472 action = X_("FileHeaderFormatWAVE");
476 action = X_("FileHeaderFormatWAVE64");
480 action = X_("FileHeaderFormatiXML");
484 action = X_("FileHeaderFormatRF64");
488 action = X_("FileHeaderFormatCAF");
492 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"),
493 Config->get_native_file_header_format()) << endmsg;
498 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
501 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
503 if (tact && !tact->get_active()) {
504 tact->set_active (true);
510 ARDOUR_UI::map_file_data_format ()
512 const char* action = 0;
514 switch (Config->get_native_file_data_format()) {
516 action = X_("FileDataFormatFloat");
520 action = X_("FileDataFormat24bit");
524 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"),
525 Config->get_native_file_data_format()) << endmsg;
530 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
533 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
535 if (tact && !tact->get_active()) {
536 tact->set_active (true);
542 ARDOUR_UI::map_input_auto_connect ()
546 if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
547 on = "InputAutoConnectManual";
549 on = "InputAutoConnectPhysical";
552 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
554 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
556 if (tact && !tact->get_active()) {
557 tact->set_active (true);
563 ARDOUR_UI::map_output_auto_connect ()
567 if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
568 on = "OutputAutoConnectManual";
569 } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
570 on = "OutputAutoConnectPhysical";
572 on = "OutputAutoConnectMaster";
575 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
577 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
579 if (tact && !tact->get_active()) {
580 tact->set_active (true);
586 ARDOUR_UI::map_meter_falloff ()
588 const char* action = X_("MeterFalloffMedium");
590 float val = Config->get_meter_falloff ();
591 MeterFalloff code = meter_falloff_from_float(val);
594 case MeterFalloffOff:
595 action = X_("MeterFalloffOff");
597 case MeterFalloffSlowest:
598 action = X_("MeterFalloffSlowest");
600 case MeterFalloffSlow:
601 action = X_("MeterFalloffSlow");
603 case MeterFalloffMedium:
604 action = X_("MeterFalloffMedium");
606 case MeterFalloffFast:
607 action = X_("MeterFalloffFast");
609 case MeterFalloffFaster:
610 action = X_("MeterFalloffFaster");
612 case MeterFalloffFastest:
613 action = X_("MeterFalloffFastest");
617 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
620 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
621 if (ract && !ract->get_active()) {
622 ract->set_active (true);
628 ARDOUR_UI::map_meter_hold ()
630 const char* action = X_("MeterHoldMedium");
632 /* XXX hack alert. Fix this. Please */
634 float val = Config->get_meter_hold ();
635 MeterHold code = (MeterHold) (int) (floor (val));
639 action = X_("MeterHoldOff");
642 action = X_("MeterHoldShort");
644 case MeterHoldMedium:
645 action = X_("MeterHoldMedium");
648 action = X_("MeterHoldLong");
652 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
655 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
656 if (ract && !ract->get_active()) {
657 ract->set_active (true);
663 ARDOUR_UI::set_meter_hold (MeterHold val)
665 const char* action = 0;
668 fval = meter_hold_to_float (val);
672 action = X_("MeterHoldOff");
675 action = X_("MeterHoldShort");
677 case MeterHoldMedium:
678 action = X_("MeterHoldMedium");
681 action = X_("MeterHoldLong");
685 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
688 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
689 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
690 Config->set_meter_hold (fval);
696 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
698 const char* action = 0;
701 fval = meter_falloff_to_float (val);
704 case MeterFalloffOff:
705 action = X_("MeterFalloffOff");
707 case MeterFalloffSlowest:
708 action = X_("MeterFalloffSlowest");
710 case MeterFalloffSlow:
711 action = X_("MeterFalloffSlow");
713 case MeterFalloffMedium:
714 action = X_("MeterFalloffMedium");
716 case MeterFalloffFast:
717 action = X_("MeterFalloffFast");
719 case MeterFalloffFaster:
720 action = X_("MeterFalloffFaster");
722 case MeterFalloffFastest:
723 action = X_("MeterFalloffFastest");
727 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
730 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
731 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
732 Config->set_meter_falloff (fval);
738 ARDOUR_UI::parameter_changed (const char* parameter_name)
740 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
742 if (PARAM_IS ("slave-source")) {
744 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
746 } else if (PARAM_IS ("send-mtc")) {
748 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
750 } else if (PARAM_IS ("send-mmc")) {
752 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
754 } else if (PARAM_IS ("mmc-control")) {
755 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
756 } else if (PARAM_IS ("midi-feedback")) {
757 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
758 } else if (PARAM_IS ("midi-control")) {
759 ActionManager::map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
760 } else if (PARAM_IS ("do-not-record-plugins")) {
761 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
762 } else if (PARAM_IS ("latched-record-enable")) {
763 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
764 } else if (PARAM_IS ("solo-latched")) {
765 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
766 } else if (PARAM_IS ("solo-model")) {
768 } else if (PARAM_IS ("auto-play")) {
769 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
770 } else if (PARAM_IS ("auto-return")) {
771 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
772 } else if (PARAM_IS ("auto-input")) {
773 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
774 } else if (PARAM_IS ("punch-out")) {
775 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
776 } else if (PARAM_IS ("punch-in")) {
777 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
778 } else if (PARAM_IS ("clicking")) {
779 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
780 } else if (PARAM_IS ("jack-time-master")) {
781 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
782 } else if (PARAM_IS ("plugins-stop-with-transport")) {
783 ActionManager::map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
784 } else if (PARAM_IS ("latched-record-enable")) {
785 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
786 } else if (PARAM_IS ("verify-remove-last-capture")) {
787 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
788 } else if (PARAM_IS ("stop-recording-on-xrun")) {
789 ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
790 } else if (PARAM_IS ("stop-at-session-end")) {
791 ActionManager::map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
792 } else if (PARAM_IS ("monitoring-model")) {
793 map_monitor_model ();
794 } else if (PARAM_IS ("use-video-sync")) {
795 ActionManager::map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
796 } else if (PARAM_IS ("quieten-at-speed")) {
797 ActionManager::map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
798 } else if (PARAM_IS ("shuttle-behaviour")) {
800 switch (Config->get_shuttle_behaviour ()) {
802 shuttle_style_button.set_active_text (_("sprung"));
804 shuttle_box.queue_draw ();
806 if (session->transport_rolling()) {
807 shuttle_fract = SHUTTLE_FRACT_SPEED1;
808 session->request_transport_speed (1.0);
813 shuttle_style_button.set_active_text (_("wheel"));
817 } else if (PARAM_IS ("shuttle-units")) {
819 switch (Config->get_shuttle_units()) {
821 shuttle_units_button.set_label("% ");
824 shuttle_units_button.set_label(_("ST"));
827 } else if (PARAM_IS ("input-auto-connect")) {
828 map_input_auto_connect ();
829 } else if (PARAM_IS ("output-auto-connect")) {
830 map_output_auto_connect ();
831 } else if (PARAM_IS ("native-file-header-format")) {
832 map_file_header_format ();
833 } else if (PARAM_IS ("native-file-data-format")) {
834 map_file_data_format ();
835 } else if (PARAM_IS ("meter-hold")) {
837 } else if (PARAM_IS ("meter-falloff")) {
838 map_meter_falloff ();
839 } else if (PARAM_IS ("verify-remove-last-capture")) {
840 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
841 } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
843 primary_clock.set (session->audible_frame(), true);
844 secondary_clock.set (session->audible_frame(), true);
846 primary_clock.set (0, true);
847 secondary_clock.set (0, true);