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;
40 ARDOUR_UI::setup_config_options ()
44 bool (Configuration::*method)(void) const;
46 { "ToggleTimeMaster", &Configuration::get_jack_time_master },
47 { "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport },
48 { "LatchedRecordEnable", &Configuration::get_latched_record_enable },
49 { "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture },
50 { "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun },
51 { "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end },
55 for (uint32_t n = 0; options[n].name; ++n) {
56 Glib::RefPtr<Action> act = ActionManager::get_action ("options", options[n].name);
58 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
59 tact->set_active ((Config->*(options[n].method))());
65 ARDOUR_UI::toggle_time_master ()
67 toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master);
69 session->engine().reset_timebase ();
74 ARDOUR_UI::toggle_config_state (const char* group, const char* action, void (Configuration::*set)(bool))
76 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
78 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
79 (Config->*set) (tact->get_active());
84 ARDOUR_UI::toggle_session_state (const char* group, const char* action, void (Session::*set)(bool), bool (Session::*get)(void) const)
87 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
89 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
90 bool x = (session->*get)();
92 if (x != tact->get_active()) {
100 ARDOUR_UI::toggle_session_state (const char* group, const char* action, sigc::slot<void> theSlot)
103 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
105 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
106 if (tact->get_active()) {
114 ARDOUR_UI::toggle_send_mtc ()
116 toggle_session_state ("options", "SendMTC", &Session::set_send_mtc, &Session::get_send_mtc);
120 ARDOUR_UI::toggle_send_mmc ()
122 toggle_session_state ("options", "SendMMC", &Session::set_send_mmc, &Session::get_send_mmc);
126 ARDOUR_UI::toggle_use_mmc ()
128 toggle_session_state ("options", "UseMMC", &Session::set_mmc_control, &Session::get_mmc_control);
132 ARDOUR_UI::toggle_use_midi_control ()
134 toggle_session_state ("options", "UseMIDIcontrol", &Session::set_midi_control, &Session::get_midi_control);
138 ARDOUR_UI::toggle_send_midi_feedback ()
140 toggle_session_state ("options", "SendMIDIfeedback", &Session::set_midi_feedback, &Session::get_midi_feedback);
144 ARDOUR_UI::toggle_AutoConnectNewTrackInputsToHardware()
146 toggle_session_state ("options", "AutoConnectNewTrackInputsToHardware", &Session::set_input_auto_connect, &Session::get_input_auto_connect);
149 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToHardware()
151 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectPhysical));
154 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToMaster()
156 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectMaster));
159 ARDOUR_UI::toggle_ManuallyConnectNewTrackOutputs()
161 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectOption (0)));
165 ARDOUR_UI::toggle_auto_input ()
167 toggle_session_state ("Transport", "ToggleAutoInput", &Session::set_auto_input, &Session::get_auto_input);
171 ARDOUR_UI::toggle_auto_play ()
173 toggle_session_state ("Transport", "ToggleAutoPlay", &Session::set_auto_play, &Session::get_auto_play);
177 ARDOUR_UI::toggle_auto_return ()
179 toggle_session_state ("Transport", "ToggleAutoReturn", &Session::set_auto_return, &Session::get_auto_return);
183 ARDOUR_UI::toggle_click ()
185 toggle_session_state ("Transport", "ToggleClick", &Session::set_clicking, &Session::get_clicking);
189 ARDOUR_UI::toggle_session_auto_loop ()
192 if (session->get_auto_loop()) {
193 if (session->transport_rolling()) {
196 session->request_auto_loop (false);
199 session->request_auto_loop (true);
205 ARDOUR_UI::toggle_punch_in ()
207 toggle_session_state ("Transport", "TogglePunchIn", &Session::set_punch_in, &Session::get_punch_in);
211 ARDOUR_UI::toggle_punch_out ()
213 toggle_session_state ("Transport", "TogglePunchOut", &Session::set_punch_out, &Session::get_punch_out);
217 ARDOUR_UI::toggle_editing_space()
219 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
221 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
222 if (tact->get_active()) {
223 maximise_editing_space ();
225 restore_editing_space ();
231 ARDOUR_UI::toggle_UseHardwareMonitoring()
233 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseSoftwareMonitoring");
235 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
236 if (tact->get_active()) {
237 Config->set_use_hardware_monitoring (true);
238 Config->set_use_sw_monitoring (false);
240 session->reset_input_monitor_state();
247 ARDOUR_UI::toggle_UseSoftwareMonitoring()
249 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseSoftwareMonitoring");
251 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
252 if (tact->get_active()) {
253 Config->set_use_hardware_monitoring (false);
254 Config->set_use_sw_monitoring (true);
256 session->reset_input_monitor_state();
263 ARDOUR_UI::toggle_UseExternalMonitoring()
265 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseExternalMonitoring");
267 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
268 if (tact->get_active()) {
269 Config->set_use_hardware_monitoring (false);
270 Config->set_use_sw_monitoring (false);
272 session->reset_input_monitor_state();
279 ARDOUR_UI::toggle_StopPluginsWithTransport()
281 toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport);
285 ARDOUR_UI::toggle_LatchedRecordEnable()
287 toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable);
291 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
293 toggle_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::set_do_not_record_plugins, &Session::get_do_not_record_plugins);
297 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
299 toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture);
303 ARDOUR_UI::toggle_StopRecordingOnXrun()
305 toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun);
309 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
311 toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end);
315 ARDOUR_UI::toggle_GainReduceFastTransport()
317 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "GainReduceFastTransport");
319 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
320 if (tact->get_active()) {
321 Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
323 Config->set_quieten_at_speed (1.0); /* no change */
329 ARDOUR_UI::toggle_LatchedSolo()
331 toggle_session_state ("options", "LatchedSolo", &Session::set_solo_latched, &Session::solo_latched);
335 ARDOUR_UI::toggle_SoloViaBus()
341 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "SoloViaBus");
343 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
345 if (tact->get_active()) {
346 session->set_solo_model (Session::SoloBus);
348 session->set_solo_model (Session::InverseMute);
354 ARDOUR_UI::toggle_AutomaticallyCreateCrossfades()
358 ARDOUR_UI::toggle_UnmuteNewFullCrossfades()
363 ARDOUR_UI::mtc_port_changed ()
368 if (session->mtc_port()) {
378 const gchar *psync_strings[] = {
385 positional_sync_strings = PBD::internationalize (psync_strings);
388 const gchar *psync_strings[] = {
393 positional_sync_strings = PBD::internationalize (psync_strings);
396 set_popdown_strings (sync_option_combo, positional_sync_strings);
400 ARDOUR_UI::setup_session_options ()
404 session_control_changed (Session::SlaveType);
405 session_control_changed (Session::SendMTC);
406 session_control_changed (Session::SendMMC);
407 session_control_changed (Session::MMCControl);
408 session_control_changed (Session::MidiFeedback);
409 session_control_changed (Session::MidiControl);
410 session_control_changed (Session::RecordingPlugins);
411 session_control_changed (Session::CrossFadesActive);
412 session_control_changed (Session::SoloLatch);
413 session_control_changed (Session::SoloingModel);
414 session_control_changed (Session::LayeringModel);
415 session_control_changed (Session::CrossfadingModel);
416 session_control_changed (Session::PunchOut);
417 session_control_changed (Session::PunchIn);
418 session_control_changed (Session::AutoPlay);
419 session_control_changed (Session::AutoReturn);
420 session_control_changed (Session::AutoInput);
421 session_control_changed (Session::Clicking);
423 session->ControlChanged.connect (mem_fun (*this, &ARDOUR_UI::queue_session_control_changed));
427 ARDOUR_UI::map_some_session_state (const char* group, const char* action, bool (Session::*get)() const)
433 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
435 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
436 bool x = (session->*get)();
437 if (tact->get_active() != x) {
438 tact->set_active (x);
444 ARDOUR_UI::queue_session_control_changed (Session::ControlType t)
446 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::session_control_changed), t));
450 ARDOUR_UI::session_control_changed (Session::ControlType t)
453 case Session::SlaveType:
454 switch (session->slave_source()) {
456 sync_option_combo.set_active_text (_("Internal"));
459 sync_option_combo.set_active_text (_("MTC"));
462 sync_option_combo.set_active_text (_("JACK"));
468 case Session::SendMTC:
469 map_some_session_state ("options", "SendMTC", &Session::get_send_mtc);
472 case Session::SendMMC:
473 map_some_session_state ("options", "SendMMC", &Session::get_send_mmc);
476 case Session::MMCControl:
477 map_some_session_state ("options", "UseMMC", &Session::get_mmc_control);
480 case Session::MidiFeedback:
481 map_some_session_state ("options", "SendMIDIfeedback", &Session::get_midi_feedback);
484 case Session::MidiControl:
485 map_some_session_state ("options", "UseMIDIcontrol", &Session::get_midi_control);
488 case Session::RecordingPlugins:
489 map_some_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::get_do_not_record_plugins);
492 case Session::CrossFadesActive:
493 map_some_session_state ("options", "CrossfadesActive", &Session::get_crossfades_active);
496 case Session::SoloLatch:
499 case Session::SoloingModel:
500 switch (session->solo_model()) {
501 case Session::InverseMute:
503 case Session::SoloBus:
508 case Session::LayeringModel:
511 case Session::CrossfadingModel:
515 case Session::AutoPlay:
516 map_some_session_state ("Transport", "ToggleAutoPlay", &Session::get_auto_play);
519 case Session::AutoLoop:
522 case Session::AutoReturn:
523 map_some_session_state ("Transport", "ToggleAutoReturn", &Session::get_auto_return);
526 case Session::AutoInput:
527 map_some_session_state ("Transport", "ToggleAutoInput", &Session::get_auto_input);
530 case Session::PunchOut:
531 map_some_session_state ("Transport", "TogglePunchOut", &Session::get_punch_out);
534 case Session::PunchIn:
535 map_some_session_state ("Transport", "TogglePunchIn", &Session::get_punch_in);
538 case Session::Clicking:
539 map_some_session_state ("Transport", "ToggleClick", &Session::get_clicking);
543 // somebody else handles this