Allow strips to add or remove personal sends
[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/transport_master_manager.h"
22
23 #include "gui_thread.h"
24 #include "session_option_editor.h"
25 #include "search_path_option.h"
26 #include "pbd/i18n.h"
27
28 using namespace std;
29 using namespace ARDOUR;
30 using namespace Timecode;
31
32 SessionOptionEditor::SessionOptionEditor (Session* s)
33         : OptionEditorWindow (&(s->config), _("Session Properties"))
34         , _session_config (&(s->config))
35 {
36         set_session (s);
37
38         set_name ("SessionProperties");
39
40         /* TIMECODE*/
41
42         add_option (_("Timecode"), new OptionEditorHeading (_("Timecode Settings")));
43
44         ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
45                 "timecode-format",
46                 _("Timecode samples-per-second"),
47                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_format),
48                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_format)
49                 );
50
51         smf->add (timecode_23976, _("23.976"));
52         smf->add (timecode_24, _("24"));
53         smf->add (timecode_24976, _("24.975"));
54         smf->add (timecode_25, _("25"));
55         smf->add (timecode_2997, _("29.97"));
56         smf->add (timecode_2997drop, _("29.97 drop"));
57         smf->add (timecode_30, _("30"));
58         smf->add (timecode_30drop, _("30 drop"));
59         smf->add (timecode_5994, _("59.94"));
60         smf->add (timecode_60, _("60"));
61
62         add_option (_("Timecode"), smf);
63
64         _vpu = new ComboOption<float> (
65                 "video-pullup",
66                 _("Pull-up / pull-down"),
67                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_video_pullup),
68                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_video_pullup)
69                 );
70
71         _vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
72         _vpu->add (4.1667, _("4.1667"));
73         _vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
74         _vpu->add (0.1, _("0.1"));
75         _vpu->add (0, _("none"));
76         _vpu->add (-0.1, _("-0.1"));
77         _vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
78         _vpu->add (-4.1667, _("-4.1667"));
79         _vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
80
81         add_option (_("Timecode"), _vpu);
82         add_option (_("Timecode"), new OptionEditorHeading (_("Ext Timecode Offsets")));
83
84         ClockOption* sco = new ClockOption (
85                 "slave-timecode-offset",
86                 _("Slave Timecode offset"),
87                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_slave_timecode_offset),
88                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_slave_timecode_offset)
89                 );
90
91         sco->set_session (_session);
92         sco->clock().set_negative_allowed (true);
93         Gtkmm2ext::UI::instance()->set_tip (sco->tip_widget(), _("The specified offset is added to the received timecode (MTC or LTC)."));
94
95         add_option (_("Timecode"), sco);
96
97         ClockOption* gco = new ClockOption (
98                 "timecode-generator-offset",
99                 _("Timecode Generator offset"),
100                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_generator_offset),
101                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_generator_offset)
102                 );
103
104         gco->set_session (_session);
105         gco->clock().set_negative_allowed (true);
106         Gtkmm2ext::UI::instance()->set_tip (gco->tip_widget(), _("Specify an offset which is added to the generated timecode (so far only LTC)."));
107
108         add_option (_("Timecode"), gco);
109
110         add_option (_("Timecode"), new OptionEditorHeading (_("JACK Transport/Time Settings")));
111
112         add_option (_("Timecode"), new BoolOption (
113                             "jack-time-master",
114                             string_compose (_("%1 is JACK Time Master (provides Bar|Beat|Tick and other information to JACK)"), PROGRAM_NAME),
115                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_jack_time_master),
116                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_jack_time_master)
117                             ));
118
119         /* Sync */
120
121         add_option (_("Sync"), new OptionEditorHeading (_("A/V Synchronization")));
122         add_option (_("Sync"), new BoolOption (
123                             "use-video-file-fps",
124                             _("Use Video File's FPS Instead of Timecode Value for Timeline and Video Monitor."),
125                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_video_file_fps),
126                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_video_file_fps)
127                             ));
128
129         add_option (_("Sync"), new BoolOption (
130                             "videotimeline-pullup",
131                             _("Apply Pull-Up/Down to Video Timeline and Video Monitor (Unless using JACK-sync)."),
132                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_videotimeline_pullup),
133                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_videotimeline_pullup)
134                             ));
135
136         add_option (_("Sync"), new OptionEditorBlank ());
137
138         /* FADES */
139
140         add_option (_("Fades"), new OptionEditorHeading (_("Audio Fades")));
141         add_option (_("Fades"), new SpinOption<float> (
142                 _("destructive-xfade-seconds"),
143                 _("Destructive crossfade length"),
144                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
145                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
146                 0, 1000, 1, 10,
147                 _("ms")
148                             ));
149
150         add_option (_("Fades"), new BoolOption (
151                             "use-transport-fades",
152                             _("Declick when transport starts and stops"),
153                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_transport_fades),
154                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_transport_fades)
155                             ));
156
157         add_option (_("Fades"), new BoolOption (
158                             "use-monitor-fades",
159                             _("Declick when monitor state changes"),
160                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_monitor_fades),
161                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_monitor_fades)
162                             ));
163
164         add_option (_("Fades"), new BoolOption (
165                             "use-region-fades",
166                             _("Region fades active"),
167                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
168                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
169                             ));
170
171         add_option (_("Fades"), new BoolOption (
172                             "show-region-fades",
173                             _("Region fades visible"),
174                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
175                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
176                             ));
177
178         /* Media */
179
180         add_option (_("Media"), new OptionEditorHeading (_("Audio File Format")));
181
182         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
183                 "native-file-data-format",
184                 _("Sample format"),
185                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
186                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
187                 );
188
189         sf->add (FormatFloat, _("32-bit floating point"));
190         sf->add (FormatInt24, _("24-bit integer"));
191         sf->add (FormatInt16, _("16-bit integer"));
192
193         add_option (_("Media"), sf);
194
195         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
196                 "native-file-header-format",
197                 _("File type"),
198                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
199                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
200                 );
201
202         hf->add (BWF, _("Broadcast WAVE (4GB size limit)"));
203 #ifdef HAVE_RF64_RIFF
204         hf->add (MBWF, _("Broadcast RF64"));
205 #endif
206         hf->add (WAVE, _("WAVE (4GB size limit)"));
207         hf->add (WAVE64, _("WAVE-64"));
208         hf->add (CAF, _("CAF"));
209         hf->add (RF64, _("RF64"));
210 #ifdef HAVE_RF64_RIFF
211         hf->add (RF64_WAV, _("RF64 (WAV compatible)"));
212 #endif
213
214         add_option (_("Media"), hf);
215
216         add_option (S_("Files|Locations"), new OptionEditorHeading (_("File Locations")));
217
218         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
219                         _session->path(),
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 (S_("Files|Locations"), spo);
223
224         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
225                         _session->path(),
226                         sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
227                         sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
228
229         add_option (S_("Files|Locations"), spo);
230
231         /* File Naming  */
232
233         add_option (_("Filenames"), new OptionEditorHeading (_("File Naming")));
234
235         BoolOption *bo;
236
237         bo = new RouteDisplayBoolOption (
238                         "track-name-number",
239                         _("Prefix Track number"),
240                         sigc::mem_fun (*_session_config, &SessionConfiguration::get_track_name_number),
241                         sigc::mem_fun (*_session_config, &SessionConfiguration::set_track_name_number)
242                         );
243         Gtkmm2ext::UI::instance()->set_tip (bo->tip_widget(),
244                         _("Adds the current track number to the beginning of the recorded file name."));
245         add_option (_("Filenames"), bo);
246
247         bo = new BoolOption (
248                         "track-name-take",
249                         _("Prefix Take Name"),
250                         sigc::mem_fun (*_session_config, &SessionConfiguration::get_track_name_take),
251                         sigc::mem_fun (*_session_config, &SessionConfiguration::set_track_name_take)
252                         );
253         Gtkmm2ext::UI::instance()->set_tip (bo->tip_widget(),
254                         _("Adds the Take Name to the beginning of the recorded file name."));
255         add_option (_("Filenames"), bo);
256
257         _take_name = new EntryOption (
258                 "take-name",
259                 _("Take Name"),
260                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_take_name),
261                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_take_name)
262                 );
263         _take_name->set_invalid_chars(".");
264         _take_name->set_sensitive(_session_config->get_track_name_take());
265
266         add_option (_("Filenames"), _take_name);
267
268         /* Monitoring */
269
270         add_option (_("Monitoring"), new OptionEditorHeading (_("Monitoring")));
271         add_option (_("Monitoring"), new BoolOption (
272                                 "auto-input",
273                                 _("Track Input Monitoring automatically follows transport state (\"auto-input\")"),
274                                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
275                                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
276                                 ));
277
278         add_option (_("Monitoring"), new BoolOption (
279                                 "have-monitor-section",
280                                 _("Use monitor section in this session"),
281                                 sigc::mem_fun (*this, &SessionOptionEditor::get_use_monitor_section),
282                                 sigc::mem_fun (*this, &SessionOptionEditor::set_use_monitor_section)
283                                 ));
284
285         add_option (_("Monitoring"), new OptionEditorBlank ());
286
287         /* Meterbridge */
288         add_option (_("Meterbridge"), new OptionEditorHeading (_("Route Display")));
289
290         add_option (_("Meterbridge"), new BoolOption (
291                             "show-midi-on-meterbridge",
292                             _("Show Midi Tracks"),
293                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_midi_on_meterbridge),
294                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_midi_on_meterbridge)
295                             ));
296
297         add_option (_("Meterbridge"), new BoolOption (
298                             "show-busses-on-meterbridge",
299                             _("Show Busses"),
300                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_busses_on_meterbridge),
301                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_busses_on_meterbridge)
302                             ));
303
304         add_option (_("Meterbridge"), new BoolOption (
305                             "show-master-on-meterbridge",
306                             _("Include Master Bus"),
307                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_master_on_meterbridge),
308                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_master_on_meterbridge)
309                             ));
310
311         add_option (_("Meterbridge"), new OptionEditorHeading (_("Button Area")));
312
313         add_option (_("Meterbridge"), new BoolOption (
314                             "show-rec-on-meterbridge",
315                             _("Rec-enable Button"),
316                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_rec_on_meterbridge),
317                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_rec_on_meterbridge)
318                             ));
319
320         add_option (_("Meterbridge"), new BoolOption (
321                             "show-mute-on-meterbridge",
322                             _("Mute Button"),
323                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_mute_on_meterbridge),
324                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_mute_on_meterbridge)
325                             ));
326
327         add_option (_("Meterbridge"), new BoolOption (
328                             "show-solo-on-meterbridge",
329                             _("Solo Button"),
330                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_solo_on_meterbridge),
331                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_solo_on_meterbridge)
332                             ));
333
334         add_option (_("Meterbridge"), new BoolOption (
335                             "show-monitor-on-meterbridge",
336                             _("Monitor Buttons"),
337                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_monitor_on_meterbridge),
338                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_monitor_on_meterbridge)
339                             ));
340
341         add_option (_("Meterbridge"), new OptionEditorHeading (_("Name Labels")));
342
343         add_option (_("Meterbridge"), new BoolOption (
344                             "show-name-on-meterbridge",
345                             _("Track Name"),
346                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_name_on_meterbridge),
347                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_name_on_meterbridge)
348                             ));
349
350         add_option (_("Meterbridge"), new OptionEditorBlank ());
351
352         /* Misc */
353
354         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
355
356         add_option (_("Misc"), new BoolOption (
357                                 "midi-copy-is-fork",
358                                 _("MIDI region copies are independent"),
359                                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
360                                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
361                                 ));
362
363         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
364                         "insert-merge-policy",
365                         _("Policy for handling overlapping notes\n on the same MIDI channel"),
366                         sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
367                         sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
368                         );
369
370         li->add (InsertMergeReject, _("never allow them"));
371         li->add (InsertMergeRelax, _("don't do anything in particular"));
372         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
373         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
374         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
375         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
376
377         add_option (_("Misc"), li);
378
379         add_option (_("Misc"), new OptionEditorHeading (_("Glue to Bars and Beats")));
380
381         add_option (_("Misc"), new BoolOption (
382                                 "glue-new-markers-to-bars-and-beats",
383                                 _("Glue new markers to bars and beats"),
384                                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
385                                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
386                                 ));
387
388         add_option (_("Misc"), new BoolOption (
389                                 "glue-new-regions-to-bars-and-beats",
390                                 _("Glue new regions to bars and beats"),
391                                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
392                                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
393                                 ));
394
395         add_option (_("Misc"), new OptionEditorHeading (_("Metronome")));
396
397         add_option (_("Misc"), new BoolOption (
398                                 "count-in",
399                                 _("Always count-in when recording"),
400                                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_count_in),
401                                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_count_in)
402                                 ));
403
404         add_option (_("Misc"), new OptionEditorHeading (_("Defaults")));
405
406         Gtk::Button* btn = Gtk::manage (new Gtk::Button (_("Use these settings as defaults")));
407         btn->signal_clicked().connect (sigc::mem_fun (*this, &SessionOptionEditor::save_defaults));
408         add_option (_("Misc"), new FooOption (btn));
409
410         set_current_page (_("Timecode"));
411 }
412
413 void
414 SessionOptionEditor::parameter_changed (std::string const & p)
415 {
416         OptionEditor::parameter_changed (p);
417         if (p == "external-sync") {
418                 if (TransportMasterManager::instance().current()->type() == Engine) {
419                         _vpu->set_sensitive(!_session_config->get_external_sync());
420                 } else {
421                         _vpu->set_sensitive(true);
422                 }
423         }
424         else if (p == "timecode-format") {
425                 /* update offset clocks */
426                 parameter_changed("timecode-generator-offset");
427                 parameter_changed("slave-timecode-offset");
428         }
429         else if (p == "track-name-take") {
430                 _take_name->set_sensitive(_session_config->get_track_name_take());
431         }
432 }
433
434 /* the presence of absence of a monitor section is not really a regular session
435  * property so we provide these two functions to act as setter/getter slots
436  */
437
438 bool
439 SessionOptionEditor::set_use_monitor_section (bool yn)
440 {
441         bool had_monitor_section = _session->monitor_out() != 0;
442
443         if (yn) {
444                 _session->add_monitor_section ();
445         } else {
446                 _session->remove_monitor_section ();
447         }
448
449         /* store this choice for any new sessions */
450
451         Config->set_use_monitor_bus (yn);
452
453         return had_monitor_section != (_session->monitor_out() != 0);
454 }
455
456 bool
457 SessionOptionEditor::get_use_monitor_section ()
458 {
459         return _session->monitor_out() != 0;
460 }
461
462 void
463 SessionOptionEditor::save_defaults ()
464 {
465         _session->save_default_options();
466 }