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 (Config->get_auto_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 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "GainReduceFastTransport");
372 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
373 if (tact->get_active()) {
374 Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
376 Config->set_quieten_at_speed (1.0); /* no change */
382 ARDOUR_UI::toggle_LatchedSolo()
384 ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
388 ARDOUR_UI::mtc_port_changed ()
393 if (session->mtc_port()) {
402 positional_sync_strings.clear ();
403 positional_sync_strings.push_back (slave_source_to_string (None));
405 positional_sync_strings.push_back (slave_source_to_string (MTC));
407 positional_sync_strings.push_back (slave_source_to_string (JACK));
409 set_popdown_strings (sync_option_combo, positional_sync_strings);
413 ARDOUR_UI::setup_session_options ()
417 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
422 ARDOUR_UI::map_solo_model ()
426 if (Config->get_solo_model() == InverseMute) {
432 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
434 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
436 if (tact && !tact->get_active()) {
437 tact->set_active (true);
443 ARDOUR_UI::map_monitor_model ()
447 switch (Config->get_monitoring_model()) {
448 case HardwareMonitoring:
449 on = X_("UseHardwareMonitoring");
451 case SoftwareMonitoring:
452 on = X_("UseSoftwareMonitoring");
454 case ExternalMonitoring:
455 on = X_("UseExternalMonitoring");
459 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
461 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
463 if (tact && !tact->get_active()) {
464 tact->set_active (true);
470 ARDOUR_UI::map_file_header_format ()
472 const char* action = 0;
474 switch (Config->get_native_file_header_format()) {
476 action = X_("FileHeaderFormatBWF");
480 action = X_("FileHeaderFormatWAVE");
484 action = X_("FileHeaderFormatWAVE64");
488 action = X_("FileHeaderFormatiXML");
492 action = X_("FileHeaderFormatRF64");
496 action = X_("FileHeaderFormatCAF");
500 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"),
501 Config->get_native_file_header_format()) << endmsg;
506 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
509 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
511 if (tact && !tact->get_active()) {
512 tact->set_active (true);
518 ARDOUR_UI::map_file_data_format ()
520 const char* action = 0;
522 switch (Config->get_native_file_data_format()) {
524 action = X_("FileDataFormatFloat");
528 action = X_("FileDataFormat24bit");
532 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"),
533 Config->get_native_file_data_format()) << endmsg;
538 Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
541 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
543 if (tact && !tact->get_active()) {
544 tact->set_active (true);
550 ARDOUR_UI::map_input_auto_connect ()
554 if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
555 on = "InputAutoConnectManual";
557 on = "InputAutoConnectPhysical";
560 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
562 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
564 if (tact && !tact->get_active()) {
565 tact->set_active (true);
571 ARDOUR_UI::map_output_auto_connect ()
575 if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
576 on = "OutputAutoConnectManual";
577 } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
578 on = "OutputAutoConnectPhysical";
580 on = "OutputAutoConnectMaster";
583 Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
585 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
587 if (tact && !tact->get_active()) {
588 tact->set_active (true);
594 ARDOUR_UI::map_meter_falloff ()
596 const char* action = 0;
598 /* XXX hack alert. Fix this. Please */
600 float val = Config->get_meter_falloff ();
601 MeterFalloff code = (MeterFalloff) (floor (val));
604 case MeterFalloffOff:
605 action = X_("MeterFalloffOff");
607 case MeterFalloffSlowest:
608 action = X_("MeterFalloffSlowest");
610 case MeterFalloffSlow:
611 action = X_("MeterFalloffSlow");
613 case MeterFalloffMedium:
614 action = X_("MeterFalloffMedium");
616 case MeterFalloffFast:
617 action = X_("MeterFalloffFast");
619 case MeterFalloffFaster:
620 action = X_("MeterFalloffFaster");
622 case MeterFalloffFastest:
623 action = X_("MeterFalloffFastest");
627 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
630 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
631 if (ract && !ract->get_active()) {
632 ract->set_active (true);
638 ARDOUR_UI::map_meter_hold ()
640 const char* action = 0;
642 /* XXX hack alert. Fix this. Please */
644 float val = Config->get_meter_hold ();
645 MeterHold code = (MeterHold) (floor (val));
649 action = X_("MeterHoldOff");
652 action = X_("MeterHoldShort");
654 case MeterHoldMedium:
655 action = X_("MeterHoldMedium");
658 action = X_("MeterHoldLong");
662 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
665 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
666 if (ract && !ract->get_active()) {
667 ract->set_active (true);
673 ARDOUR_UI::set_meter_hold (MeterHold val)
675 const char* action = 0;
678 fval = meter_hold_to_float (val);
682 action = X_("MeterHoldOff");
685 action = X_("MeterHoldShort");
687 case MeterHoldMedium:
688 action = X_("MeterHoldMedium");
691 action = X_("MeterHoldLong");
695 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
698 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
699 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
700 Config->set_meter_hold (fval);
706 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
708 const char* action = 0;
711 fval = meter_falloff_to_float (val);
714 case MeterFalloffOff:
715 action = X_("MeterFalloffOff");
717 case MeterFalloffSlowest:
718 action = X_("MeterFalloffSlowest");
720 case MeterFalloffSlow:
721 action = X_("MeterFalloffSlow");
723 case MeterFalloffMedium:
724 action = X_("MeterFalloffMedium");
726 case MeterFalloffFast:
727 action = X_("MeterFalloffFast");
729 case MeterFalloffFaster:
730 action = X_("MeterFalloffFaster");
732 case MeterFalloffFastest:
733 action = X_("MeterFalloffFastest");
737 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
740 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
741 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
742 Config->set_meter_falloff (fval);
748 ARDOUR_UI::parameter_changed (const char* parameter_name)
750 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
752 if (PARAM_IS ("slave-source")) {
754 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
756 } else if (PARAM_IS ("send-mtc")) {
758 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
760 } else if (PARAM_IS ("send-mmc")) {
762 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
764 } else if (PARAM_IS ("mmc-control")) {
765 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
766 } else if (PARAM_IS ("midi-feedback")) {
767 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
768 } else if (PARAM_IS ("midi-control")) {
769 ActionManager::map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
770 } else if (PARAM_IS ("do-not-record-plugins")) {
771 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
772 } else if (PARAM_IS ("latched-record-enable")) {
773 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
774 } else if (PARAM_IS ("solo-latched")) {
775 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
776 } else if (PARAM_IS ("solo-model")) {
778 } else if (PARAM_IS ("auto-play")) {
779 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
780 } else if (PARAM_IS ("auto-loop")) {
781 ActionManager::map_some_state ("Transport", "Loop", &Configuration::get_auto_loop);
782 } else if (PARAM_IS ("auto-return")) {
783 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
784 } else if (PARAM_IS ("auto-input")) {
785 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
786 } else if (PARAM_IS ("punch-out")) {
787 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
788 } else if (PARAM_IS ("punch-in")) {
789 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
790 } else if (PARAM_IS ("clicking")) {
791 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
792 } else if (PARAM_IS ("jack-time-master")) {
793 ActionManager::map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
794 } else if (PARAM_IS ("plugins-stop-with-transport")) {
795 ActionManager::map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
796 } else if (PARAM_IS ("latched-record-enable")) {
797 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
798 } else if (PARAM_IS ("verify-remove-last-capture")) {
799 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
800 } else if (PARAM_IS ("stop-recording-on-xrun")) {
801 ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
802 } else if (PARAM_IS ("stop-at-session-end")) {
803 ActionManager::map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
804 } else if (PARAM_IS ("monitoring-model")) {
805 map_monitor_model ();
806 } else if (PARAM_IS ("use-video-sync")) {
807 ActionManager::map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
808 } else if (PARAM_IS ("quieten-at-speed")) {
809 ActionManager::map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
810 } else if (PARAM_IS ("shuttle-behaviour")) {
812 switch (Config->get_shuttle_behaviour ()) {
814 shuttle_style_button.set_active_text (_("sprung"));
816 shuttle_box.queue_draw ();
818 if (session->transport_rolling()) {
819 shuttle_fract = SHUTTLE_FRACT_SPEED1;
820 session->request_transport_speed (1.0);
825 shuttle_style_button.set_active_text (_("wheel"));
829 } else if (PARAM_IS ("shuttle-units")) {
831 switch (Config->get_shuttle_units()) {
833 shuttle_units_button.set_label("% ");
836 shuttle_units_button.set_label(_("ST"));
839 } else if (PARAM_IS ("input-auto-connect")) {
840 map_input_auto_connect ();
841 } else if (PARAM_IS ("output-auto-connect")) {
842 map_output_auto_connect ();
843 } else if (PARAM_IS ("native-file-header-format")) {
844 map_file_header_format ();
845 } else if (PARAM_IS ("native-file-data-format")) {
846 map_file_data_format ();
847 } else if (PARAM_IS ("meter-hold")) {
849 } else if (PARAM_IS ("meter-falloff")) {
850 map_meter_falloff ();
851 } else if (PARAM_IS ("verify-remove-last-capture")) {
852 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);