1 #include "ardour/session.h"
3 #include "ardour/auditioner.h"
4 #include "ardour/audioengine.h"
5 #include "ardour/port.h"
7 #include "gui_thread.h"
8 #include "session_option_editor.h"
9 #include "port_matrix.h"
13 using namespace ARDOUR
;
15 class OptionsPortMatrix
: public PortMatrix
18 OptionsPortMatrix (Gtk::Window
* parent
, ARDOUR::Session
* session
)
19 : PortMatrix (parent
, session
, DataType::AUDIO
)
21 _port_group
.reset (new PortGroup (""));
22 _ports
[OURS
].add_group (_port_group
);
28 void setup_ports (int dim
)
31 _port_group
->clear ();
32 _port_group
->add_bundle (_session
->click_io()->bundle());
33 _port_group
->add_bundle (_session
->the_auditioner()->output()->bundle());
35 _ports
[OTHER
].gather (_session
, true, false);
39 void set_state (ARDOUR::BundleChannel c
[2], bool s
)
41 Bundle::PortList
const & our_ports
= c
[OURS
].bundle
->channel_ports (c
[OURS
].channel
);
42 Bundle::PortList
const & other_ports
= c
[OTHER
].bundle
->channel_ports (c
[OTHER
].channel
);
44 if (c
[OURS
].bundle
== _session
->click_io()->bundle()) {
46 for (ARDOUR::Bundle::PortList::const_iterator i
= our_ports
.begin(); i
!= our_ports
.end(); ++i
) {
47 for (ARDOUR::Bundle::PortList::const_iterator j
= other_ports
.begin(); j
!= other_ports
.end(); ++j
) {
49 Port
* f
= _session
->engine().get_port_by_name (*i
);
53 _session
->click_io()->connect (f
, *j
, 0);
55 _session
->click_io()->disconnect (f
, *j
, 0);
62 PortMatrixNode::State
get_state (ARDOUR::BundleChannel c
[2]) const
64 Bundle::PortList
const & our_ports
= c
[OURS
].bundle
->channel_ports (c
[OURS
].channel
);
65 Bundle::PortList
const & other_ports
= c
[OTHER
].bundle
->channel_ports (c
[OTHER
].channel
);
67 if (c
[OURS
].bundle
== _session
->click_io()->bundle()) {
69 for (ARDOUR::Bundle::PortList::const_iterator i
= our_ports
.begin(); i
!= our_ports
.end(); ++i
) {
70 for (ARDOUR::Bundle::PortList::const_iterator j
= other_ports
.begin(); j
!= other_ports
.end(); ++j
) {
71 Port
* f
= _session
->engine().get_port_by_name (*i
);
74 if (f
->connected_to (*j
)) {
75 return PortMatrixNode::ASSOCIATED
;
77 return PortMatrixNode::NOT_ASSOCIATED
;
88 return PortMatrixNode::NOT_ASSOCIATED
;
91 bool list_is_global (int dim
) const {
92 return (dim
== OTHER
);
95 bool can_remove_channels (boost::shared_ptr
<Bundle
>) const {
99 void remove_channel (ARDOUR::BundleChannel
) {}
101 std::string
disassociation_verb () const {
102 return _("Disassociate");
106 /* see PortMatrix: signal flow from 0 to 1 (out to in) */
112 boost::shared_ptr
<PortGroup
> _port_group
;
117 class ConnectionOptions
: public OptionEditorBox
120 ConnectionOptions (Gtk::Window
* parent
, ARDOUR::Session
* s
)
121 : _port_matrix (parent
, s
)
123 _box
->pack_start (_port_matrix
);
126 void parameter_changed (string
const &)
131 void set_state_from_config ()
137 OptionsPortMatrix _port_matrix
;
140 SessionOptionEditor::SessionOptionEditor (Session
* s
)
141 : OptionEditor (&(s
->config
), _("Session Preferences"))
142 , _session_config (&(s
->config
))
146 ComboOption
<uint32_t>* spf
= new ComboOption
<uint32_t> (
147 "subframes-per-frame",
148 _("Subframes per frame"),
149 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_subframes_per_frame
),
150 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_subframes_per_frame
)
153 spf
->add (80, _("80"));
154 spf
->add (100, _("100"));
156 add_option (_("Sync"), spf
);
158 ComboOption
<SyncSource
>* ssrc
= new ComboOption
<SyncSource
> (
160 _("External sync source"),
161 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_sync_source
),
162 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_sync_source
)
165 s
->MTC_PortChanged
.connect (_session_connections
, invalidator (*this), boost::bind (&SessionOptionEditor::populate_sync_options
, this, s
, ssrc
), gui_context());
166 s
->MIDIClock_PortChanged
.connect (_session_connections
, invalidator (*this), boost::bind (&SessionOptionEditor::populate_sync_options
, this, s
, ssrc
), gui_context());
167 s
->config
.ParameterChanged
.connect (_session_connections
, invalidator (*this), ui_bind (&SessionOptionEditor::follow_sync_state
, this, _1
, s
, ssrc
), gui_context());
169 populate_sync_options (s
, ssrc
);
170 follow_sync_state (string ("external-sync"), s
, ssrc
);
172 add_option (_("Sync"), ssrc
);
174 ComboOption
<TimecodeFormat
>* smf
= new ComboOption
<TimecodeFormat
> (
176 _("Timecode frames-per-second"),
177 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_timecode_format
),
178 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_timecode_format
)
181 smf
->add (timecode_23976
, _("23.976"));
182 smf
->add (timecode_24
, _("24"));
183 smf
->add (timecode_24976
, _("24.976"));
184 smf
->add (timecode_25
, _("25"));
185 smf
->add (timecode_2997
, _("29.97"));
186 smf
->add (timecode_2997drop
, _("29.97 drop"));
187 smf
->add (timecode_30
, _("30"));
188 smf
->add (timecode_30drop
, _("30 drop"));
189 smf
->add (timecode_5994
, _("59.94"));
190 smf
->add (timecode_60
, _("60"));
192 add_option (_("Sync"), smf
);
194 add_option (_("Sync"), new BoolOption (
195 "timecode-source-is-synced",
196 _("Timecode source shares sample clock with audio interface"),
197 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_timecode_source_is_synced
),
198 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_timecode_source_is_synced
)
201 ComboOption
<float>* vpu
= new ComboOption
<float> (
203 _("Pull-up / pull-down"),
204 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_video_pullup
),
205 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_video_pullup
)
208 vpu
->add (4.1667 + 0.1, _("4.1667 + 0.1%"));
209 vpu
->add (4.1667, _("4.1667"));
210 vpu
->add (4.1667 - 0.1, _("4.1667 - 0.1%"));
211 vpu
->add (0.1, _("0.1"));
212 vpu
->add (0, _("none"));
213 vpu
->add (-0.1, _("-0.1"));
214 vpu
->add (-4.1667 + 0.1, _("-4.1667 + 0.1%"));
215 vpu
->add (-4.1667, _("-4.1667"));
216 vpu
->add (-4.1667 - 0.1, _("-4.1667 - 0.1%"));
218 add_option (_("Sync"), vpu
);
222 ComboOption
<CrossfadeModel
>* cfm
= new ComboOption
<CrossfadeModel
> (
224 _("Crossfades are created"),
225 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_xfade_model
),
226 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_xfade_model
)
229 cfm
->add (FullCrossfade
, _("to span entire overlap"));
230 cfm
->add (ShortCrossfade
, _("short"));
232 add_option (_("Fades"), cfm
);
234 add_option (_("Fades"), new SpinOption
<float> (
235 _("short-xfade-seconds"),
236 _("Short crossfade length"),
237 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_short_xfade_seconds
),
238 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_short_xfade_seconds
),
243 add_option (_("Fades"), new SpinOption
<float> (
244 _("destructive-xfade-seconds"),
245 _("Destructive crossfade length"),
246 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_destructive_xfade_msecs
),
247 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_destructive_xfade_msecs
),
252 add_option (_("Fades"), new BoolOption (
254 _("Create crossfades automatically"),
255 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_auto_xfade
),
256 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_auto_xfade
)
259 add_option (_("Fades"), new BoolOption (
261 _("Crossfades active"),
262 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_xfades_active
),
263 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_xfades_active
)
266 add_option (_("Fades"), new BoolOption (
268 _("Crossfades visible"),
269 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_xfades_visible
),
270 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_xfades_visible
)
273 add_option (_("Fades"), new BoolOption (
275 _("Region fades active"),
276 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_use_region_fades
),
277 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_use_region_fades
)
280 add_option (_("Fades"), new BoolOption (
282 _("Region fades visible"),
283 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_show_region_fades
),
284 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_show_region_fades
)
289 add_option (_("Misc"), new OptionEditorHeading (_("Audio file format")));
291 ComboOption
<SampleFormat
>* sf
= new ComboOption
<SampleFormat
> (
292 "native-file-data-format",
294 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_native_file_data_format
),
295 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_native_file_data_format
)
298 sf
->add (FormatFloat
, _("32-bit floating point"));
299 sf
->add (FormatInt24
, _("24-bit integer"));
300 sf
->add (FormatInt16
, _("16-bit integer"));
302 add_option (_("Misc"), sf
);
304 ComboOption
<HeaderFormat
>* hf
= new ComboOption
<HeaderFormat
> (
305 "native-file-header-format",
307 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_native_file_header_format
),
308 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_native_file_header_format
)
311 hf
->add (BWF
, _("Broadcast WAVE"));
312 hf
->add (WAVE
, _("WAVE"));
313 hf
->add (WAVE64
, _("WAVE-64"));
314 hf
->add (CAF
, _("CAF"));
316 add_option (_("Misc"), hf
);
318 add_option (_("Misc"), new OptionEditorHeading (_("Layering")));
320 ComboOption
<LayerModel
>* lm
= new ComboOption
<LayerModel
> (
322 _("Layering model in overlaid mode"),
323 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_layer_model
),
324 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_layer_model
)
327 lm
->add (LaterHigher
, _("later is higher"));
328 lm
->add (MoveAddHigher
, _("most recently moved or added is higher"));
329 lm
->add (AddHigher
, _("most recently added is higher"));
331 add_option (_("Misc"), lm
);
333 add_option (_("Misc"), new OptionEditorHeading (_("Broadcast WAVE metadata")));
335 add_option (_("Misc"), new EntryOption (
338 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_bwf_country_code
),
339 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_bwf_country_code
)
342 add_option (_("Misc"), new EntryOption (
343 "bwf-organization-code",
344 _("Organization code"),
345 sigc::mem_fun (*_session_config
, &SessionConfiguration::get_bwf_organization_code
),
346 sigc::mem_fun (*_session_config
, &SessionConfiguration::set_bwf_organization_code
)
349 add_option (_("Connections"), new ConnectionOptions (this, s
));
353 SessionOptionEditor::populate_sync_options (Session
* s
, Option
* opt
)
355 ComboOption
<SyncSource
>* sync_opt
= dynamic_cast<ComboOption
<SyncSource
>* > (opt
);
357 vector
<SyncSource
> sync_opts
= s
->get_available_sync_options ();
361 for (vector
<SyncSource
>::iterator i
= sync_opts
.begin(); i
!= sync_opts
.end(); ++i
) {
362 sync_opt
->add (*i
, sync_source_to_string (*i
));
367 SessionOptionEditor::follow_sync_state (std::string p
, Session
* s
, Option
* opt
)
369 ComboOption
<SyncSource
>* sync_opt
= dynamic_cast<ComboOption
<SyncSource
>* > (opt
);
370 if (p
== "external-sync") {
371 if (s
->config
.get_external_sync()) {
372 sync_opt
->set_sensitive (false);
374 sync_opt
->set_sensitive (true);