put JACK time master option into Session -> Properties -> Timecode, and fully remove...
[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 #include "ardour/io.h"
22 #include "ardour/auditioner.h"
23 #include "ardour/audioengine.h"
24 #include "ardour/port.h"
25
26 #include "gui_thread.h"
27 #include "session_option_editor.h"
28 #include "search_path_option.h"
29 #include "i18n.h"
30
31 using namespace std;
32 using namespace ARDOUR;
33
34 SessionOptionEditor::SessionOptionEditor (Session* s)
35         : OptionEditor (&(s->config), _("Session Properties"))
36         , _session_config (&(s->config))
37 {
38         set_session (s);
39
40         set_name ("SessionProperties");
41
42         /* TIMECODE*/
43
44         _sync_source = new ComboOption<SyncSource> (
45                 "sync-source",
46                 _("External timecode source"),
47                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_sync_source),
48                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_sync_source)
49                 );
50
51         populate_sync_options ();
52         parameter_changed (string ("external-sync"));
53
54         add_option (_("Timecode"), _sync_source);
55
56         add_option (_("Timecode"), new OptionEditorHeading (_("Timecode Settings")));
57
58         ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
59                 "timecode-format",
60                 _("Timecode frames-per-second"),
61                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_format),
62                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_format)
63                 );
64
65         smf->add (timecode_23976, _("23.976"));
66         smf->add (timecode_24, _("24"));
67         smf->add (timecode_24976, _("24.976"));
68         smf->add (timecode_25, _("25"));
69         smf->add (timecode_2997, _("29.97"));
70         smf->add (timecode_2997drop, _("29.97 drop"));
71         smf->add (timecode_30, _("30"));
72         smf->add (timecode_30drop, _("30 drop"));
73         smf->add (timecode_5994, _("59.94"));
74         smf->add (timecode_60, _("60"));
75
76         add_option (_("Timecode"), smf);
77
78         ComboOption<uint32_t>* spf = new ComboOption<uint32_t> (
79                 "subframes-per-frame",
80                 _("Subframes per frame"),
81                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame),
82                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame)
83                 );
84
85         spf->add (80, _("80"));
86         spf->add (100, _("100"));
87
88         add_option (_("Timecode"), spf);
89
90         add_option (_("Timecode"), new BoolOption (
91                             "timecode-source-is-synced",
92                             _("Timecode source shares sample clock with audio interface"),
93                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced),
94                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced)
95                             ));
96
97         ComboOption<float>* vpu = new ComboOption<float> (
98                 "video-pullup",
99                 _("Pull-up / pull-down"),
100                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_video_pullup),
101                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_video_pullup)
102                 );
103
104         vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
105         vpu->add (4.1667, _("4.1667"));
106         vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
107         vpu->add (0.1, _("0.1"));
108         vpu->add (0, _("none"));
109         vpu->add (-0.1, _("-0.1"));
110         vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
111         vpu->add (-4.1667, _("-4.1667"));
112         vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
113
114         add_option (_("Timecode"), vpu);
115
116         ClockOption* co = new ClockOption (
117                 "timecode-offset",
118                 _("Timecode Offset"),
119                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset),
120                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset)
121                 );
122
123         co->set_session (_session);
124
125         add_option (_("Timecode"), co);
126
127         add_option (_("Timecode"), new BoolOption (
128                             "timecode-offset-negative",
129                             _("Timecode Offset Negative"),
130                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_offset_negative),
131                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_offset_negative)
132                             ));
133
134         add_option (_("Timecode"), new OptionEditorHeading (_("JACK Transport/Time Settings")));
135
136         add_option (_("Timecode"), new BoolOption (
137                             "jack-time-master",
138                             _("Ardour is JACK Time Master (provides Bar|Beat|Tick and other information to JACK)"),
139                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_jack_time_master),
140                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_jack_time_master)
141                             ));
142
143         /* FADES */
144
145         ComboOption<CrossfadeModel>* cfm = new ComboOption<CrossfadeModel> (
146                 "xfade-model",
147                 _("Crossfades are created"),
148                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_model),
149                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_model)
150                 );
151
152         cfm->add (FullCrossfade, _("to span entire overlap"));
153         cfm->add (ShortCrossfade, _("short"));
154
155         add_option (_("Fades"), cfm);
156
157         add_option (_("Fades"), new SpinOption<float> (
158                 _("short-xfade-seconds"),
159                 _("Short crossfade length"),
160                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_short_xfade_seconds),
161                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_short_xfade_seconds),
162                 0, 1000, 1, 10,
163                 _("ms"), 0.001
164                             ));
165
166         add_option (_("Fades"), new SpinOption<float> (
167                 _("destructive-xfade-seconds"),
168                 _("Destructive crossfade length"),
169                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
170                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
171                 0, 1000, 1, 10,
172                 _("ms")
173                             ));
174
175         add_option (_("Fades"), new BoolOption (
176                             "auto-xfade",
177                             _("Create crossfades automatically"),
178                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_xfade),
179                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_xfade)
180                             ));
181
182         add_option (_("Fades"), new BoolOption (
183                             "xfades-active",
184                             _("Crossfades active"),
185                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfades_active),
186                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfades_active)
187                             ));
188
189         add_option (_("Fades"), new BoolOption (
190                             "xfades-visible",
191                             _("Crossfades visible"),
192                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfades_visible),
193                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfades_visible)
194                             ));
195
196         add_option (_("Fades"), new BoolOption (
197                             "use-region-fades",
198                             _("Region fades active"),
199                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
200                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
201                             ));
202
203         add_option (_("Fades"), new BoolOption (
204                             "show-region-fades",
205                             _("Region fades visible"),
206                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
207                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
208                             ));
209
210         /* Media */
211
212         add_option (_("Media"), new OptionEditorHeading (_("Audio file format")));
213
214         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
215                 "native-file-data-format",
216                 _("Sample format"),
217                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
218                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
219                 );
220
221         sf->add (FormatFloat, _("32-bit floating point"));
222         sf->add (FormatInt24, _("24-bit integer"));
223         sf->add (FormatInt16, _("16-bit integer"));
224
225         add_option (_("Media"), sf);
226
227         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
228                 "native-file-header-format",
229                 _("File type"),
230                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
231                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
232                 );
233
234         hf->add (BWF, _("Broadcast WAVE"));
235         hf->add (WAVE, _("WAVE"));
236         hf->add (WAVE64, _("WAVE-64"));
237         hf->add (CAF, _("CAF"));
238
239         add_option (_("Media"), hf);
240
241         add_option (_("Media"), new OptionEditorHeading (_("File locations")));
242
243         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
244                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
245                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));
246         add_option (_("Media"), spo);
247
248         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
249                                     sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
250                                     sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
251
252         add_option (_("Media"), spo);
253
254         /* Monitoring */
255
256         add_option (_("Monitoring"), new BoolOption (
257                             "auto-input",
258                             _("Monitoring automatically follows transport state (\"auto-input\")"),
259                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
260                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
261                             ));
262
263         /* Misc */
264
265         add_option (_("Misc"), new OptionEditorHeading (_("Layering (in overlaid mode)")));
266
267         ComboOption<LayerModel>* lm = new ComboOption<LayerModel> (
268                 "layer-model",
269                 _("Layering model"),
270                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_layer_model),
271                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_layer_model)
272                 );
273
274         lm->add (LaterHigher, _("later is higher"));
275         lm->add (MoveAddHigher, _("most recently moved or added is higher"));
276         lm->add (AddHigher, _("most recently added is higher"));
277
278         add_option (_("Misc"), lm);
279
280         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
281
282         add_option (_("Misc"), new BoolOption (
283                             "midi-copy-is-fork",
284                             _("MIDI region copies are independent"),
285                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
286                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
287                             ));
288
289         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
290                 "insert-merge-policy",
291                 _("Policy for handling same note\nand channel overlaps"),
292                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
293                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
294                 );
295
296         li->add (InsertMergeReject, _("never allow them"));
297         li->add (InsertMergeRelax, _("don't do anything in particular"));
298         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
299         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
300         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
301         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
302
303         add_option (_("Misc"), li);
304
305         add_option (_("Misc"), new OptionEditorHeading (_("Broadcast WAVE metadata")));
306
307         add_option (_("Misc"), new EntryOption (
308                             "bwf-country-code",
309                             _("Country code"),
310                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_bwf_country_code),
311                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_bwf_country_code)
312                             ));
313
314         add_option (_("Misc"), new EntryOption (
315                             "bwf-organization-code",
316                             _("Organization code"),
317                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_bwf_organization_code),
318                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_bwf_organization_code)
319                             ));
320
321         add_option (_("Misc"), new OptionEditorHeading (_("Glue to bars and beats")));
322
323         add_option (_("Misc"), new BoolOption (
324                             "glue-new-markers-to-bars-and-beats",
325                             _("Glue new markers to bars and beats"),
326                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
327                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
328                             ));
329 }
330
331 void
332 SessionOptionEditor::populate_sync_options ()
333 {
334         vector<SyncSource> sync_opts = _session->get_available_sync_options ();
335
336         _sync_source->clear ();
337
338         for (vector<SyncSource>::iterator i = sync_opts.begin(); i != sync_opts.end(); ++i) {
339                 _sync_source->add (*i, sync_source_to_string (*i));
340         }
341 }
342
343 void
344 SessionOptionEditor::parameter_changed (std::string const & p)
345 {
346         OptionEditor::parameter_changed (p);
347
348         if (p == "external-sync") {
349                 _sync_source->set_sensitive (!_session->config.get_external_sync ());
350         }
351 }