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