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 ()
42 std::vector<Glib::ustring> groups;
43 groups.push_back("options");
44 groups.push_back("Editor");
48 bool (Configuration::*method)(void) const;
49 char act_type; //(t)oggle or (r)adio
51 { "ToggleTimeMaster", &Configuration::get_jack_time_master, 't' },
52 { "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport, 't' },
53 { "LatchedRecordEnable", &Configuration::get_latched_record_enable, 't' },
54 { "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture, 't' },
55 { "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun, 't' },
56 { "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end, 't' },
57 { "UseHardwareMonitoring", &Configuration::get_use_hardware_monitoring, 'r' },
58 { "UseSoftwareMonitoring", &Configuration::get_use_sw_monitoring, 'r' },
59 { "UseExternalMonitoring", &Configuration::get_use_external_monitoring, 'r' },
60 { "MeterFalloffOff", &Configuration::get_meter_falloff_off, 'r' },
61 { "MeterFalloffSlowest", &Configuration::get_meter_falloff_slowest, 'r' },
62 { "MeterFalloffSlow", &Configuration::get_meter_falloff_slow, 'r' },
63 { "MeterFalloffMedium", &Configuration::get_meter_falloff_medium, 'r' },
64 { "MeterFalloffFast", &Configuration::get_meter_falloff_fast, 'r' },
65 { "MeterFalloffFaster", &Configuration::get_meter_falloff_faster, 'r' },
66 { "MeterFalloffFastest", &Configuration::get_meter_falloff_fastest, 'r' },
67 { "MeterHoldOff", &Configuration::get_meter_hold_off, 'r' },
68 { "MeterHoldShort", &Configuration::get_meter_hold_short, 'r' },
69 { "MeterHoldMedium", &Configuration::get_meter_hold_medium, 'r' },
70 { "MeterHoldLong", &Configuration::get_meter_hold_long, 'r' },
74 for (uint32_t n = 0; options[n].name; ++n) {
75 for (std::vector<Glib::ustring>::iterator i = groups.begin(); i != groups.end(); i++) {
76 Glib::RefPtr<Action> act = ActionManager::get_action (i->c_str(), options[n].name);
78 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
79 if (options[n].act_type == 't' || (options[n].act_type == 'r' && (Config->*(options[n].method))()))
80 tact->set_active ((Config->*(options[n].method))());
88 ARDOUR_UI::toggle_time_master ()
90 toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master);
92 session->engine().reset_timebase ();
97 ARDOUR_UI::toggle_config_state (const char* group, const char* action, void (Configuration::*set)(bool))
99 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
101 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
102 (Config->*set) (tact->get_active());
107 ARDOUR_UI::toggle_session_state (const char* group, const char* action, void (Session::*set)(bool), bool (Session::*get)(void) const)
110 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
112 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
113 bool x = (session->*get)();
115 if (x != tact->get_active()) {
116 (session->*set) (!x);
123 ARDOUR_UI::toggle_session_state (const char* group, const char* action, sigc::slot<void> theSlot)
126 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
128 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
129 if (tact->get_active()) {
137 ARDOUR_UI::toggle_send_mtc ()
139 toggle_session_state ("options", "SendMTC", &Session::set_send_mtc, &Session::get_send_mtc);
143 ARDOUR_UI::toggle_send_mmc ()
145 toggle_session_state ("options", "SendMMC", &Session::set_send_mmc, &Session::get_send_mmc);
149 ARDOUR_UI::toggle_use_mmc ()
151 toggle_session_state ("options", "UseMMC", &Session::set_mmc_control, &Session::get_mmc_control);
155 ARDOUR_UI::toggle_use_midi_control ()
157 toggle_session_state ("options", "UseMIDIcontrol", &Session::set_midi_control, &Session::get_midi_control);
161 ARDOUR_UI::toggle_send_midi_feedback ()
163 toggle_session_state ("options", "SendMIDIfeedback", &Session::set_midi_feedback, &Session::get_midi_feedback);
167 ARDOUR_UI::toggle_AutoConnectNewTrackInputsToHardware()
169 toggle_session_state ("options", "AutoConnectNewTrackInputsToHardware", &Session::set_input_auto_connect, &Session::get_input_auto_connect);
172 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToHardware()
174 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectPhysical));
177 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToMaster()
179 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectMaster));
182 ARDOUR_UI::toggle_ManuallyConnectNewTrackOutputs()
184 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectOption (0)));
188 ARDOUR_UI::toggle_auto_input ()
190 toggle_session_state ("Transport", "ToggleAutoInput", &Session::set_auto_input, &Session::get_auto_input);
194 ARDOUR_UI::toggle_auto_play ()
196 toggle_session_state ("Transport", "ToggleAutoPlay", &Session::set_auto_play, &Session::get_auto_play);
200 ARDOUR_UI::toggle_auto_return ()
202 toggle_session_state ("Transport", "ToggleAutoReturn", &Session::set_auto_return, &Session::get_auto_return);
206 ARDOUR_UI::toggle_click ()
208 toggle_session_state ("Transport", "ToggleClick", &Session::set_clicking, &Session::get_clicking);
212 ARDOUR_UI::toggle_session_auto_loop ()
215 if (session->get_auto_loop()) {
216 if (session->transport_rolling()) {
219 session->request_auto_loop (false);
222 session->request_auto_loop (true);
228 ARDOUR_UI::toggle_punch_in ()
230 toggle_session_state ("Transport", "TogglePunchIn", &Session::set_punch_in, &Session::get_punch_in);
234 ARDOUR_UI::toggle_punch_out ()
236 toggle_session_state ("Transport", "TogglePunchOut", &Session::set_punch_out, &Session::get_punch_out);
240 ARDOUR_UI::toggle_editing_space()
242 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
244 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
245 if (tact->get_active()) {
246 maximise_editing_space ();
248 restore_editing_space ();
254 ARDOUR_UI::toggle_UseHardwareMonitoring()
256 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseHardwareMonitoring");
258 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
259 if (tact->get_active()) {
260 Config->set_use_hardware_monitoring (true);
261 Config->set_use_sw_monitoring (false);
262 Config->set_use_external_monitoring (false);
264 session->reset_input_monitor_state();
271 ARDOUR_UI::toggle_UseSoftwareMonitoring()
273 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseSoftwareMonitoring");
275 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
276 if (tact->get_active()) {
277 Config->set_use_hardware_monitoring (false);
278 Config->set_use_sw_monitoring (true);
279 Config->set_use_external_monitoring (false);
281 session->reset_input_monitor_state();
288 ARDOUR_UI::toggle_UseExternalMonitoring()
290 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseExternalMonitoring");
292 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
293 if (tact->get_active()) {
294 Config->set_use_hardware_monitoring (false);
295 Config->set_use_sw_monitoring (false);
296 Config->set_use_external_monitoring (true);
298 session->reset_input_monitor_state();
305 ARDOUR_UI::toggle_StopPluginsWithTransport()
307 toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport);
311 ARDOUR_UI::toggle_LatchedRecordEnable()
313 toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable);
317 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
319 toggle_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::set_do_not_record_plugins, &Session::get_do_not_record_plugins);
323 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
325 toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture);
329 ARDOUR_UI::toggle_StopRecordingOnXrun()
331 toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun);
335 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
337 toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end);
341 ARDOUR_UI::toggle_GainReduceFastTransport()
343 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "GainReduceFastTransport");
345 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
346 if (tact->get_active()) {
347 Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
349 Config->set_quieten_at_speed (1.0); /* no change */
355 ARDOUR_UI::toggle_LatchedSolo()
357 toggle_session_state ("options", "LatchedSolo", &Session::set_solo_latched, &Session::solo_latched);
361 ARDOUR_UI::toggle_SoloViaBus()
367 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "SoloViaBus");
369 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
371 if (tact->get_active()) {
372 session->set_solo_model (Session::SoloBus);
374 session->set_solo_model (Session::InverseMute);
380 ARDOUR_UI::toggle_AutomaticallyCreateCrossfades()
384 ARDOUR_UI::toggle_UnmuteNewFullCrossfades()
389 ARDOUR_UI::mtc_port_changed ()
394 if (session->mtc_port()) {
404 const gchar *psync_strings[] = {
411 positional_sync_strings = PBD::internationalize (psync_strings);
414 const gchar *psync_strings[] = {
419 positional_sync_strings = PBD::internationalize (psync_strings);
422 set_popdown_strings (sync_option_combo, positional_sync_strings);
426 ARDOUR_UI::setup_session_options ()
430 session_control_changed (Session::SlaveType);
431 session_control_changed (Session::SendMTC);
432 session_control_changed (Session::SendMMC);
433 session_control_changed (Session::MMCControl);
434 session_control_changed (Session::MidiFeedback);
435 session_control_changed (Session::MidiControl);
436 session_control_changed (Session::RecordingPlugins);
437 session_control_changed (Session::CrossFadesActive);
438 session_control_changed (Session::SoloLatch);
439 session_control_changed (Session::SoloingModel);
440 session_control_changed (Session::LayeringModel);
441 session_control_changed (Session::CrossfadingModel);
442 session_control_changed (Session::PunchOut);
443 session_control_changed (Session::PunchIn);
444 session_control_changed (Session::AutoPlay);
445 session_control_changed (Session::AutoReturn);
446 session_control_changed (Session::AutoInput);
447 session_control_changed (Session::Clicking);
449 session->ControlChanged.connect (mem_fun (*this, &ARDOUR_UI::queue_session_control_changed));
453 ARDOUR_UI::map_some_session_state (const char* group, const char* action, bool (Session::*get)() const)
459 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
461 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
462 bool x = (session->*get)();
463 if (tact->get_active() != x) {
464 tact->set_active (x);
470 ARDOUR_UI::queue_session_control_changed (Session::ControlType t)
472 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::session_control_changed), t));
476 ARDOUR_UI::session_control_changed (Session::ControlType t)
479 case Session::SlaveType:
480 switch (session->slave_source()) {
482 sync_option_combo.set_active_text (_("Internal"));
485 sync_option_combo.set_active_text (_("MTC"));
488 sync_option_combo.set_active_text (_("JACK"));
494 case Session::SendMTC:
495 map_some_session_state ("options", "SendMTC", &Session::get_send_mtc);
498 case Session::SendMMC:
499 map_some_session_state ("options", "SendMMC", &Session::get_send_mmc);
502 case Session::MMCControl:
503 map_some_session_state ("options", "UseMMC", &Session::get_mmc_control);
506 case Session::MidiFeedback:
507 map_some_session_state ("options", "SendMIDIfeedback", &Session::get_midi_feedback);
510 case Session::MidiControl:
511 map_some_session_state ("options", "UseMIDIcontrol", &Session::get_midi_control);
514 case Session::RecordingPlugins:
515 map_some_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::get_do_not_record_plugins);
518 case Session::CrossFadesActive:
519 map_some_session_state ("options", "CrossfadesActive", &Session::get_crossfades_active);
522 case Session::SoloLatch:
525 case Session::SoloingModel:
526 switch (session->solo_model()) {
527 case Session::InverseMute:
529 case Session::SoloBus:
534 case Session::LayeringModel:
537 case Session::CrossfadingModel:
541 case Session::AutoPlay:
542 map_some_session_state ("Transport", "ToggleAutoPlay", &Session::get_auto_play);
545 case Session::AutoLoop:
548 case Session::AutoReturn:
549 map_some_session_state ("Transport", "ToggleAutoReturn", &Session::get_auto_return);
552 case Session::AutoInput:
553 map_some_session_state ("Transport", "ToggleAutoInput", &Session::get_auto_input);
556 case Session::PunchOut:
557 map_some_session_state ("Transport", "TogglePunchOut", &Session::get_punch_out);
560 case Session::PunchIn:
561 map_some_session_state ("Transport", "TogglePunchIn", &Session::get_punch_in);
564 case Session::Clicking:
565 map_some_session_state ("Transport", "ToggleClick", &Session::get_clicking);
569 // somebody else handles this