remove confusing RC preferences option for get/set use monitor section, and simplymak...
[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
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         /* FADES */
121
122         ComboOption<CrossfadeChoice>* cfc = new ComboOption<CrossfadeChoice> (
123                 "xfade-choice",
124                 _("Default crossfade type"),
125                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_choice),
126                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_choice)
127                 );
128
129         cfc->add (ConstantPowerMinus3dB, _("Constant power (-3dB) crossfade"));
130         cfc->add (ConstantPowerMinus6dB, _("Linear (-6dB) crossfade"));
131
132         add_option (_("Fades"), cfc);
133
134         add_option (_("Fades"), new SpinOption<float> (
135                 _("destructive-xfade-seconds"),
136                 _("Destructive crossfade length"),
137                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
138                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
139                 0, 1000, 1, 10,
140                 _("ms")
141                             ));
142
143         add_option (_("Fades"), new BoolOption (
144                             "use-region-fades",
145                             _("Region fades active"),
146                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
147                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
148                             ));
149
150         add_option (_("Fades"), new BoolOption (
151                             "show-region-fades",
152                             _("Region fades visible"),
153                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
154                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
155                             ));
156
157         /* Media */
158
159         add_option (_("Media"), new OptionEditorHeading (_("Audio file format")));
160
161         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
162                 "native-file-data-format",
163                 _("Sample format"),
164                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
165                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
166                 );
167
168         sf->add (FormatFloat, _("32-bit floating point"));
169         sf->add (FormatInt24, _("24-bit integer"));
170         sf->add (FormatInt16, _("16-bit integer"));
171
172         add_option (_("Media"), sf);
173
174         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
175                 "native-file-header-format",
176                 _("File type"),
177                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
178                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
179                 );
180
181         hf->add (BWF, _("Broadcast WAVE"));
182         hf->add (WAVE, _("WAVE"));
183         hf->add (WAVE64, _("WAVE-64"));
184         hf->add (CAF, _("CAF"));
185
186         add_option (_("Media"), hf);
187
188         add_option (_("Media"), new OptionEditorHeading (_("File locations")));
189
190         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
191                                                       _session->path(),
192                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
193                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));
194         add_option (_("Media"), spo);
195
196         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
197                                     _session->path(),
198                                     sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
199                                     sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
200
201         add_option (_("Media"), spo);
202
203         /* Monitoring */
204
205         add_option (_("Monitoring"), new BoolOption (
206                             "auto-input",
207                             _("Track Input Monitoring automatically follows transport state (\"auto-input\")"),
208                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
209                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
210                             ));
211
212         add_option (_("Monitoring"), new BoolOption (
213                             "have-monitor-section",
214                             _("Use monitor section in this session"),
215                             sigc::mem_fun (*this, &SessionOptionEditor::get_use_monitor_section),
216                             sigc::mem_fun (*this, &SessionOptionEditor::set_use_monitor_section)
217                             ));
218
219         /* Misc */
220
221         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
222
223         add_option (_("Misc"), new BoolOption (
224                             "midi-copy-is-fork",
225                             _("MIDI region copies are independent"),
226                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
227                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
228                             ));
229
230         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
231                 "insert-merge-policy",
232                 _("Policy for handling overlapping notes\n on the same MIDI channel"),
233                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
234                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
235                 );
236
237         li->add (InsertMergeReject, _("never allow them"));
238         li->add (InsertMergeRelax, _("don't do anything in particular"));
239         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
240         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
241         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
242         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
243
244         add_option (_("Misc"), li);
245
246         add_option (_("Misc"), new OptionEditorHeading (_("Glue to bars and beats")));
247
248         add_option (_("Misc"), new BoolOption (
249                             "glue-new-markers-to-bars-and-beats",
250                             _("Glue new markers to bars and beats"),
251                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
252                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
253                             ));
254
255         add_option (_("Misc"), new BoolOption (
256                             "glue-new-regions-to-bars-and-beats",
257                             _("Glue new regions to bars and beats"),
258                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
259                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
260                             ));
261 }
262
263 void
264 SessionOptionEditor::parameter_changed (std::string const & p)
265 {
266         OptionEditor::parameter_changed (p);
267         if (p == "external-sync") {
268                 if (Config->get_sync_source() == JACK) {
269                         _vpu->set_sensitive(!_session_config->get_external_sync());
270                 } else {
271                         _vpu->set_sensitive(true);
272                 }
273         }
274         if (p == "timecode-format") {
275                 /* update offset clocks */
276                 parameter_changed("timecode-generator-offset");
277                 parameter_changed("slave-timecode-offset");
278         }
279 }
280
281 /* the presence of absence of a monitor section is not really a regular session
282  * property so we provide these two functions to act as setter/getter slots
283  */
284
285 bool
286 SessionOptionEditor::set_use_monitor_section (bool yn)
287 {
288         bool had_monitor_section = _session->monitor_out();
289
290         if (yn) {
291                 _session->add_monitor_section ();
292         } else {
293                 _session->remove_monitor_section ();
294         }
295
296         /* store this choice for any new sessions */
297         
298         Config->set_use_monitor_bus (yn);
299
300         return had_monitor_section != yn;
301 }
302
303 bool
304 SessionOptionEditor::get_use_monitor_section ()
305 {
306         return _session->monitor_out() != 0;
307 }