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