1 #include "ardour/session.h"
3 #include "ardour/auditioner.h"
4 #include "ardour/audioengine.h"
5 #include "ardour/port.h"
6 #include "session_option_editor.h"
7 #include "port_matrix.h"
12 using namespace ARDOUR;
14 class OptionsPortMatrix : public PortMatrix
17 OptionsPortMatrix (Gtk::Window* parent, ARDOUR::Session& session)
18 : PortMatrix (parent, session, DataType::AUDIO)
20 _port_group.reset (new PortGroup (""));
21 _ports[OURS].add_group (_port_group);
27 void setup_ports (int dim)
29 cerr << _session.the_auditioner()->output()->n_ports() << "\n";
32 _port_group->clear ();
33 _port_group->add_bundle (_session.click_io()->bundle());
34 _port_group->add_bundle (_session.the_auditioner()->output()->bundle());
36 _ports[OTHER].gather (_session, true, false);
40 void set_state (ARDOUR::BundleChannel c[2], bool s)
42 Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel);
43 Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel);
45 if (c[OURS].bundle == _session.click_io()->bundle()) {
47 for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
48 for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
50 Port* f = _session.engine().get_port_by_name (*i);
54 _session.click_io()->connect (f, *j, 0);
56 _session.click_io()->disconnect (f, *j, 0);
63 PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const
65 Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel);
66 Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel);
68 if (c[OURS].bundle == _session.click_io()->bundle()) {
70 for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
71 for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
72 Port* f = _session.engine().get_port_by_name (*i);
75 if (f->connected_to (*j)) {
76 return PortMatrixNode::ASSOCIATED;
78 return PortMatrixNode::NOT_ASSOCIATED;
89 return PortMatrixNode::NOT_ASSOCIATED;
92 bool list_is_global (int dim) const {
93 return (dim == OTHER);
96 bool can_remove_channels (boost::shared_ptr<Bundle>) const {
100 void remove_channel (ARDOUR::BundleChannel) {}
102 std::string disassociation_verb () const {
103 return _("Disassociate");
107 /* see PortMatrix: signal flow from 0 to 1 (out to in) */
113 boost::shared_ptr<PortGroup> _port_group;
118 class ConnectionOptions : public OptionEditorBox
121 ConnectionOptions (Gtk::Window* parent, ARDOUR::Session* s)
122 : _port_matrix (parent, *s)
124 _box->pack_start (_port_matrix);
127 void parameter_changed (string const &)
132 void set_state_from_config ()
138 OptionsPortMatrix _port_matrix;
141 SessionOptionEditor::SessionOptionEditor (Session* s)
142 : OptionEditor (&(s->config), _("Session Preferences"))
143 , _session_config (&(s->config))
147 ComboOption<uint32_t>* spf = new ComboOption<uint32_t> (
148 "subframes-per-frame",
149 _("Subframes per frame"),
150 mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame),
151 mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame)
154 spf->add (80, _("80"));
155 spf->add (100, _("100"));
157 add_option (_("Sync"), spf);
159 ComboOption<SyncSource>* ssrc = new ComboOption<SyncSource> (
161 _("External sync source"),
162 mem_fun (*_session_config, &SessionConfiguration::get_sync_source),
163 mem_fun (*_session_config, &SessionConfiguration::set_sync_source)
166 s->MTC_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc));
167 s->MIDIClock_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc));
168 s->config.ParameterChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::follow_sync_state), s, ssrc));
170 populate_sync_options (s, ssrc);
171 follow_sync_state (string ("external-sync"), s, ssrc);
173 add_option (_("Sync"), ssrc);
175 ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
177 _("Timecode frames-per-second"),
178 mem_fun (*_session_config, &SessionConfiguration::get_timecode_format),
179 mem_fun (*_session_config, &SessionConfiguration::set_timecode_format)
182 smf->add (timecode_23976, _("23.976"));
183 smf->add (timecode_24, _("24"));
184 smf->add (timecode_24976, _("24.976"));
185 smf->add (timecode_25, _("25"));
186 smf->add (timecode_2997, _("29.97"));
187 smf->add (timecode_2997drop, _("29.97 drop"));
188 smf->add (timecode_30, _("30"));
189 smf->add (timecode_30drop, _("30 drop"));
190 smf->add (timecode_5994, _("59.94"));
191 smf->add (timecode_60, _("60"));
193 add_option (_("Sync"), smf);
195 add_option (_("Sync"), new BoolOption (
196 "timecode-source-is-synced",
197 _("Timecode source shares sample clock with audio interface"),
198 mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced),
199 mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced)
202 ComboOption<float>* vpu = new ComboOption<float> (
204 _("Pull-up / pull-down"),
205 mem_fun (*_session_config, &SessionConfiguration::get_video_pullup),
206 mem_fun (*_session_config, &SessionConfiguration::set_video_pullup)
209 vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
210 vpu->add (4.1667, _("4.1667"));
211 vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
212 vpu->add (0.1, _("0.1"));
213 vpu->add (0, _("none"));
214 vpu->add (-0.1, _("-0.1"));
215 vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
216 vpu->add (-4.1667, _("-4.1667"));
217 vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
219 add_option (_("Sync"), vpu);
223 ComboOption<CrossfadeModel>* cfm = new ComboOption<CrossfadeModel> (
225 _("Crossfades are created"),
226 mem_fun (*_session_config, &SessionConfiguration::get_xfade_model),
227 mem_fun (*_session_config, &SessionConfiguration::set_xfade_model)
230 cfm->add (FullCrossfade, _("to span entire overlap"));
231 cfm->add (ShortCrossfade, _("short"));
233 add_option (_("Fades"), cfm);
235 add_option (_("Fades"), new SpinOption<float> (
236 _("short-xfade-seconds"),
237 _("Short crossfade length"),
238 mem_fun (*_session_config, &SessionConfiguration::get_short_xfade_seconds),
239 mem_fun (*_session_config, &SessionConfiguration::set_short_xfade_seconds),
244 add_option (_("Fades"), new SpinOption<float> (
245 _("destructive-xfade-seconds"),
246 _("Destructive crossfade length"),
247 mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs),
248 mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs),
253 add_option (_("Fades"), new BoolOption (
255 _("Create crossfades automatically"),
256 mem_fun (*_session_config, &SessionConfiguration::get_auto_xfade),
257 mem_fun (*_session_config, &SessionConfiguration::set_auto_xfade)
260 add_option (_("Fades"), new BoolOption (
262 _("Crossfades active"),
263 mem_fun (*_session_config, &SessionConfiguration::get_xfades_active),
264 mem_fun (*_session_config, &SessionConfiguration::set_xfades_active)
267 add_option (_("Fades"), new BoolOption (
269 _("Crossfades visible"),
270 mem_fun (*_session_config, &SessionConfiguration::get_xfades_visible),
271 mem_fun (*_session_config, &SessionConfiguration::set_xfades_visible)
274 add_option (_("Fades"), new BoolOption (
276 _("Region fades active"),
277 mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades),
278 mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades)
281 add_option (_("Fades"), new BoolOption (
283 _("Region fades visible"),
284 mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades),
285 mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades)
290 add_option (_("Misc"), new OptionEditorHeading (_("Audio file format")));
292 ComboOption<SampleFormat>* sf = new ComboOption<SampleFormat> (
293 "native-file-data-format",
295 mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format),
296 mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format)
299 sf->add (FormatFloat, _("32-bit floating point"));
300 sf->add (FormatInt24, _("24-bit integer"));
301 sf->add (FormatInt16, _("16-bit integer"));
303 add_option (_("Misc"), sf);
305 ComboOption<HeaderFormat>* hf = new ComboOption<HeaderFormat> (
306 "native-file-header-format",
308 mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format),
309 mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format)
312 hf->add (BWF, _("Broadcast WAVE"));
313 hf->add (WAVE, _("WAVE"));
314 hf->add (WAVE64, _("WAVE-64"));
315 hf->add (CAF, _("CAF"));
317 add_option (_("Misc"), hf);
319 add_option (_("Misc"), new OptionEditorHeading (_("Layering")));
321 ComboOption<LayerModel>* lm = new ComboOption<LayerModel> (
323 _("Layering model in overlaid mode"),
324 mem_fun (*_session_config, &SessionConfiguration::get_layer_model),
325 mem_fun (*_session_config, &SessionConfiguration::set_layer_model)
328 lm->add (LaterHigher, _("later is higher"));
329 lm->add (MoveAddHigher, _("most recently moved or added is higher"));
330 lm->add (AddHigher, _("most recently added is higher"));
332 add_option (_("Misc"), lm);
334 add_option (_("Misc"), new OptionEditorHeading (_("Broadcast WAVE metadata")));
336 add_option (_("Misc"), new EntryOption (
339 mem_fun (*_session_config, &SessionConfiguration::get_bwf_country_code),
340 mem_fun (*_session_config, &SessionConfiguration::set_bwf_country_code)
343 add_option (_("Misc"), new EntryOption (
344 "bwf-organization-code",
345 _("Organization code"),
346 mem_fun (*_session_config, &SessionConfiguration::get_bwf_organization_code),
347 mem_fun (*_session_config, &SessionConfiguration::set_bwf_organization_code)
350 add_option (_("Connections"), new ConnectionOptions (this, s));
354 SessionOptionEditor::populate_sync_options (Session* s, Option* opt)
356 ComboOption<SyncSource>* sync_opt = dynamic_cast<ComboOption<SyncSource>* > (opt);
358 vector<SyncSource> sync_opts = s->get_available_sync_options ();
362 for (vector<SyncSource>::iterator i = sync_opts.begin(); i != sync_opts.end(); ++i) {
363 sync_opt->add (*i, sync_source_to_string (*i));
368 SessionOptionEditor::follow_sync_state (std::string p, Session* s, Option* opt)
370 ComboOption<SyncSource>* sync_opt = dynamic_cast<ComboOption<SyncSource>* > (opt);
371 if (p == "external-sync") {
372 if (s->config.get_external_sync()) {
373 sync_opt->set_sensitive (false);
375 sync_opt->set_sensitive (true);