move the external sync source selection tobe a global config parameter, not per-sessi...
[ardour.git] / gtk2_ardour / session_option_editor.cc
1 /*
2     Copyright (C) 2000-2010 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 */
19
20 #include "ardour/session.h"
21
22 #include "gui_thread.h"
23 #include "session_option_editor.h"
24 #include "search_path_option.h"
25 #include "i18n.h"
26
27 using namespace std;
28 using namespace ARDOUR;
29
30 SessionOptionEditor::SessionOptionEditor (Session* s)
31         : OptionEditor (&(s->config), _("Session Properties"))
32         , _session_config (&(s->config))
33 {
34         set_session (s);
35
36         set_name ("SessionProperties");
37
38         /* TIMECODE*/
39
40         add_option (_("Timecode"), new OptionEditorHeading (_("Timecode Settings")));
41
42         ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
43                 "timecode-format",
44                 _("Timecode frames-per-second"),
45                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_format),
46                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_format)
47                 );
48
49         smf->add (timecode_23976, _("23.976"));
50         smf->add (timecode_24, _("24"));
51         smf->add (timecode_24976, _("24.976"));
52         smf->add (timecode_25, _("25"));
53         smf->add (timecode_2997, _("29.97"));
54         smf->add (timecode_2997drop, _("29.97 drop"));
55         smf->add (timecode_30, _("30"));
56         smf->add (timecode_30drop, _("30 drop"));
57         smf->add (timecode_5994, _("59.94"));
58         smf->add (timecode_60, _("60"));
59
60         add_option (_("Timecode"), smf);
61
62         ComboOption<uint32_t>* spf = new ComboOption<uint32_t> (
63                 "subframes-per-frame",
64                 _("Subframes per frame"),
65                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame),
66                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame)
67                 );
68
69         spf->add (80, _("80"));
70         spf->add (100, _("100"));
71
72         add_option (_("Timecode"), spf);
73
74         ComboOption<float>* vpu = new ComboOption<float> (
75                 "video-pullup",
76                 _("Pull-up / pull-down"),
77                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_video_pullup),
78                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_video_pullup)
79                 );
80
81         vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
82         vpu->add (4.1667, _("4.1667"));
83         vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
84         vpu->add (0.1, _("0.1"));
85         vpu->add (0, _("none"));
86         vpu->add (-0.1, _("-0.1"));
87         vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
88         vpu->add (-4.1667, _("-4.1667"));
89         vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
90
91         add_option (_("Timecode"), vpu);
92
93         ClockOption* co = new ClockOption (
94                 "timecode-offset",
95                 _("Timecode offset"),
96                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset),
97                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset)
98                 );
99
100         co->set_session (_session);
101
102         add_option (_("Timecode"), co);
103
104         add_option (_("Timecode"), new BoolOption (
105                             "timecode-offset-negative",
106                             _("Timecode Offset Negative"),
107                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset_negative),
108                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset_negative)
109                             ));
110
111         add_option (_("Timecode"), new OptionEditorHeading (_("JACK Transport/Time Settings")));
112
113         add_option (_("Timecode"), new BoolOption (
114                             "jack-time-master",
115                             string_compose (_("%1 is JACK Time Master (provides Bar|Beat|Tick and other information to JACK)"), PROGRAM_NAME),
116                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_jack_time_master),
117                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_jack_time_master)
118                             ));
119
120         /* FADES */
121
122         ComboOption<CrossfadeModel>* cfm = new ComboOption<CrossfadeModel> (
123                 "xfade-model",
124                 _("Crossfades are created"),
125                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_model),
126                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_model)
127                 );
128
129         cfm->add (FullCrossfade, _("to span entire overlap"));
130         cfm->add (ShortCrossfade, _("short"));
131
132         add_option (_("Fades"), cfm);
133
134         ComboOption<CrossfadeChoice>* cfc = new ComboOption<CrossfadeChoice> (
135                 "xfade-choice",
136                 _("Crossfade type"),
137                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_choice),
138                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_choice)
139                 );
140
141         cfc->add (ConstantPowerMinus3dB, _("constant power (-3dB)"));
142         cfc->add (ConstantPowerMinus6dB, _("constant power (-6dB)"));
143         cfc->add (RegionFades, _("use existing region fade shape"));
144
145         add_option (_("Fades"), cfc);
146
147         add_option (_("Fades"), new SpinOption<float> (
148                 _("short-xfade-seconds"),
149                 _("Short crossfade length"),
150                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_short_xfade_seconds),
151                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_short_xfade_seconds),
152                 0, 1000, 1, 10,
153                 _("ms"), 0.001
154                             ));
155
156         add_option (_("Fades"), new SpinOption<float> (
157                 _("destructive-xfade-seconds"),
158                 _("Destructive crossfade length"),
159                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
160                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
161                 0, 1000, 1, 10,
162                 _("ms")
163                             ));
164
165         add_option (_("Fades"), new BoolOption (
166                             "auto-xfade",
167                             _("Create crossfades automatically"),
168                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_xfade),
169                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_xfade)
170                             ));
171
172         add_option (_("Fades"), new BoolOption (
173                             "use-region-fades",
174                             _("Region fades active"),
175                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
176                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
177                             ));
178
179         add_option (_("Fades"), new BoolOption (
180                             "show-region-fades",
181                             _("Region fades visible"),
182                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
183                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
184                             ));
185
186         /* Media */
187
188         add_option (_("Media"), new OptionEditorHeading (_("Audio file format")));
189
190         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
191                 "native-file-data-format",
192                 _("Sample format"),
193                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
194                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
195                 );
196
197         sf->add (FormatFloat, _("32-bit floating point"));
198         sf->add (FormatInt24, _("24-bit integer"));
199         sf->add (FormatInt16, _("16-bit integer"));
200
201         add_option (_("Media"), sf);
202
203         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
204                 "native-file-header-format",
205                 _("File type"),
206                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
207                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
208                 );
209
210         hf->add (BWF, _("Broadcast WAVE"));
211         hf->add (WAVE, _("WAVE"));
212         hf->add (WAVE64, _("WAVE-64"));
213         hf->add (CAF, _("CAF"));
214
215         add_option (_("Media"), hf);
216
217         add_option (_("Media"), new OptionEditorHeading (_("File locations")));
218
219         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
220                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
221                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));
222         add_option (_("Media"), spo);
223
224         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
225                                     sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
226                                     sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
227
228         add_option (_("Media"), spo);
229
230         /* Monitoring */
231
232         add_option (_("Monitoring"), new BoolOption (
233                             "auto-input",
234                             _("Monitoring automatically follows transport state (\"auto-input\")"),
235                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
236                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
237                             ));
238
239         add_option (_("Monitoring"), new BoolOption (
240                             "have-monitor-section",
241                             _("Use monitor section in this session"),
242                             sigc::mem_fun (*this, &SessionOptionEditor::get_use_monitor_section),
243                             sigc::mem_fun (*this, &SessionOptionEditor::set_use_monitor_section)
244                             ));
245
246         /* Misc */
247
248         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
249
250         add_option (_("Misc"), new BoolOption (
251                             "midi-copy-is-fork",
252                             _("MIDI region copies are independent"),
253                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
254                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
255                             ));
256
257         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
258                 "insert-merge-policy",
259                 _("Policy for handling overlapping notes\n on the same MIDI channel"),
260                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
261                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
262                 );
263
264         li->add (InsertMergeReject, _("never allow them"));
265         li->add (InsertMergeRelax, _("don't do anything in particular"));
266         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
267         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
268         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
269         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
270
271         add_option (_("Misc"), li);
272
273         add_option (_("Misc"), new OptionEditorHeading (_("Glue to bars and beats")));
274
275         add_option (_("Misc"), new BoolOption (
276                             "glue-new-markers-to-bars-and-beats",
277                             _("Glue new markers to bars and beats"),
278                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
279                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
280                             ));
281
282         add_option (_("Misc"), new BoolOption (
283                             "glue-new-regions-to-bars-and-beats",
284                             _("Glue new regions to bars and beats"),
285                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
286                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
287                             ));
288 }
289
290 void
291 SessionOptionEditor::parameter_changed (std::string const & p)
292 {
293         OptionEditor::parameter_changed (p);
294 }
295
296 /* the presence of absence of a monitor section is not really a regular session
297  * property so we provide these two functions to act as setter/getter slots
298  */
299
300 bool
301 SessionOptionEditor::set_use_monitor_section (bool yn)
302 {
303         bool had_monitor_section = _session->monitor_out();
304
305         if (yn) {
306                 _session->add_monitor_section ();
307         } else {
308                 _session->remove_monitor_section ();
309         }
310
311         return had_monitor_section != yn;
312 }
313
314 bool
315 SessionOptionEditor::get_use_monitor_section ()
316 {
317         return _session->monitor_out() != 0;
318 }