videotimline
[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 using namespace Timecode;
30
31 SessionOptionEditor::SessionOptionEditor (Session* s)
32         : OptionEditor (&(s->config), _("Session Properties"))
33         , _session_config (&(s->config))
34 {
35         set_session (s);
36
37         set_name ("SessionProperties");
38
39         /* TIMECODE*/
40
41         add_option (_("Timecode"), new OptionEditorHeading (_("Timecode Settings")));
42
43         ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
44                 "timecode-format",
45                 _("Timecode frames-per-second"),
46                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_format),
47                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_format)
48                 );
49
50         smf->add (timecode_23976, _("23.976"));
51         smf->add (timecode_24, _("24"));
52         smf->add (timecode_24976, _("24.975"));
53         smf->add (timecode_25, _("25"));
54         smf->add (timecode_2997, _("29.97"));
55         smf->add (timecode_2997drop, _("29.97 drop"));
56         smf->add (timecode_30, _("30"));
57         smf->add (timecode_30drop, _("30 drop"));
58         smf->add (timecode_5994, _("59.94"));
59         smf->add (timecode_60, _("60"));
60
61         add_option (_("Timecode"), smf);
62
63         _vpu = new ComboOption<float> (
64                 "video-pullup",
65                 _("Pull-up / pull-down"),
66                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_video_pullup),
67                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_video_pullup)
68                 );
69
70         _vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
71         _vpu->add (4.1667, _("4.1667"));
72         _vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
73         _vpu->add (0.1, _("0.1"));
74         _vpu->add (0, _("none"));
75         _vpu->add (-0.1, _("-0.1"));
76         _vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
77         _vpu->add (-4.1667, _("-4.1667"));
78         _vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
79
80         add_option (_("Timecode"), _vpu);
81
82 #ifdef WITH_VIDEOTIMELINE
83         add_option (_("Sync"), new BoolOption (
84                             "use-video-file-fps",
85                             _("Use Video File's FPS Instead of Timecode Value for Timeline and Video Monitor."),
86                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_video_file_fps),
87                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_video_file_fps)
88                             ));
89
90         add_option (_("Sync"), new BoolOption (
91                             "videotimeline-pullup",
92                             _("Apply Pull-Up/Down to Video Timeline and Video Monitor (Unless in JACK-sync)."),
93                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_videotimeline_pullup),
94                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_videotimeline_pullup)
95                             ));
96 #endif
97
98         add_option (_("Timecode"), new OptionEditorHeading (_("Ext Timecode Offsets")));
99
100         ClockOption* sco = new ClockOption (
101                 "slave-timecode-offset",
102                 _("Slave Timecode offset"),
103                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_slave_timecode_offset),
104                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_slave_timecode_offset)
105                 );
106
107         sco->set_session (_session);
108         sco->clock().set_negative_allowed (true);
109         Gtkmm2ext::UI::instance()->set_tip (sco->tip_widget(), _("The specified offset is added to the received timecode (MTC or LTC)."));
110
111         add_option (_("Timecode"), sco);
112
113         ClockOption* gco = new ClockOption (
114                 "timecode-generator-offset",
115                 _("Timecode Generator offset"),
116                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_generator_offset),
117                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_generator_offset)
118                 );
119
120         gco->set_session (_session);
121         gco->clock().set_negative_allowed (true);
122         Gtkmm2ext::UI::instance()->set_tip (gco->tip_widget(), _("Specify an offset which is added to the generated timecode (so far only LTC)."));
123
124         add_option (_("Timecode"), gco);
125
126         add_option (_("Timecode"), new OptionEditorHeading (_("JACK Transport/Time Settings")));
127
128         add_option (_("Timecode"), new BoolOption (
129                             "jack-time-master",
130                             string_compose (_("%1 is JACK Time Master (provides Bar|Beat|Tick and other information to JACK)"), PROGRAM_NAME),
131                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_jack_time_master),
132                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_jack_time_master)
133                             ));
134
135         /* FADES */
136
137         ComboOption<CrossfadeChoice>* cfc = new ComboOption<CrossfadeChoice> (
138                 "xfade-choice",
139                 _("Default crossfade type"),
140                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_choice),
141                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_choice)
142                 );
143
144         cfc->add (ConstantPowerMinus3dB, _("Constant power (-3dB) crossfade"));
145         cfc->add (ConstantPowerMinus6dB, _("Linear (-6dB) crossfade"));
146
147         add_option (_("Fades"), cfc);
148
149         add_option (_("Fades"), new SpinOption<float> (
150                 _("destructive-xfade-seconds"),
151                 _("Destructive crossfade length"),
152                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
153                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
154                 0, 1000, 1, 10,
155                 _("ms")
156                             ));
157
158         add_option (_("Fades"), new BoolOption (
159                             "use-region-fades",
160                             _("Region fades active"),
161                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
162                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
163                             ));
164
165         add_option (_("Fades"), new BoolOption (
166                             "show-region-fades",
167                             _("Region fades visible"),
168                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
169                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
170                             ));
171
172         /* Media */
173
174         add_option (_("Media"), new OptionEditorHeading (_("Audio file format")));
175
176         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
177                 "native-file-data-format",
178                 _("Sample format"),
179                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
180                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
181                 );
182
183         sf->add (FormatFloat, _("32-bit floating point"));
184         sf->add (FormatInt24, _("24-bit integer"));
185         sf->add (FormatInt16, _("16-bit integer"));
186
187         add_option (_("Media"), sf);
188
189         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
190                 "native-file-header-format",
191                 _("File type"),
192                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
193                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
194                 );
195
196         hf->add (BWF, _("Broadcast WAVE"));
197         hf->add (WAVE, _("WAVE"));
198         hf->add (WAVE64, _("WAVE-64"));
199         hf->add (CAF, _("CAF"));
200
201         add_option (_("Media"), hf);
202
203         add_option (_("Media"), new OptionEditorHeading (_("File locations")));
204
205         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
206                                                       _session->path(),
207                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
208                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));
209         add_option (_("Media"), spo);
210
211         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
212                                     _session->path(),
213                                     sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
214                                     sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
215
216         add_option (_("Media"), spo);
217
218         /* Monitoring */
219
220         add_option (_("Monitoring"), new BoolOption (
221                             "auto-input",
222                             _("Track Input Monitoring automatically follows transport state (\"auto-input\")"),
223                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
224                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
225                             ));
226
227         add_option (_("Monitoring"), new BoolOption (
228                             "have-monitor-section",
229                             _("Use monitor section in this session"),
230                             sigc::mem_fun (*this, &SessionOptionEditor::get_use_monitor_section),
231                             sigc::mem_fun (*this, &SessionOptionEditor::set_use_monitor_section)
232                             ));
233
234         /* Misc */
235
236         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
237
238         add_option (_("Misc"), new BoolOption (
239                             "midi-copy-is-fork",
240                             _("MIDI region copies are independent"),
241                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
242                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
243                             ));
244
245         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
246                 "insert-merge-policy",
247                 _("Policy for handling overlapping notes\n on the same MIDI channel"),
248                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
249                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
250                 );
251
252         li->add (InsertMergeReject, _("never allow them"));
253         li->add (InsertMergeRelax, _("don't do anything in particular"));
254         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
255         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
256         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
257         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
258
259         add_option (_("Misc"), li);
260
261         add_option (_("Misc"), new OptionEditorHeading (_("Glue to bars and beats")));
262
263         add_option (_("Misc"), new BoolOption (
264                             "glue-new-markers-to-bars-and-beats",
265                             _("Glue new markers to bars and beats"),
266                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
267                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
268                             ));
269
270         add_option (_("Misc"), new BoolOption (
271                             "glue-new-regions-to-bars-and-beats",
272                             _("Glue new regions to bars and beats"),
273                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
274                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
275                             ));
276 }
277
278 void
279 SessionOptionEditor::parameter_changed (std::string const & p)
280 {
281         OptionEditor::parameter_changed (p);
282         if (p == "external-sync") {
283                 if (Config->get_sync_source() == JACK) {
284                         _vpu->set_sensitive(!_session_config->get_external_sync());
285                 } else {
286                         _vpu->set_sensitive(true);
287                 }
288         }
289         if (p == "timecode-format") {
290                 /* update offset clocks */
291                 parameter_changed("timecode-generator-offset");
292                 parameter_changed("slave-timecode-offset");
293         }
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         /* store this choice for any new sessions */
312         
313         Config->set_use_monitor_bus (yn);
314
315         return had_monitor_section != yn;
316 }
317
318 bool
319 SessionOptionEditor::get_use_monitor_section ()
320 {
321         return _session->monitor_out() != 0;
322 }