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_config_state (const char* group, const char* action, bool (Configuration::*set)(bool), bool (Configuration::*get)(void) const)
44 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
46 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
49 bool x = (Config->*get)();
51 if (x != tact->get_active()) {
59 ARDOUR_UI::toggle_config_state (const char* group, const char* action, sigc::slot<void> theSlot)
62 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
64 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
65 if (tact->get_active()) {
73 ARDOUR_UI::toggle_time_master ()
75 toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
77 session->engine().reset_timebase ();
82 ARDOUR_UI::toggle_send_mtc ()
84 toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
88 ARDOUR_UI::toggle_send_mmc ()
90 toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
94 ARDOUR_UI::toggle_use_mmc ()
96 toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
100 ARDOUR_UI::toggle_use_midi_control ()
102 toggle_config_state ("options", "UseMIDIcontrol", &Configuration::set_midi_control, &Configuration::get_midi_control);
106 ARDOUR_UI::toggle_send_midi_feedback ()
108 toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
112 ARDOUR_UI::toggle_AutoConnectNewTrackInputsToHardware()
114 toggle_config_state ("options", "AutoConnectNewTrackInputsToHardware", hide_return (bind (mem_fun (*Config, &Configuration::set_input_auto_connect), AutoConnectPhysical)));
117 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToHardware()
119 toggle_config_state ("options", "AutoConnectNewTrackOutputsToHardware", hide_return (bind (mem_fun (*Config, &Configuration::set_output_auto_connect), AutoConnectPhysical)));
122 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToMaster()
124 toggle_config_state ("options", "AutoConnectNewTrackOutputsToHardware", hide_return (bind (mem_fun (*Config, &Configuration::set_output_auto_connect), AutoConnectMaster)));
127 ARDOUR_UI::toggle_ManuallyConnectNewTrackOutputs()
129 toggle_config_state ("options", "AutoConnectNewTrackOutputsToHardware", hide_return (bind (mem_fun (*Config, &Configuration::set_output_auto_connect), AutoConnectOption (0))));
133 ARDOUR_UI::toggle_auto_input ()
135 toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
139 ARDOUR_UI::toggle_auto_play ()
141 toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
145 ARDOUR_UI::toggle_auto_return ()
147 toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
151 ARDOUR_UI::toggle_click ()
153 toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
157 ARDOUR_UI::toggle_session_auto_loop ()
160 if (Config->get_auto_loop()) {
161 if (session->transport_rolling()) {
164 session->request_play_loop (false);
167 session->request_play_loop (true);
173 ARDOUR_UI::toggle_punch_in ()
175 toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
179 ARDOUR_UI::toggle_punch_out ()
181 toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
185 ARDOUR_UI::toggle_video_sync()
187 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
189 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
190 Config->set_use_video_sync (tact->get_active());
195 ARDOUR_UI::toggle_editing_space()
197 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
199 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
200 if (tact->get_active()) {
201 maximise_editing_space ();
203 restore_editing_space ();
209 ARDOUR_UI::toggle_UseHardwareMonitoring()
211 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseHardwareMonitoring");
213 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
214 if (tact->get_active()) {
215 Config->set_use_hardware_monitoring (true);
216 Config->set_use_sw_monitoring (false);
217 Config->set_use_external_monitoring (false);
219 session->reset_input_monitor_state();
226 ARDOUR_UI::toggle_UseSoftwareMonitoring()
228 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseSoftwareMonitoring");
230 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
231 if (tact->get_active()) {
232 Config->set_use_hardware_monitoring (false);
233 Config->set_use_sw_monitoring (true);
234 Config->set_use_external_monitoring (false);
236 session->reset_input_monitor_state();
243 ARDOUR_UI::toggle_UseExternalMonitoring()
245 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseExternalMonitoring");
247 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
248 if (tact->get_active()) {
249 Config->set_use_hardware_monitoring (false);
250 Config->set_use_sw_monitoring (false);
251 Config->set_use_external_monitoring (true);
253 session->reset_input_monitor_state();
260 ARDOUR_UI::toggle_StopPluginsWithTransport()
262 toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
266 ARDOUR_UI::toggle_LatchedRecordEnable()
268 toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
272 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
274 toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
278 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
280 toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
284 ARDOUR_UI::toggle_StopRecordingOnXrun()
286 toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
290 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
292 toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
296 ARDOUR_UI::toggle_GainReduceFastTransport()
298 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "GainReduceFastTransport");
300 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
301 if (tact->get_active()) {
302 Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
304 Config->set_quieten_at_speed (1.0); /* no change */
310 ARDOUR_UI::toggle_LatchedSolo()
312 toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
316 ARDOUR_UI::toggle_SoloViaBus()
322 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "SoloViaBus");
324 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
326 if (tact->get_active()) {
327 Config->set_solo_model (SoloBus);
329 Config->set_solo_model (InverseMute);
335 ARDOUR_UI::toggle_AutomaticallyCreateCrossfades()
340 ARDOUR_UI::toggle_UnmuteNewFullCrossfades()
345 ARDOUR_UI::mtc_port_changed ()
350 if (session->mtc_port()) {
359 positional_sync_strings.clear ();
360 positional_sync_strings.push_back (slave_source_to_string (None));
362 positional_sync_strings.push_back (slave_source_to_string (MTC));
364 positional_sync_strings.push_back (slave_source_to_string (JACK));
366 set_popdown_strings (sync_option_combo, positional_sync_strings);
370 ARDOUR_UI::setup_session_options ()
374 Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
378 ARDOUR_UI::map_some_state (const char* group, const char* action, bool (Configuration::*get)() const)
380 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
382 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
385 bool x = (Config->*get)();
387 if (tact->get_active() != x) {
388 tact->set_active (x);
395 ARDOUR_UI::parameter_changed (const char* parameter_name)
397 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
399 if (PARAM_IS ("slave-source")) {
401 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
403 } else if (PARAM_IS ("send-mtc")) {
405 map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
407 } else if (PARAM_IS ("send-mmc")) {
409 map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
411 } else if (PARAM_IS ("mmc-control")) {
412 map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
413 } else if (PARAM_IS ("midi-feedback")) {
414 map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
415 } else if (PARAM_IS ("midi-control")) {
416 map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
417 } else if (PARAM_IS ("do-not-record-plugins")) {
418 map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
419 } else if (PARAM_IS ("crossfades-active")) {
420 map_some_state ("options", "CrossfadesActive", &Configuration::get_crossfades_active);
421 } else if (PARAM_IS ("latched-record-enable")) {
422 map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
423 } else if (PARAM_IS ("solo-latch")) {
424 map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
425 } else if (PARAM_IS ("solo-model")) {
426 } else if (PARAM_IS ("layer-model")) {
427 } else if (PARAM_IS ("crossfade-model")) {
428 } else if (PARAM_IS ("auto-play")) {
429 map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
430 } else if (PARAM_IS ("auto-loop")) {
431 map_some_state ("Transport", "Loop", &Configuration::get_auto_loop);
432 } else if (PARAM_IS ("auto-return")) {
433 map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
434 } else if (PARAM_IS ("auto-input")) {
435 map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
436 } else if (PARAM_IS ("punch-out")) {
437 map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
438 } else if (PARAM_IS ("punch-in")) {
439 map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
440 } else if (PARAM_IS ("clicking")) {
441 map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
442 } else if (PARAM_IS ("jack-time-master")) {
443 map_some_state ("Transport", "ToggleTimeMaster", &Configuration::get_jack_time_master);
444 } else if (PARAM_IS ("plugins-stop-with-transport")) {
445 map_some_state ("options", "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
446 } else if (PARAM_IS ("latched-record-enable")) {
447 map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
448 } else if (PARAM_IS ("verify-remove-last-capture")) {
449 map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
450 } else if (PARAM_IS ("stop-recording-on-xrun")) {
451 map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
452 } else if (PARAM_IS ("stop-at-session-end")) {
453 map_some_state ("options", "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
454 } else if (PARAM_IS ("use-hardware-monitoring")) {
455 map_some_state ("options", "UseHardwareMonitoring", &Configuration::get_use_hardware_monitoring);
456 } else if (PARAM_IS ("use-sw-monitoring")) {
457 map_some_state ("options", "UseSoftwareMonitoring", &Configuration::get_use_sw_monitoring);
458 } else if (PARAM_IS ("use-external-monitoring")) {
459 map_some_state ("options", "UseExternalMonitoring", &Configuration::get_use_external_monitoring);
460 } else if (PARAM_IS ("use-video-sync")) {
461 map_some_state ("Transport", "ToggleVideoSync", &Configuration::get_use_video_sync);
462 } else if (PARAM_IS ("quieten-at-speed")) {
463 map_some_state ("options", "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
464 } else if (PARAM_IS ("shuttle-behaviour")) {
466 switch (Config->get_shuttle_behaviour ()) {
468 shuttle_style_button.set_active_text (_("sprung"));
470 shuttle_box.queue_draw ();
472 if (session->transport_rolling()) {
473 shuttle_fract = SHUTTLE_FRACT_SPEED1;
474 session->request_transport_speed (1.0);
479 shuttle_style_button.set_active_text (_("wheel"));
483 } else if (PARAM_IS ("shuttle-units")) {
485 switch (Config->get_shuttle_units()) {
487 shuttle_units_button.set_label("% ");
490 shuttle_units_button.set_label(_("ST"));