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