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