allow to include solo,mute buttons on meterbridge
[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         add_option (_("Sync"), new BoolOption (
83                             "use-video-file-fps",
84                             _("Use Video File's FPS Instead of Timecode Value for Timeline and Video Monitor."),
85                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_video_file_fps),
86                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_video_file_fps)
87                             ));
88
89         add_option (_("Sync"), new BoolOption (
90                             "videotimeline-pullup",
91                             _("Apply Pull-Up/Down to Video Timeline and Video Monitor (Unless in JACK-sync)."),
92                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_videotimeline_pullup),
93                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_videotimeline_pullup)
94                             ));
95
96         add_option (_("Timecode"), new OptionEditorHeading (_("Ext Timecode Offsets")));
97
98         ClockOption* sco = new ClockOption (
99                 "slave-timecode-offset",
100                 _("Slave Timecode offset"),
101                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_slave_timecode_offset),
102                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_slave_timecode_offset)
103                 );
104
105         sco->set_session (_session);
106         sco->clock().set_negative_allowed (true);
107         Gtkmm2ext::UI::instance()->set_tip (sco->tip_widget(), _("The specified offset is added to the received timecode (MTC or LTC)."));
108
109         add_option (_("Timecode"), sco);
110
111         ClockOption* gco = new ClockOption (
112                 "timecode-generator-offset",
113                 _("Timecode Generator offset"),
114                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_generator_offset),
115                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_generator_offset)
116                 );
117
118         gco->set_session (_session);
119         gco->clock().set_negative_allowed (true);
120         Gtkmm2ext::UI::instance()->set_tip (gco->tip_widget(), _("Specify an offset which is added to the generated timecode (so far only LTC)."));
121
122         add_option (_("Timecode"), gco);
123
124         add_option (_("Timecode"), new OptionEditorHeading (_("JACK Transport/Time Settings")));
125
126         add_option (_("Timecode"), new BoolOption (
127                             "jack-time-master",
128                             string_compose (_("%1 is JACK Time Master (provides Bar|Beat|Tick and other information to JACK)"), PROGRAM_NAME),
129                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_jack_time_master),
130                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_jack_time_master)
131                             ));
132
133         /* FADES */
134
135         ComboOption<CrossfadeChoice>* cfc = new ComboOption<CrossfadeChoice> (
136                 "xfade-choice",
137                 _("Default crossfade type"),
138                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_choice),
139                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_choice)
140                 );
141
142         cfc->add (ConstantPowerMinus3dB, _("Constant power (-3dB) crossfade"));
143         cfc->add (ConstantPowerMinus6dB, _("Linear (-6dB) crossfade"));
144
145         add_option (_("Fades"), cfc);
146
147         add_option (_("Fades"), new SpinOption<float> (
148                 _("destructive-xfade-seconds"),
149                 _("Destructive crossfade length"),
150                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
151                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
152                 0, 1000, 1, 10,
153                 _("ms")
154                             ));
155
156         add_option (_("Fades"), new BoolOption (
157                             "use-region-fades",
158                             _("Region fades active"),
159                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
160                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
161                             ));
162
163         add_option (_("Fades"), new BoolOption (
164                             "show-region-fades",
165                             _("Region fades visible"),
166                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
167                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
168                             ));
169
170         /* Media */
171
172         add_option (_("Media"), new OptionEditorHeading (_("Audio file format")));
173
174         ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
175                 "native-file-data-format",
176                 _("Sample format"),
177                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
178                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
179                 );
180
181         sf->add (FormatFloat, _("32-bit floating point"));
182         sf->add (FormatInt24, _("24-bit integer"));
183         sf->add (FormatInt16, _("16-bit integer"));
184
185         add_option (_("Media"), sf);
186
187         ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
188                 "native-file-header-format",
189                 _("File type"),
190                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
191                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
192                 );
193
194         hf->add (BWF, _("Broadcast WAVE"));
195         hf->add (WAVE, _("WAVE"));
196         hf->add (WAVE64, _("WAVE-64"));
197         hf->add (CAF, _("CAF"));
198
199         add_option (_("Media"), hf);
200
201         add_option (_("Media"), new OptionEditorHeading (_("File locations")));
202
203         SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
204                                                       _session->path(),
205                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
206                                                       sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));
207         add_option (_("Media"), spo);
208
209         spo = new SearchPathOption ("midi-search-path", _("Search for MIDI files in:"),
210                                     _session->path(),
211                                     sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_search_path),
212                                     sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_search_path));
213
214         add_option (_("Media"), spo);
215
216         /* Monitoring */
217
218         add_option (_("Monitoring"), new BoolOption (
219                             "auto-input",
220                             _("Track Input Monitoring automatically follows transport state (\"auto-input\")"),
221                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_input),
222                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_input)
223                             ));
224
225         add_option (_("Monitoring"), new BoolOption (
226                             "have-monitor-section",
227                             _("Use monitor section in this session"),
228                             sigc::mem_fun (*this, &SessionOptionEditor::get_use_monitor_section),
229                             sigc::mem_fun (*this, &SessionOptionEditor::set_use_monitor_section)
230                             ));
231
232         /* Misc */
233
234         add_option (_("Misc"), new OptionEditorHeading (_("MIDI Options")));
235
236         add_option (_("Misc"), new BoolOption (
237                             "midi-copy-is-fork",
238                             _("MIDI region copies are independent"),
239                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_midi_copy_is_fork),
240                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_midi_copy_is_fork)
241                             ));
242
243         ComboOption<InsertMergePolicy>* li = new ComboOption<InsertMergePolicy> (
244                 "insert-merge-policy",
245                 _("Policy for handling overlapping notes\n on the same MIDI channel"),
246                 sigc::mem_fun (*_session_config, &SessionConfiguration::get_insert_merge_policy),
247                 sigc::mem_fun (*_session_config, &SessionConfiguration::set_insert_merge_policy)
248                 );
249
250         li->add (InsertMergeReject, _("never allow them"));
251         li->add (InsertMergeRelax, _("don't do anything in particular"));
252         li->add (InsertMergeReplace, _("replace any overlapped existing note"));
253         li->add (InsertMergeTruncateExisting, _("shorten the overlapped existing note"));
254         li->add (InsertMergeTruncateAddition, _("shorten the overlapping new note"));
255         li->add (InsertMergeExtend, _("replace both overlapping notes with a single note"));
256
257         add_option (_("Misc"), li);
258
259         add_option (_("Misc"), new OptionEditorHeading (_("Glue to bars and beats")));
260
261         add_option (_("Misc"), new BoolOption (
262                             "glue-new-markers-to-bars-and-beats",
263                             _("Glue new markers to bars and beats"),
264                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_markers_to_bars_and_beats),
265                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_markers_to_bars_and_beats)
266                             ));
267
268         add_option (_("Misc"), new BoolOption (
269                             "glue-new-regions-to-bars-and-beats",
270                             _("Glue new regions to bars and beats"),
271                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_glue_new_regions_to_bars_and_beats),
272                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_glue_new_regions_to_bars_and_beats)
273                             ));
274
275         add_option (_("Misc"), new OptionEditorHeading (_("Meterbridge Options")));
276
277         add_option (_("Misc"), new BoolOption (
278                             "show-midi-on-meterbridge",
279                             _("Include Midi Tracks on Meterbridge"),
280                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_midi_on_meterbridge),
281                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_midi_on_meterbridge)
282                             ));
283
284         add_option (_("Misc"), new BoolOption (
285                             "show-busses-on-meterbridge",
286                             _("Include Busses on Meterbridge"),
287                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_busses_on_meterbridge),
288                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_busses_on_meterbridge)
289                             ));
290
291         add_option (_("Misc"), new BoolOption (
292                             "show-master-on-meterbridge",
293                             _("Include Master Bus on Meterbridge"),
294                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_master_on_meterbridge),
295                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_master_on_meterbridge)
296                             ));
297
298         add_option (_("Misc"), new BoolOption (
299                             "show-rec-on-meterbridge",
300                             _("Show Rec-enable Button on Meterbridge"),
301                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_rec_on_meterbridge),
302                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_rec_on_meterbridge)
303                             ));
304
305         add_option (_("Misc"), new BoolOption (
306                             "show-mute-on-meterbridge",
307                             _("Include Mute Button on Meterbridge"),
308                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_mute_on_meterbridge),
309                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_mute_on_meterbridge)
310                             ));
311
312         add_option (_("Misc"), new BoolOption (
313                             "show-solo-on-meterbridge",
314                             _("Show Solo Button on Meterbridge"),
315                             sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_solo_on_meterbridge),
316                             sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_solo_on_meterbridge)
317                             ));
318
319 }
320
321 void
322 SessionOptionEditor::parameter_changed (std::string const & p)
323 {
324         OptionEditor::parameter_changed (p);
325         if (p == "external-sync") {
326                 if (Config->get_sync_source() == JACK) {
327                         _vpu->set_sensitive(!_session_config->get_external_sync());
328                 } else {
329                         _vpu->set_sensitive(true);
330                 }
331         }
332         if (p == "timecode-format") {
333                 /* update offset clocks */
334                 parameter_changed("timecode-generator-offset");
335                 parameter_changed("slave-timecode-offset");
336         }
337 }
338
339 /* the presence of absence of a monitor section is not really a regular session
340  * property so we provide these two functions to act as setter/getter slots
341  */
342
343 bool
344 SessionOptionEditor::set_use_monitor_section (bool yn)
345 {
346         bool had_monitor_section = _session->monitor_out();
347
348         if (yn) {
349                 _session->add_monitor_section ();
350         } else {
351                 _session->remove_monitor_section ();
352         }
353
354         /* store this choice for any new sessions */
355         
356         Config->set_use_monitor_bus (yn);
357
358         return had_monitor_section != yn;
359 }
360
361 bool
362 SessionOptionEditor::get_use_monitor_section ()
363 {
364         return _session->monitor_out() != 0;
365 }