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;
41 ARDOUR_UI::setup_config_options ()
43 std::vector<Glib::ustring> groups;
44 groups.push_back("options");
45 groups.push_back("Editor");
49 bool (Configuration::*method)(void) const;
50 char act_type; //(t)oggle or (r)adio
52 { "ToggleTimeMaster", &Configuration::get_jack_time_master, 't' },
53 { "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport, 't' },
54 { "LatchedRecordEnable", &Configuration::get_latched_record_enable, 't' },
55 { "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture, 't' },
56 { "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun, 't' },
57 { "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end, 't' },
58 { "UseHardwareMonitoring", &Configuration::get_use_hardware_monitoring, 'r' },
59 { "UseSoftwareMonitoring", &Configuration::get_use_sw_monitoring, 'r' },
60 { "UseExternalMonitoring", &Configuration::get_use_external_monitoring, 'r' },
61 { "MeterFalloffOff", &Configuration::get_meter_falloff_off, 'r' },
62 { "MeterFalloffSlowest", &Configuration::get_meter_falloff_slowest, 'r' },
63 { "MeterFalloffSlow", &Configuration::get_meter_falloff_slow, 'r' },
64 { "MeterFalloffMedium", &Configuration::get_meter_falloff_medium, 'r' },
65 { "MeterFalloffFast", &Configuration::get_meter_falloff_fast, 'r' },
66 { "MeterFalloffFaster", &Configuration::get_meter_falloff_faster, 'r' },
67 { "MeterFalloffFastest", &Configuration::get_meter_falloff_fastest, 'r' },
68 { "MeterHoldOff", &Configuration::get_meter_hold_off, 'r' },
69 { "MeterHoldShort", &Configuration::get_meter_hold_short, 'r' },
70 { "MeterHoldMedium", &Configuration::get_meter_hold_medium, 'r' },
71 { "MeterHoldLong", &Configuration::get_meter_hold_long, 'r' },
75 for (uint32_t n = 0; options[n].name; ++n) {
76 for (std::vector<Glib::ustring>::iterator i = groups.begin(); i != groups.end(); i++) {
77 Glib::RefPtr<Action> act = ActionManager::get_action (i->c_str(), options[n].name);
79 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
80 if (options[n].act_type == 't' || (options[n].act_type == 'r' && (Config->*(options[n].method))()))
81 tact->set_active ((Config->*(options[n].method))());
89 ARDOUR_UI::toggle_time_master ()
91 toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master);
93 session->engine().reset_timebase ();
98 ARDOUR_UI::toggle_config_state (const char* group, const char* action, void (Configuration::*set)(bool))
100 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
102 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
103 (Config->*set) (tact->get_active());
108 ARDOUR_UI::toggle_session_state (const char* group, const char* action, void (Session::*set)(bool), bool (Session::*get)(void) const)
111 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
113 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
114 bool x = (session->*get)();
116 if (x != tact->get_active()) {
117 (session->*set) (!x);
124 ARDOUR_UI::toggle_session_state (const char* group, const char* action, sigc::slot<void> theSlot)
127 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
129 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
130 if (tact->get_active()) {
138 ARDOUR_UI::toggle_send_mtc ()
140 toggle_session_state ("options", "SendMTC", &Session::set_send_mtc, &Session::get_send_mtc);
144 ARDOUR_UI::toggle_send_mmc ()
146 toggle_session_state ("options", "SendMMC", &Session::set_send_mmc, &Session::get_send_mmc);
150 ARDOUR_UI::toggle_use_mmc ()
152 toggle_session_state ("options", "UseMMC", &Session::set_mmc_control, &Session::get_mmc_control);
156 ARDOUR_UI::toggle_use_midi_control ()
158 toggle_session_state ("options", "UseMIDIcontrol", &Session::set_midi_control, &Session::get_midi_control);
162 ARDOUR_UI::toggle_send_midi_feedback ()
164 toggle_session_state ("options", "SendMIDIfeedback", &Session::set_midi_feedback, &Session::get_midi_feedback);
168 ARDOUR_UI::toggle_AutoConnectNewTrackInputsToHardware()
170 toggle_session_state ("options", "AutoConnectNewTrackInputsToHardware", &Session::set_input_auto_connect, &Session::get_input_auto_connect);
173 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToHardware()
175 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectPhysical));
178 ARDOUR_UI::toggle_AutoConnectNewTrackOutputsToMaster()
180 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectMaster));
183 ARDOUR_UI::toggle_ManuallyConnectNewTrackOutputs()
185 toggle_session_state ("options", "AutoConnectNewTrackOutputsToHardware", bind (mem_fun (session, &Session::set_output_auto_connect), Session::AutoConnectOption (0)));
189 ARDOUR_UI::toggle_auto_input ()
191 toggle_session_state ("Transport", "ToggleAutoInput", &Session::set_auto_input, &Session::get_auto_input);
195 ARDOUR_UI::toggle_auto_play ()
197 toggle_session_state ("Transport", "ToggleAutoPlay", &Session::set_auto_play, &Session::get_auto_play);
201 ARDOUR_UI::toggle_auto_return ()
203 toggle_session_state ("Transport", "ToggleAutoReturn", &Session::set_auto_return, &Session::get_auto_return);
207 ARDOUR_UI::toggle_click ()
209 toggle_session_state ("Transport", "ToggleClick", &Session::set_clicking, &Session::get_clicking);
213 ARDOUR_UI::toggle_session_auto_loop ()
216 if (session->get_auto_loop()) {
217 if (session->transport_rolling()) {
220 session->request_auto_loop (false);
223 session->request_auto_loop (true);
229 ARDOUR_UI::toggle_punch_in ()
231 toggle_session_state ("Transport", "TogglePunchIn", &Session::set_punch_in, &Session::get_punch_in);
235 ARDOUR_UI::toggle_punch_out ()
237 toggle_session_state ("Transport", "TogglePunchOut", &Session::set_punch_out, &Session::get_punch_out);
241 ARDOUR_UI::toggle_editing_space()
243 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
245 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
246 if (tact->get_active()) {
247 maximise_editing_space ();
249 restore_editing_space ();
255 ARDOUR_UI::toggle_UseHardwareMonitoring()
257 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseHardwareMonitoring");
259 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
260 if (tact->get_active()) {
261 Config->set_use_hardware_monitoring (true);
262 Config->set_use_sw_monitoring (false);
263 Config->set_use_external_monitoring (false);
265 session->reset_input_monitor_state();
272 ARDOUR_UI::toggle_UseSoftwareMonitoring()
274 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseSoftwareMonitoring");
276 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
277 if (tact->get_active()) {
278 Config->set_use_hardware_monitoring (false);
279 Config->set_use_sw_monitoring (true);
280 Config->set_use_external_monitoring (false);
282 session->reset_input_monitor_state();
289 ARDOUR_UI::toggle_UseExternalMonitoring()
291 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "UseExternalMonitoring");
293 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
294 if (tact->get_active()) {
295 Config->set_use_hardware_monitoring (false);
296 Config->set_use_sw_monitoring (false);
297 Config->set_use_external_monitoring (true);
299 session->reset_input_monitor_state();
306 ARDOUR_UI::toggle_StopPluginsWithTransport()
308 toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport);
312 ARDOUR_UI::toggle_LatchedRecordEnable()
314 toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable);
318 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
320 toggle_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::set_do_not_record_plugins, &Session::get_do_not_record_plugins);
324 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
326 toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture);
330 ARDOUR_UI::toggle_StopRecordingOnXrun()
332 toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun);
336 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
338 toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end);
342 ARDOUR_UI::toggle_GainReduceFastTransport()
344 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "GainReduceFastTransport");
346 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
347 if (tact->get_active()) {
348 Config->set_quieten_at_speed (0.251189); // -12dB reduction for ffwd or rewind
350 Config->set_quieten_at_speed (1.0); /* no change */
356 ARDOUR_UI::toggle_LatchedSolo()
358 toggle_session_state ("options", "LatchedSolo", &Session::set_solo_latched, &Session::solo_latched);
362 ARDOUR_UI::toggle_SoloViaBus()
368 Glib::RefPtr<Action> act = ActionManager::get_action ("options", "SoloViaBus");
370 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
372 if (tact->get_active()) {
373 session->set_solo_model (Session::SoloBus);
375 session->set_solo_model (Session::InverseMute);
381 ARDOUR_UI::toggle_AutomaticallyCreateCrossfades()
385 ARDOUR_UI::toggle_UnmuteNewFullCrossfades()
390 ARDOUR_UI::mtc_port_changed ()
395 if (session->mtc_port()) {
405 const gchar *psync_strings[] = {
412 positional_sync_strings = PBD::internationalize (psync_strings);
415 const gchar *psync_strings[] = {
420 positional_sync_strings = PBD::internationalize (psync_strings);
423 set_popdown_strings (sync_option_combo, positional_sync_strings);
427 ARDOUR_UI::setup_session_options ()
431 session_control_changed (Session::SlaveType);
432 session_control_changed (Session::SendMTC);
433 session_control_changed (Session::SendMMC);
434 session_control_changed (Session::MMCControl);
435 session_control_changed (Session::MidiFeedback);
436 session_control_changed (Session::MidiControl);
437 session_control_changed (Session::RecordingPlugins);
438 session_control_changed (Session::CrossFadesActive);
439 session_control_changed (Session::SoloLatch);
440 session_control_changed (Session::SoloingModel);
441 session_control_changed (Session::LayeringModel);
442 session_control_changed (Session::CrossfadingModel);
443 session_control_changed (Session::PunchOut);
444 session_control_changed (Session::PunchIn);
445 session_control_changed (Session::AutoPlay);
446 session_control_changed (Session::AutoReturn);
447 session_control_changed (Session::AutoInput);
448 session_control_changed (Session::Clicking);
450 session->ControlChanged.connect (mem_fun (*this, &ARDOUR_UI::queue_session_control_changed));
454 ARDOUR_UI::map_some_session_state (const char* group, const char* action, bool (Session::*get)() const)
460 Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
462 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
463 bool x = (session->*get)();
464 if (tact->get_active() != x) {
465 tact->set_active (x);
471 ARDOUR_UI::queue_session_control_changed (Session::ControlType t)
473 ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::session_control_changed), t));
477 ARDOUR_UI::session_control_changed (Session::ControlType t)
480 case Session::SlaveType:
481 switch (session->slave_source()) {
483 sync_option_combo.set_active_text (_("Internal"));
486 sync_option_combo.set_active_text (_("MTC"));
489 sync_option_combo.set_active_text (_("JACK"));
495 case Session::SendMTC:
496 map_some_session_state ("options", "SendMTC", &Session::get_send_mtc);
499 case Session::SendMMC:
500 map_some_session_state ("options", "SendMMC", &Session::get_send_mmc);
503 case Session::MMCControl:
504 map_some_session_state ("options", "UseMMC", &Session::get_mmc_control);
507 case Session::MidiFeedback:
508 map_some_session_state ("options", "SendMIDIfeedback", &Session::get_midi_feedback);
511 case Session::MidiControl:
512 map_some_session_state ("options", "UseMIDIcontrol", &Session::get_midi_control);
515 case Session::RecordingPlugins:
516 map_some_session_state ("options", "DoNotRunPluginsWhileRecording", &Session::get_do_not_record_plugins);
519 case Session::CrossFadesActive:
520 map_some_session_state ("options", "CrossfadesActive", &Session::get_crossfades_active);
523 case Session::SoloLatch:
526 case Session::SoloingModel:
527 switch (session->solo_model()) {
528 case Session::InverseMute:
530 case Session::SoloBus:
535 case Session::LayeringModel:
538 case Session::CrossfadingModel:
542 case Session::AutoPlay:
543 map_some_session_state ("Transport", "ToggleAutoPlay", &Session::get_auto_play);
546 case Session::AutoLoop:
549 case Session::AutoReturn:
550 map_some_session_state ("Transport", "ToggleAutoReturn", &Session::get_auto_return);
553 case Session::AutoInput:
554 map_some_session_state ("Transport", "ToggleAutoInput", &Session::get_auto_input);
557 case Session::PunchOut:
558 map_some_session_state ("Transport", "TogglePunchOut", &Session::get_punch_out);
561 case Session::PunchIn:
562 map_some_session_state ("Transport", "TogglePunchIn", &Session::get_punch_in);
565 case Session::Clicking:
566 map_some_session_state ("Transport", "ToggleClick", &Session::get_clicking);
570 // somebody else handles this