add crossfade and layering options to menu system; add missing crossfade editor curve...
[ardour.git] / libs / ardour / configuration.cc
1 /*
2     Copyright (C) 1999 Paul Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <unistd.h>
22 #include <cstdio> /* for snprintf, grrr */
23
24 #ifdef HAVE_WORDEXP
25 #include <wordexp.h>
26 #endif
27
28 #include <pbd/failed_constructor.h>
29 #include <pbd/xml++.h>
30
31 #include <ardour/ardour.h>
32 #include <ardour/configuration.h>
33 #include <ardour/diskstream.h>
34 #include <ardour/destructive_filesource.h>
35
36 #include "i18n.h"
37
38 using namespace ARDOUR;
39 using namespace std;
40
41 /* this is global so that we do not have to indirect through an object pointer
42    to reference it.
43 */
44
45 namespace ARDOUR {
46     float speed_quietning = 0.251189; // -12dB reduction for ffwd or rewind
47 }
48
49 Configuration::Configuration ()
50 {
51         key_node = 0;
52         user_configuration = false;
53         set_defaults ();
54 }
55
56 Configuration::~Configuration ()
57 {
58 }
59         
60 string
61 Configuration::get_user_path()
62 {
63         return find_config_file ("ardour.rc");
64 }
65
66 string
67 Configuration::get_system_path()
68 {
69         return find_config_file ("ardour_system.rc");
70 }
71
72 int
73 Configuration::load_state ()
74 {
75         string rcfile;
76         
77         /* load system configuration first */
78
79         rcfile = get_system_path ();
80
81         if (rcfile.length()) {
82
83                 XMLTree tree;
84                 
85                 if (!tree.read (rcfile.c_str())) {
86                         error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg;
87                         return -1;
88                 }
89
90                 if (set_state (*tree.root())) {
91                         error << string_compose(_("Ardour: system configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
92                         return -1;
93                 }
94         }
95
96         /* from this point on, all configuration changes are user driven */
97
98         user_configuration = true;
99
100         /* now load configuration file for user */
101         
102         rcfile = get_user_path ();
103
104         if (rcfile.length()) {
105
106                 XMLTree tree;
107                 
108                 if (!tree.read (rcfile)) {
109                         error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg;
110                         return -1;
111                 }
112                 
113                 
114                 if (set_state (*tree.root())) {
115                         error << string_compose(_("Ardour: configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
116                         return -1;
117                 }
118         }
119
120         return 0;
121 }
122
123 int
124 Configuration::save_state()
125 {
126         XMLTree tree;
127         string rcfile;
128
129         /* Note: this only writes the per-user file, and therefore
130            only saves variables marked as user-set or modified
131         */
132
133         rcfile = find_config_file("ardour.rc");
134
135         if (rcfile.length()) {
136                 tree.set_root (&state (true));
137                 if (!tree.write (rcfile.c_str())){
138                         error << _("Config file not saved") << endmsg;
139                         return -1;
140                 }
141         }
142
143         return 0;
144 }
145
146 XMLNode&
147 Configuration::get_state ()
148 {
149         return state (false);
150 }
151
152 XMLNode&
153 Configuration::state (bool user_only)
154 {
155         XMLNode* root = new XMLNode("Ardour");
156         LocaleGuard lg (X_("POSIX"));
157
158         typedef map<string, MidiPortDescriptor*>::const_iterator CI;
159         for(CI m = midi_ports.begin(); m != midi_ports.end(); ++m){
160                 root->add_child_nocopy(m->second->get_state());
161         }
162
163         XMLNode* node = new XMLNode("Config");
164         char buf[32];
165         
166         if (!user_only || minimum_disk_io_bytes_is_user) {
167                 snprintf(buf, sizeof(buf), "%" PRIu32 , minimum_disk_io_bytes);
168                 node->add_child_nocopy(option_node("minimum-disk-io-bytes", string(buf)));
169         }
170         if (!user_only || track_buffer_seconds_is_user) {
171                 snprintf(buf, sizeof(buf), "%f", track_buffer_seconds);
172                 node->add_child_nocopy(option_node("track-buffer-seconds", string(buf)));
173         }
174         if (!user_only || disk_choice_space_threshold_is_user) {
175                 snprintf(buf, sizeof(buf), "%" PRIu32, disk_choice_space_threshold);
176                 node->add_child_nocopy(option_node("disk-choice-space-threshold", string(buf)));
177         }
178
179         if (!user_only || midi_feedback_interval_ms_is_user) {
180                 snprintf(buf, sizeof(buf), "%" PRIu32, midi_feedback_interval_ms);
181                 node->add_child_nocopy(option_node("midi-feedback-interval-ms", string(buf)));
182         }
183
184         if (!user_only || mute_affects_pre_fader_is_user) {
185                 node->add_child_nocopy(option_node("mute-affects-pre-fader", mute_affects_pre_fader?"yes":"no"));
186         }
187         if (!user_only || mute_affects_post_fader_is_user) {
188                 node->add_child_nocopy(option_node("mute-affects-post-fader", mute_affects_post_fader?"yes":"no"));
189         }
190         if (!user_only || mute_affects_control_outs_is_user) {
191                 node->add_child_nocopy(option_node("mute-affects-control-outs", mute_affects_control_outs?"yes":"no"));
192         }
193         if (!user_only || mute_affects_main_outs_is_user) {
194                 node->add_child_nocopy(option_node("mute-affects-main-outs", mute_affects_main_outs?"yes":"no"));
195         }
196         if (!user_only || solo_latch_is_user) {
197                 node->add_child_nocopy(option_node("solo-latch", solo_latch?"yes":"no"));
198         }
199         if (!user_only || raid_path_is_user) {
200                 node->add_child_nocopy(option_node("raid-path", orig_raid_path));
201         }
202         if (!user_only || mtc_port_name_is_user) {
203                 node->add_child_nocopy(option_node("mtc-port", mtc_port_name));
204         }
205         if (!user_only || mmc_port_name_is_user) {
206                 node->add_child_nocopy(option_node("mmc-port", mmc_port_name));
207         }
208         if (!user_only || midi_port_name_is_user) {
209                 node->add_child_nocopy(option_node("midi-port", midi_port_name));
210         }
211         if (!user_only || use_hardware_monitoring_is_user) {
212                 node->add_child_nocopy(option_node("hardware-monitoring", use_hardware_monitoring?"yes":"no"));
213         }
214         if (!user_only || be_jack_time_master_is_user) {
215                 node->add_child_nocopy(option_node("jack-time-master", be_jack_time_master?"yes":"no"));
216         }
217         if (!user_only || native_format_is_bwf_is_user) {
218                 node->add_child_nocopy(option_node("native-format-bwf", native_format_is_bwf?"yes":"no"));
219         }
220         if (!user_only || trace_midi_input_is_user) {
221                 node->add_child_nocopy(option_node("trace-midi-input", trace_midi_input?"yes":"no"));
222         }
223         if (!user_only || trace_midi_output_is_user) {
224                 node->add_child_nocopy(option_node("trace-midi-output", trace_midi_output?"yes":"no"));
225         }
226         if (!user_only || plugins_stop_with_transport_is_user) {
227                 node->add_child_nocopy(option_node("plugins-stop-with-transport", plugins_stop_with_transport?"yes":"no"));
228         }
229         if (!user_only || use_sw_monitoring_is_user) {
230                 node->add_child_nocopy(option_node("use-sw-monitoring", use_sw_monitoring?"yes":"no"));
231         }
232         if (!user_only || stop_recording_on_xrun_is_user) {
233                 node->add_child_nocopy(option_node("stop-recording-on-xrun", stop_recording_on_xrun?"yes":"no"));
234         }
235         if (!user_only || verify_remove_last_capture_is_user) {
236                 node->add_child_nocopy(option_node("verify-remove-last-capture", verify_remove_last_capture?"yes":"no"));
237         }
238         if (!user_only || stop_at_session_end_is_user) {
239                 node->add_child_nocopy(option_node("stop-at-session-end", stop_at_session_end?"yes":"no"));
240         }
241         if (!user_only || seamless_looping_is_user) {
242                 node->add_child_nocopy(option_node("seamless-loop", seamless_looping?"yes":"no"));
243         }
244         if (!user_only || auto_xfade_is_user) {
245                 node->add_child_nocopy(option_node("auto-xfade", auto_xfade?"yes":"no"));
246         }
247         if (!user_only || no_new_session_dialog_is_user) {
248                 node->add_child_nocopy(option_node("no-new-session-dialog", no_new_session_dialog?"yes":"no"));
249         }
250         if (!user_only || timecode_source_is_synced_is_user) {
251                 node->add_child_nocopy(option_node("timecode-source-is-synced", timecode_source_is_synced?"yes":"no"));
252         }
253         if (!user_only || auditioner_output_left_is_user) {
254                 node->add_child_nocopy(option_node("auditioner-left-out", auditioner_output_left));
255         }
256         if (!user_only || auditioner_output_right_is_user) {
257                 node->add_child_nocopy(option_node("auditioner-right-out", auditioner_output_right));
258         }
259         if (!user_only || quieten_at_speed_is_user) {
260                 snprintf (buf, sizeof (buf), "%f", speed_quietning);
261                 node->add_child_nocopy(option_node("quieten-at-speed", buf));
262         }
263         if (!user_only || latched_record_enable_is_user) {
264                 node->add_child_nocopy(option_node("latched-record-enable", latched_record_enable?"yes":"no"));
265         }
266         if (!user_only || destructive_xfade_msecs_is_user) {
267                 snprintf(buf, sizeof(buf), "%" PRIu32, destructive_xfade_msecs);
268                 node->add_child_nocopy(option_node("destructive_xfade_msecs", string(buf)));
269         }
270
271         /* use-vst is always per-user */
272         node->add_child_nocopy (option_node ("use-vst", use_vst?"yes":"no"));
273
274         root->add_child_nocopy (*node);
275
276         if (key_node) {
277                 root->add_child_copy (*key_node);
278         }
279
280         if (_extra_xml) {
281                 root->add_child_copy (*_extra_xml);
282         }
283
284         return *root;
285 }
286
287 int
288 Configuration::set_state (const XMLNode& root)
289 {
290         if (root.name() != "Ardour") {
291                 return -1;
292         }
293
294         XMLNodeList nlist = root.children();
295         XMLNodeConstIterator niter;
296         XMLNode *node;
297         XMLProperty *prop;
298
299         for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
300
301                 node = *niter;
302
303                 if (node->name() == "MIDI-port") {
304
305                         try {
306                                 pair<string,MidiPortDescriptor*> newpair;
307                                 newpair.second = new MidiPortDescriptor (*node);
308                                 newpair.first = newpair.second->tag;
309                                 midi_ports.insert (newpair);
310                         }
311
312                         catch (failed_constructor& err) {
313                                 warning << _("ill-formed MIDI port specification in ardour rcfile (ignored)") << endmsg;
314                         }
315
316                 } else if (node->name() == "Config") {
317                         
318                         XMLNodeList option_list = node->children();
319                         XMLNodeConstIterator option_iter;
320                         XMLNode *option_node;
321
322                         string option_name;
323                         string option_value;
324
325                         for (option_iter = option_list.begin(); option_iter != option_list.end(); ++option_iter) {
326
327                                 option_node = *option_iter;
328
329                                 if (option_node->name() != "Option") {
330                                         continue;
331                                 }
332
333                                 if ((prop = option_node->property ("name")) != 0) {
334                                         option_name = prop->value();
335                                 } else {
336                                         throw failed_constructor ();
337                                 }
338                                 
339                                 if ((prop = option_node->property ("value")) != 0) {
340                                         option_value = prop->value();
341                                 } else {
342                                         throw failed_constructor ();
343                                 }
344                                 
345                                 if (option_name == "minimum-disk-io-bytes") {
346                                         set_minimum_disk_io (atoi (option_value.c_str()));
347                                 } else if (option_name == "track-buffer-seconds") {
348                                         set_track_buffer (atof (option_value.c_str()));
349                                 } else if (option_name == "raid-path") {
350                                         set_raid_path (option_value);
351                                 } else if (option_name == "hiding-groups-deactivates-groups") {
352                                         set_hiding_groups_deactivates_groups (option_value == "yes");
353                                 } else if (option_name == "mute-affects-pre-fader") {
354                                         set_mute_affects_pre_fader (option_value == "yes");
355                                 } else if (option_name == "mute-affects-post-fader") {
356                                         set_mute_affects_post_fader (option_value == "yes");
357                                 } else if (option_name == "mute-affects-control-outs") {
358                                         set_mute_affects_control_outs (option_value == "yes");
359                                 } else if (option_name == "mute-affects-main-outs") {
360                                         set_mute_affects_main_outs (option_value == "yes");
361                                 } else if (option_name == "solo-latch") {
362                                         set_solo_latch (option_value == "yes");
363                                 } else if (option_name == "mtc-port") {
364                                         set_mtc_port_name (option_value);
365                                 } else if (option_name == "mmc-port") {
366                                         set_mmc_port_name (option_value);
367                                 } else if (option_name == "midi-port") {
368                                         set_midi_port_name (option_value);
369                                 } else if (option_name == "hardware-monitoring") {
370                                         set_use_hardware_monitoring (option_value == "yes");
371                                 } else if (option_name == "jack-time-master") {
372                                         set_jack_time_master (option_value == "yes");
373                                 } else if (option_name == "trace-midi-input") {
374                                         set_trace_midi_input (option_value == "yes");
375                                 } else if (option_name == "trace-midi-output") {
376                                         set_trace_midi_output (option_value == "yes");
377                                 } else if (option_name == "plugins-stop-with-transport") {
378                                         set_plugins_stop_with_transport (option_value == "yes");
379                                 } else if (option_name == "use-sw-monitoring") {
380                                         set_use_sw_monitoring (option_value == "yes");
381                                 } else if (option_name == "no-sw-monitoring") {     /* DEPRECATED */
382                                         set_use_sw_monitoring (option_value != "yes");
383                                 } else if (option_name == "stop-recording-on-xrun") {
384                                         set_stop_recording_on_xrun (option_value == "yes");
385                                 } else if (option_name == "verify-remove-last-capture") {
386                                         set_verify_remove_last_capture (option_value == "yes");
387                                 } else if (option_name == "stop-at-session-end") {
388                                         set_stop_at_session_end (option_value == "yes");
389                                 } else if (option_name == "seamless-loop") {
390                                         set_seamless_looping (option_value == "yes");
391                                 } else if (option_name == "auto-xfade") {
392                                         set_auto_xfade (option_value == "yes");
393                                 } else if (option_name == "no-new-session-dialog") {
394                                         set_no_new_session_dialog (option_value == "yes");
395                                 } else if (option_name == "timecode-source-is-synced") {
396                                         set_timecode_source_is_synced (option_value == "yes");
397                                 } else if (option_name == "auditioner-left-out") {
398                                         set_auditioner_output_left (option_value);
399                                 } else if (option_name == "auditioner-right-out") {
400                                         set_auditioner_output_right (option_value);
401                                 } else if (option_name == "use-vst") {
402                                         set_use_vst (option_value == "yes");
403                                 } else if (option_name == "quieten-at-speed") {
404                                         float v;
405                                         if (sscanf (option_value.c_str(), "%f", &v) == 1) {
406                                                 set_quieten_at_speed (v);
407                                         }
408                                 } else if (option_name == "midi-feedback-interval-ms") {
409                                         set_midi_feedback_interval_ms (atoi (option_value.c_str()));
410                                 } else if (option_name == "latched-record-enable") {
411                                         set_latched_record_enable (option_value == "yes");
412                                 } else if (option_name == "destructive_xfade_msecs") {
413                                         uint32_t v;
414                                         if (sscanf (option_value.c_str(), "%u", &v) == 1) {
415                                                 set_destructive_xfade_msecs (v);
416                                         }
417                                 }
418                         }
419                         
420                 } else if (node->name() == "Keys") {
421                         /* defer handling of this for UI objects */
422                         key_node = new XMLNode (*node);
423                 } else if (node->name() == "extra") {
424                         _extra_xml = new XMLNode (*node);
425                 }
426         }
427
428         DiskStream::set_disk_io_chunk_frames (minimum_disk_io_bytes / sizeof (Sample));
429
430         return 0;
431 }
432
433 void
434 Configuration::set_defaults ()
435 {
436         raid_path = "";
437         orig_raid_path = raid_path;
438
439         mtc_port_name = N_("default");
440         mmc_port_name = N_("default");
441         midi_port_name = N_("default");
442 #ifdef __APPLE__
443         auditioner_output_left = N_("coreaudio:Built-in Audio:in1");
444         auditioner_output_right = N_("coreaudio:Built-in Audio:in2");
445 #else
446         auditioner_output_left = N_("alsa_pcm:playback_1");
447         auditioner_output_right = N_("alsa_pcm:playback_2");
448 #endif
449         minimum_disk_io_bytes = 1024 * 256;
450         track_buffer_seconds = 5.0;
451         hiding_groups_deactivates_groups = true;
452         mute_affects_pre_fader = 1;
453         mute_affects_post_fader = 1;
454         mute_affects_control_outs = 1;
455         mute_affects_main_outs = 1;
456         solo_latch = 1;
457         use_hardware_monitoring = true;
458         be_jack_time_master = true;
459         native_format_is_bwf = true;
460         trace_midi_input = false;
461         trace_midi_output = false;
462         plugins_stop_with_transport = false;
463         use_sw_monitoring = true;
464         stop_recording_on_xrun = false;
465         verify_remove_last_capture = true;
466         stop_at_session_end = true;
467         seamless_looping = true;
468         auto_xfade = true;
469         no_new_session_dialog = false;
470         timecode_source_is_synced = true;
471         use_vst = true; /* if we build with VST_SUPPORT, otherwise no effect */
472         quieten_at_speed = true;
473         destructive_xfade_msecs = 2;
474
475         midi_feedback_interval_ms = 100;
476         
477         // this is about 5 minutes at 48kHz, 4 bytes/sample
478         disk_choice_space_threshold = 57600000;
479
480         /* at this point, no variables from from the user */
481
482         raid_path_is_user = false;
483         minimum_disk_io_bytes_is_user = false;
484         track_buffer_seconds_is_user = false;
485         hiding_groups_deactivates_groups_is_user = false;
486         auditioner_output_left_is_user = false;
487         auditioner_output_right_is_user = false;
488         mute_affects_pre_fader_is_user = false;
489         mute_affects_post_fader_is_user = false;
490         mute_affects_control_outs_is_user = false;
491         mute_affects_main_outs_is_user = false;
492         solo_latch_is_user = false;
493         disk_choice_space_threshold_is_user = false;
494         mtc_port_name_is_user = false;
495         mmc_port_name_is_user = false;
496         midi_port_name_is_user = false;
497         use_hardware_monitoring_is_user = false;
498         be_jack_time_master_is_user = false;
499         native_format_is_bwf_is_user = false;
500         trace_midi_input_is_user = false;
501         trace_midi_output_is_user = false;
502         plugins_stop_with_transport_is_user = false;
503         use_sw_monitoring_is_user = false;
504         stop_recording_on_xrun_is_user = false;
505         verify_remove_last_capture_is_user = false;
506         stop_at_session_end_is_user = false;
507         seamless_looping_is_user = false;
508         auto_xfade_is_user = false;
509         no_new_session_dialog_is_user = false;
510         timecode_source_is_synced_is_user = false;
511         quieten_at_speed_is_user = false;
512         midi_feedback_interval_ms_is_user = false;
513         latched_record_enable_is_user = false;
514         destructive_xfade_msecs_is_user = false;
515 }
516
517 Configuration::MidiPortDescriptor::MidiPortDescriptor (const XMLNode& node)
518 {
519         const XMLProperty *prop;
520         bool have_tag = false;
521         bool have_device = false;
522         bool have_type = false;
523         bool have_mode = false;
524
525         if ((prop = node.property ("tag")) != 0) {
526                 tag = prop->value();
527                 have_tag = true;
528         }
529
530         if ((prop = node.property ("device")) != 0) {
531                 device = prop->value();
532                 have_device = true;
533         }
534
535         if ((prop = node.property ("type")) != 0) {
536                 type = prop->value();
537                 have_type = true;
538         }
539
540         if ((prop = node.property ("mode")) != 0) {
541                 mode = prop->value();
542                 have_mode = true;
543         }
544
545         if (!have_tag || !have_device || !have_type || !have_mode) {
546                 throw failed_constructor();
547         }
548 }
549
550 XMLNode&
551 Configuration::MidiPortDescriptor::get_state()
552 {
553         XMLNode* root = new XMLNode("MIDI-port");
554
555         root->add_property("tag", tag);
556         root->add_property("device", device);
557         root->add_property("type", type);
558         root->add_property("mode", mode);
559
560         return *root;
561 }
562
563 XMLNode&
564 Configuration::option_node(const string & name, const string & value)
565 {
566         XMLNode* root = new XMLNode("Option");
567
568         root->add_property("name", name);
569         root->add_property("value", value);
570         
571         return *root;
572 }
573
574 string
575 Configuration::get_raid_path()
576 {
577         return raid_path;
578 }
579
580 void
581 Configuration::set_raid_path(string path)
582 {
583 #ifdef HAVE_WORDEXP
584         /* Handle tilde and environment variable expansion in session path */
585         wordexp_t expansion;
586         switch (wordexp (path.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF)) {
587         case 0:
588                 break;
589         default:
590                 error << _("illegal or badly-formed string used for RAID path") << endmsg;
591                 return;
592         }
593
594         if (expansion.we_wordc > 1) {
595                 error << _("RAID search path is ambiguous") << endmsg;
596                 return;
597         }
598
599         raid_path = expansion.we_wordv[0];
600         orig_raid_path = path;
601         wordfree (&expansion);
602 #else
603         raid_path = orig_raid_path = path;
604 #endif
605
606         if (user_configuration) {
607                 raid_path_is_user = true;
608         }
609 }
610
611 uint32_t
612 Configuration::get_minimum_disk_io()
613 {
614         return minimum_disk_io_bytes;
615 }
616         
617 void
618 Configuration::set_minimum_disk_io(uint32_t min)
619 {
620         minimum_disk_io_bytes = min;
621         if (user_configuration) {
622                 minimum_disk_io_bytes_is_user = true;
623         }
624 }
625
626 float
627 Configuration::get_track_buffer()
628 {
629         return track_buffer_seconds;
630 }
631
632 void 
633 Configuration::set_track_buffer(float buffer)
634 {
635         track_buffer_seconds = buffer;
636         if (user_configuration) {
637                 track_buffer_seconds_is_user = true;
638         }
639 }
640
641 bool 
642 Configuration::does_hiding_groups_deactivates_groups()
643 {
644         return hiding_groups_deactivates_groups;
645 }
646
647 void 
648 Configuration::set_hiding_groups_deactivates_groups(bool hiding)
649 {
650         hiding_groups_deactivates_groups = hiding;
651         if (user_configuration) {
652                 hiding_groups_deactivates_groups_is_user = true;
653         }
654 }
655
656 string
657 Configuration::get_auditioner_output_left ()
658 {
659         return auditioner_output_left;
660 }
661
662 void
663 Configuration::set_auditioner_output_left (string str)
664 {
665         auditioner_output_left = str;
666         if (user_configuration) {
667                 auditioner_output_left_is_user = true;
668         }
669 }
670
671 string
672 Configuration::get_auditioner_output_right ()
673 {
674         return auditioner_output_right;
675 }
676
677 void
678 Configuration::set_auditioner_output_right (string str)
679 {
680         auditioner_output_right = str;
681         if (user_configuration) {
682                 auditioner_output_right_is_user = true;
683         }
684 }
685
686 bool
687 Configuration::get_mute_affects_pre_fader()
688 {
689         return mute_affects_pre_fader;
690 }
691
692 void 
693 Configuration::set_mute_affects_pre_fader (bool affects)
694 {
695         mute_affects_pre_fader = affects;
696         if (user_configuration) {
697                 mute_affects_pre_fader_is_user = true;
698         }
699 }
700
701 bool 
702 Configuration::get_mute_affects_post_fader()
703 {
704         return mute_affects_post_fader;
705 }
706
707 void 
708 Configuration::set_mute_affects_post_fader (bool affects)
709 {
710         mute_affects_post_fader = affects;
711         if (user_configuration) {
712                 mute_affects_post_fader_is_user = true;
713         }
714 }
715
716 bool 
717 Configuration::get_mute_affects_control_outs()
718 {
719         return mute_affects_control_outs;
720 }
721
722 void 
723 Configuration::set_mute_affects_control_outs (bool affects)
724 {
725         mute_affects_control_outs = affects;
726         if (user_configuration) {
727                 mute_affects_control_outs_is_user = true;
728         }
729 }
730
731 bool 
732 Configuration::get_mute_affects_main_outs()
733 {
734         return mute_affects_main_outs;
735 }
736
737 void 
738 Configuration::set_mute_affects_main_outs (bool affects)
739 {
740         mute_affects_main_outs = affects;
741         if (user_configuration) {
742                 mute_affects_main_outs_is_user = true;
743         }
744 }
745
746 bool 
747 Configuration::get_solo_latch()
748 {
749         return solo_latch;
750 }
751
752 void 
753 Configuration::set_solo_latch (bool latch)
754 {
755         solo_latch = latch;
756         if (user_configuration) {
757                 solo_latch_is_user = true;
758         }
759 }
760
761 XMLNode *
762 Configuration::get_keys () const
763 {
764         return key_node;
765 }
766
767 void
768 Configuration::set_keys (XMLNode* keys)
769 {
770         key_node = keys;
771 }
772
773 uint32_t
774 Configuration::get_disk_choice_space_threshold ()
775 {
776         return disk_choice_space_threshold;
777 }
778
779 void
780 Configuration::set_disk_choice_space_threshold (uint32_t val)
781 {
782         disk_choice_space_threshold = val;
783         if (user_configuration) {
784                 disk_choice_space_threshold_is_user = true;
785         }
786 }
787
788 string
789 Configuration::get_mmc_port_name ()
790 {
791         return mmc_port_name;
792 }
793
794 void
795 Configuration::set_mmc_port_name (string name)
796 {
797         mmc_port_name = name;
798         if (user_configuration) {
799                 mmc_port_name_is_user = true;
800         }
801 }
802
803 string
804 Configuration::get_mtc_port_name ()
805 {
806         return mtc_port_name;
807 }
808
809 void
810 Configuration::set_mtc_port_name (string name)
811 {
812         mtc_port_name = name;
813         if (user_configuration) {
814                 mtc_port_name_is_user = true;
815         }
816 }
817
818 string
819 Configuration::get_midi_port_name ()
820 {
821         return midi_port_name;
822 }
823
824 void
825 Configuration::set_midi_port_name (string name)
826 {
827         midi_port_name = name;
828         if (user_configuration) {
829                 midi_port_name_is_user = true;
830         }
831 }
832
833 uint32_t
834 Configuration::get_midi_feedback_interval_ms ()
835 {
836         return midi_feedback_interval_ms;
837 }
838
839 void
840 Configuration::set_midi_feedback_interval_ms (uint32_t val)
841 {
842         midi_feedback_interval_ms = val;
843         if (user_configuration) {
844                 midi_feedback_interval_ms_is_user = true;
845         }
846 }
847
848 bool
849 Configuration::get_use_hardware_monitoring()
850 {
851         return use_hardware_monitoring;
852 }
853
854 void
855 Configuration::set_use_hardware_monitoring(bool yn)
856 {
857         use_hardware_monitoring = yn;
858         if (user_configuration) {
859                 use_hardware_monitoring_is_user = true;
860         }
861 }
862
863 bool
864 Configuration::get_jack_time_master()
865 {
866         return be_jack_time_master;
867 }
868
869 void
870 Configuration::set_jack_time_master(bool yn)
871 {
872         be_jack_time_master = yn;
873         if (user_configuration) {
874                 be_jack_time_master_is_user = true;
875         }
876 }
877
878 bool
879 Configuration::get_native_format_is_bwf()
880 {
881         return native_format_is_bwf;
882 }
883
884 void
885 Configuration::set_native_format_is_bwf(bool yn)
886 {
887         native_format_is_bwf = yn;
888         if (user_configuration) {
889                 native_format_is_bwf_is_user = true;
890         }
891 }
892
893 bool
894 Configuration::get_trace_midi_input ()
895 {
896         return trace_midi_input;
897 }
898
899 void
900 Configuration::set_trace_midi_input (bool yn)
901 {
902         trace_midi_input = yn;
903         if (user_configuration) {
904                 trace_midi_input_is_user = true;
905         }
906 }
907
908 bool
909 Configuration::get_trace_midi_output ()
910 {
911         return trace_midi_output;
912 }
913
914 void
915 Configuration::set_trace_midi_output (bool yn)
916 {
917         trace_midi_output = yn;
918         if (user_configuration) {
919                 trace_midi_output_is_user = true;
920         }
921 }
922
923 bool
924 Configuration::get_plugins_stop_with_transport ()
925 {
926         return plugins_stop_with_transport;
927 }
928
929 void
930 Configuration::set_plugins_stop_with_transport (bool yn)
931 {
932         plugins_stop_with_transport = yn;
933         if (user_configuration) {
934                 plugins_stop_with_transport_is_user = true;
935         }
936 }
937
938 bool
939 Configuration::get_use_sw_monitoring ()
940 {
941         return use_sw_monitoring;
942 }
943
944 void
945 Configuration::set_use_sw_monitoring (bool yn)
946 {
947         use_sw_monitoring = yn;
948         if (user_configuration) {
949                 use_sw_monitoring_is_user = true;
950         }
951 }
952
953 bool
954 Configuration::get_stop_recording_on_xrun ()
955 {
956         return stop_recording_on_xrun;
957 }
958
959 void
960 Configuration::set_stop_recording_on_xrun (bool yn)
961 {
962         stop_recording_on_xrun = yn;
963         if (user_configuration) {
964                 stop_recording_on_xrun_is_user = true;
965         }
966 }
967
968 bool
969 Configuration::get_verify_remove_last_capture ()
970 {
971         return verify_remove_last_capture;
972 }
973
974 void
975 Configuration::set_verify_remove_last_capture (bool yn)
976 {
977         verify_remove_last_capture = yn;
978         if (user_configuration) {
979                 verify_remove_last_capture_is_user = true;
980         }
981 }
982
983 bool
984 Configuration::get_stop_at_session_end ()
985 {
986         return stop_at_session_end;
987 }
988
989 void
990 Configuration::set_stop_at_session_end (bool yn)
991 {
992         stop_at_session_end = yn;
993         if (user_configuration) {
994                 stop_at_session_end_is_user = true;
995         }
996 }
997
998 bool
999 Configuration::get_seamless_looping ()
1000 {
1001         return seamless_looping;
1002 }
1003
1004 void
1005 Configuration::set_seamless_looping (bool yn)
1006 {
1007         seamless_looping = yn;
1008         if (user_configuration) {
1009                 seamless_looping_is_user = true;
1010         }
1011 }
1012
1013 bool
1014 Configuration::get_auto_xfade ()
1015 {
1016         return auto_xfade;
1017 }
1018
1019 void
1020 Configuration::set_auto_xfade (bool yn)
1021 {
1022         auto_xfade = yn;
1023         if (user_configuration) {
1024                 auto_xfade_is_user = true;
1025         }
1026 }
1027
1028 bool 
1029 Configuration::get_no_new_session_dialog()
1030 {
1031         return no_new_session_dialog;
1032 }
1033
1034 void 
1035 Configuration::set_no_new_session_dialog(bool yn)
1036 {
1037         no_new_session_dialog = yn;
1038         if (user_configuration) {
1039                 no_new_session_dialog_is_user = true;
1040         }
1041 }
1042
1043 bool
1044 Configuration::get_timecode_source_is_synced()
1045 {
1046         return timecode_source_is_synced;
1047 }
1048
1049 void
1050 Configuration::set_timecode_source_is_synced (bool yn)
1051 {
1052         timecode_source_is_synced = yn;
1053         if (user_configuration) {
1054                 timecode_source_is_synced_is_user = true;
1055         }
1056 }
1057
1058 bool
1059 Configuration::get_use_vst ()
1060 {
1061         return use_vst;
1062 }
1063
1064 void
1065 Configuration::set_use_vst (bool yn)
1066 {
1067         use_vst = yn;
1068 }
1069
1070 gain_t
1071 Configuration::get_quieten_at_speed()
1072 {
1073         return speed_quietning;
1074 }
1075
1076 void
1077 Configuration::set_quieten_at_speed (float gain_coefficient)
1078 {
1079         speed_quietning = gain_coefficient;
1080         if (user_configuration) {
1081                 quieten_at_speed_is_user = true;
1082         }
1083 }
1084
1085 void
1086 Configuration::set_latched_record_enable (bool yn)
1087 {
1088         latched_record_enable = yn;
1089         if (user_configuration) {
1090                 latched_record_enable_is_user = true;
1091         }
1092 }
1093
1094 bool
1095 Configuration::get_latched_record_enable ()
1096 {
1097         return latched_record_enable;
1098 }
1099
1100 uint32_t 
1101 Configuration::get_destructive_xfade_msecs ()
1102 {
1103         return destructive_xfade_msecs;
1104 }
1105
1106 void
1107 Configuration::set_destructive_xfade_msecs (uint32_t msecs, jack_nframes_t rate)
1108 {
1109         destructive_xfade_msecs = msecs;
1110         if (rate) {
1111                 DestructiveFileSource::setup_standard_crossfades (rate);
1112         }
1113 }