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 solo model in ARDOUR_UI::set_solo_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) {
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 /* XXX hack alert. Fix this. Please */
592 float val = Config->get_meter_falloff ();
593 MeterFalloff code = (MeterFalloff) (int) (floor (val));
596 case MeterFalloffOff:
597 action = X_("MeterFalloffOff");
599 case MeterFalloffSlowest:
600 action = X_("MeterFalloffSlowest");
602 case MeterFalloffSlow:
603 action = X_("MeterFalloffSlow");
605 case MeterFalloffMedium:
606 action = X_("MeterFalloffMedium");
608 case MeterFalloffFast:
609 action = X_("MeterFalloffFast");
611 case MeterFalloffFaster:
612 action = X_("MeterFalloffFaster");
614 case MeterFalloffFastest:
615 action = X_("MeterFalloffFastest");
619 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
622 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
623 if (ract && !ract->get_active()) {
624 ract->set_active (true);
630 ARDOUR_UI::map_meter_hold ()
632 const char* action = X_("MeterHoldMedium");
634 /* XXX hack alert. Fix this. Please */
636 float val = Config->get_meter_hold ();
637 MeterHold code = (MeterHold) (int) (floor (val));
641 action = X_("MeterHoldOff");
644 action = X_("MeterHoldShort");
646 case MeterHoldMedium:
647 action = X_("MeterHoldMedium");
650 action = X_("MeterHoldLong");
654 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
657 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
658 if (ract && !ract->get_active()) {
659 ract->set_active (true);
665 ARDOUR_UI::set_meter_hold (MeterHold val)
667 const char* action = 0;
670 fval = meter_hold_to_float (val);
674 action = X_("MeterHoldOff");
677 action = X_("MeterHoldShort");
679 case MeterHoldMedium:
680 action = X_("MeterHoldMedium");
683 action = X_("MeterHoldLong");
687 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
690 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
691 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
692 Config->set_meter_hold (fval);
698 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
700 const char* action = 0;
703 fval = meter_falloff_to_float (val);
706 case MeterFalloffOff:
707 action = X_("MeterFalloffOff");
709 case MeterFalloffSlowest:
710 action = X_("MeterFalloffSlowest");
712 case MeterFalloffSlow:
713 action = X_("MeterFalloffSlow");
715 case MeterFalloffMedium:
716 action = X_("MeterFalloffMedium");
718 case MeterFalloffFast:
719 action = X_("MeterFalloffFast");
721 case MeterFalloffFaster:
722 action = X_("MeterFalloffFaster");
724 case MeterFalloffFastest:
725 action = X_("MeterFalloffFastest");
729 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
732 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
733 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
734 Config->set_meter_falloff (fval);
740 ARDOUR_UI::parameter_changed (const char* parameter_name)
742 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
744 if (PARAM_IS ("slave-source")) {
746 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
748 } else if (PARAM_IS ("send-mtc")) {
750 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
752 } else if (PARAM_IS ("send-mmc")) {
754 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
756 } else if (PARAM_IS ("mmc-control")) {
757 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
758 } else if (PARAM_IS ("midi-feedback")) {
759 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
760 } else if (PARAM_IS ("midi-control")) {
761 ActionManager::map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
762 } else if (PARAM_IS ("do-not-record-plugins")) {
763 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
764 } else if (PARAM_IS ("latched-record-enable")) {
765 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
766 } else if (PARAM_IS ("solo-latched")) {
767 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
768 } else if (PARAM_IS ("solo-model")) {
770 } else if (PARAM_IS ("auto-play")) {
771 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
772 } else if (PARAM_IS ("auto-return")) {
773 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
774 } else if (PARAM_IS ("auto-input")) {
775 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
776 } else if (PARAM_IS ("punch-out")) {
777 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
778 } else if (PARAM_IS ("punch-in")) {
779 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
780 } else if (PARAM_IS ("clicking")) {
781 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
782 } else if (PARAM_IS ("jack-time-master")) {
783 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
784 } else if (PARAM_IS ("plugins-stop-with-transport")) {
785 ActionManager::map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
786 } else if (PARAM_IS ("latched-record-enable")) {
787 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
788 } else if (PARAM_IS ("verify-remove-last-capture")) {
789 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
790 } else if (PARAM_IS ("stop-recording-on-xrun")) {
791 ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
792 } else if (PARAM_IS ("stop-at-session-end")) {
793 ActionManager::map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
794 } else if (PARAM_IS ("monitoring-model")) {
795 map_monitor_model ();
796 } else if (PARAM_IS ("use-video-sync")) {
797 ActionManager::map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
798 } else if (PARAM_IS ("quieten-at-speed")) {
799 ActionManager::map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
800 } else if (PARAM_IS ("shuttle-behaviour")) {
802 switch (Config->get_shuttle_behaviour ()) {
804 shuttle_style_button.set_active_text (_("sprung"));
806 shuttle_box.queue_draw ();
808 if (session->transport_rolling()) {
809 shuttle_fract = SHUTTLE_FRACT_SPEED1;
810 session->request_transport_speed (1.0);
815 shuttle_style_button.set_active_text (_("wheel"));
819 } else if (PARAM_IS ("shuttle-units")) {
821 switch (Config->get_shuttle_units()) {
823 shuttle_units_button.set_label("% ");
826 shuttle_units_button.set_label(_("ST"));
829 } else if (PARAM_IS ("input-auto-connect")) {
830 map_input_auto_connect ();
831 } else if (PARAM_IS ("output-auto-connect")) {
832 map_output_auto_connect ();
833 } else if (PARAM_IS ("native-file-header-format")) {
834 map_file_header_format ();
835 } else if (PARAM_IS ("native-file-data-format")) {
836 map_file_data_format ();
837 } else if (PARAM_IS ("meter-hold")) {
839 } else if (PARAM_IS ("meter-falloff")) {
840 map_meter_falloff ();
841 } else if (PARAM_IS ("verify-remove-last-capture")) {
842 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);