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