X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fsession_option_editor.cc;h=13f5dbc26cbea8b0e3b8e423d0c046c4927e56ba;hb=fddb3778120e25b3b8e8134084e260dac07c1365;hp=5defe27e9d3e1dfe9d5f26358f9bc444070539cf;hpb=6da5dd6d41df9e3d05b9b8cceaf1b671b4e21141;p=ardour.git diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index 5defe27e9d..13f5dbc26c 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -3,36 +3,36 @@ #include "ardour/auditioner.h" #include "ardour/audioengine.h" #include "ardour/port.h" + +#include "gui_thread.h" #include "session_option_editor.h" #include "port_matrix.h" #include "i18n.h" using namespace std; -using namespace sigc; using namespace ARDOUR; class OptionsPortMatrix : public PortMatrix { public: - OptionsPortMatrix (ARDOUR::Session& session) - : PortMatrix (session, DataType::AUDIO) + OptionsPortMatrix (Gtk::Window* parent, ARDOUR::Session* session) + : PortMatrix (parent, session, DataType::AUDIO) { _port_group.reset (new PortGroup ("")); _ports[OURS].add_group (_port_group); - + setup_all_ports (); + init (); } void setup_ports (int dim) { - cerr << _session.the_auditioner()->output()->n_ports() << "\n"; - if (dim == OURS) { _port_group->clear (); - _port_group->add_bundle (_session.click_io()->bundle()); - _port_group->add_bundle (_session.the_auditioner()->output()->bundle()); + _port_group->add_bundle (_session->click_io()->bundle()); + _port_group->add_bundle (_session->the_auditioner()->output()->bundle()); } else { - _ports[OTHER].gather (_session, true); + _ports[OTHER].gather (_session, true, false); } } @@ -40,19 +40,19 @@ public: { Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel); Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel); - - if (c[OURS].bundle == _session.click_io()->bundle()) { + + if (c[OURS].bundle == _session->click_io()->bundle()) { for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); assert (f); - + if (s) { - _session.click_io()->connect (f, *j, 0); + _session->click_io()->connect (f, *j, 0); } else { - _session.click_io()->disconnect (f, *j, 0); + _session->click_io()->disconnect (f, *j, 0); } } } @@ -63,14 +63,14 @@ public: { Bundle::PortList const & our_ports = c[OURS].bundle->channel_ports (c[OURS].channel); Bundle::PortList const & other_ports = c[OTHER].bundle->channel_ports (c[OTHER].channel); - - if (c[OURS].bundle == _session.click_io()->bundle()) { - + + if (c[OURS].bundle == _session->click_io()->bundle()) { + for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) { for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) { - Port* f = _session.engine().get_port_by_name (*i); + Port* f = _session->engine().get_port_by_name (*i); assert (f); - + if (f->connected_to (*j)) { return PortMatrixNode::ASSOCIATED; } else { @@ -88,24 +88,20 @@ public: return PortMatrixNode::NOT_ASSOCIATED; } - bool list_is_global (int dim) const - { + bool list_is_global (int dim) const { return (dim == OTHER); } - void add_channel (boost::shared_ptr) {} - bool can_remove_channels (int) const { + bool can_remove_channels (boost::shared_ptr) const { return false; } + void remove_channel (ARDOUR::BundleChannel) {} - bool can_rename_channels (int) const { - return false; - } std::string disassociation_verb () const { return _("Disassociate"); } - + private: /* see PortMatrix: signal flow from 0 to 1 (out to in) */ enum { @@ -121,13 +117,13 @@ private: class ConnectionOptions : public OptionEditorBox { public: - ConnectionOptions (ARDOUR::Session* s) - : _port_matrix (*s) + ConnectionOptions (Gtk::Window* parent, ARDOUR::Session* s) + : _port_matrix (parent, s) { _box->pack_start (_port_matrix); } - void parameter_changed (string const & p) + void parameter_changed (string const &) { } @@ -142,16 +138,94 @@ private: }; SessionOptionEditor::SessionOptionEditor (Session* s) - : OptionEditor (&(s->config), _("Session Preferences")), - _session_config (&(s->config)) + : OptionEditor (&(s->config), _("Session Properties")) + , _session_config (&(s->config)) { + set_name ("SessionProperties"); + + /* SYNC */ + + ComboOption* spf = new ComboOption ( + "subframes-per-frame", + _("Subframes per frame"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame) + ); + + spf->add (80, _("80")); + spf->add (100, _("100")); + + add_option (_("Sync"), spf); + + ComboOption* ssrc = new ComboOption ( + "sync-source", + _("External sync source"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_sync_source), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_sync_source) + ); + + s->MTC_PortChanged.connect (_session_connections, invalidator (*this), boost::bind (&SessionOptionEditor::populate_sync_options, this, s, ssrc), gui_context()); + s->MIDIClock_PortChanged.connect (_session_connections, invalidator (*this), boost::bind (&SessionOptionEditor::populate_sync_options, this, s, ssrc), gui_context()); + s->config.ParameterChanged.connect (_session_connections, invalidator (*this), ui_bind (&SessionOptionEditor::follow_sync_state, this, _1, s, ssrc), gui_context()); + + populate_sync_options (s, ssrc); + follow_sync_state (string ("external-sync"), s, ssrc); + + add_option (_("Sync"), ssrc); + + ComboOption* smf = new ComboOption ( + "timecode-format", + _("Timecode frames-per-second"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_format), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_format) + ); + + smf->add (timecode_23976, _("23.976")); + smf->add (timecode_24, _("24")); + smf->add (timecode_24976, _("24.976")); + smf->add (timecode_25, _("25")); + smf->add (timecode_2997, _("29.97")); + smf->add (timecode_2997drop, _("29.97 drop")); + smf->add (timecode_30, _("30")); + smf->add (timecode_30drop, _("30 drop")); + smf->add (timecode_5994, _("59.94")); + smf->add (timecode_60, _("60")); + + add_option (_("Sync"), smf); + + add_option (_("Sync"), new BoolOption ( + "timecode-source-is-synced", + _("Timecode source shares sample clock with audio interface"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced) + )); + + ComboOption* vpu = new ComboOption ( + "video-pullup", + _("Pull-up / pull-down"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_video_pullup), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_video_pullup) + ); + + vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%")); + vpu->add (4.1667, _("4.1667")); + vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%")); + vpu->add (0.1, _("0.1")); + vpu->add (0, _("none")); + vpu->add (-0.1, _("-0.1")); + vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%")); + vpu->add (-4.1667, _("-4.1667")); + vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%")); + + add_option (_("Sync"), vpu); + /* FADES */ ComboOption* cfm = new ComboOption ( "xfade-model", _("Crossfades are created"), - mem_fun (*_session_config, &SessionConfiguration::get_xfade_model), - mem_fun (*_session_config, &SessionConfiguration::set_xfade_model) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfade_model), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfade_model) ); cfm->add (FullCrossfade, _("to span entire overlap")); @@ -162,8 +236,8 @@ SessionOptionEditor::SessionOptionEditor (Session* s) add_option (_("Fades"), new SpinOption ( _("short-xfade-seconds"), _("Short crossfade length"), - mem_fun (*_session_config, &SessionConfiguration::get_short_xfade_seconds), - mem_fun (*_session_config, &SessionConfiguration::set_short_xfade_seconds), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_short_xfade_seconds), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_short_xfade_seconds), 0, 1000, 1, 10, _("ms"), 0.001 )); @@ -171,8 +245,8 @@ SessionOptionEditor::SessionOptionEditor (Session* s) add_option (_("Fades"), new SpinOption ( _("destructive-xfade-seconds"), _("Destructive crossfade length"), - mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs), - mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_destructive_xfade_msecs), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_destructive_xfade_msecs), 0, 1000, 1, 10, _("ms") )); @@ -180,98 +254,38 @@ SessionOptionEditor::SessionOptionEditor (Session* s) add_option (_("Fades"), new BoolOption ( "auto-xfade", _("Create crossfades automatically"), - mem_fun (*_session_config, &SessionConfiguration::get_auto_xfade), - mem_fun (*_session_config, &SessionConfiguration::set_auto_xfade) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_auto_xfade), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_auto_xfade) )); add_option (_("Fades"), new BoolOption ( "xfades-active", _("Crossfades active"), - mem_fun (*_session_config, &SessionConfiguration::get_xfades_active), - mem_fun (*_session_config, &SessionConfiguration::set_xfades_active) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfades_active), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfades_active) )); add_option (_("Fades"), new BoolOption ( "xfades-visible", _("Crossfades visible"), - mem_fun (*_session_config, &SessionConfiguration::get_xfades_visible), - mem_fun (*_session_config, &SessionConfiguration::set_xfades_visible) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_xfades_visible), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_xfades_visible) )); add_option (_("Fades"), new BoolOption ( "use-region-fades", _("Region fades active"), - mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades), - mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_use_region_fades), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_use_region_fades) )); add_option (_("Fades"), new BoolOption ( "show-region-fades", _("Region fades visible"), - mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades), - mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades) - )); - - /* SYNC */ - - ComboOption* spf = new ComboOption ( - "subframes-per-frame", - _("Subframes per frame"), - mem_fun (*_session_config, &SessionConfiguration::get_subframes_per_frame), - mem_fun (*_session_config, &SessionConfiguration::set_subframes_per_frame) - ); - - spf->add (80, _("80")); - spf->add (100, _("100")); - - add_option (_("Sync"), spf); - - ComboOption* smf = new ComboOption ( - "smpte-format", - _("Timecode frames-per-second"), - mem_fun (*_session_config, &SessionConfiguration::get_smpte_format), - mem_fun (*_session_config, &SessionConfiguration::set_smpte_format) - ); - - smf->add (smpte_23976, _("23.976")); - smf->add (smpte_24, _("24")); - smf->add (smpte_24976, _("24.976")); - smf->add (smpte_25, _("25")); - smf->add (smpte_2997, _("29.97")); - smf->add (smpte_2997drop, _("29.97 drop")); - smf->add (smpte_30, _("30")); - smf->add (smpte_30drop, _("30 drop")); - smf->add (smpte_5994, _("59.94")); - smf->add (smpte_60, _("60")); - - add_option (_("Sync"), smf); - - add_option (_("Sync"), new BoolOption ( - "timecode-source-is-synced", - _("Timecode source is synced"), - mem_fun (*_session_config, &SessionConfiguration::get_timecode_source_is_synced), - mem_fun (*_session_config, &SessionConfiguration::set_timecode_source_is_synced) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_show_region_fades), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_show_region_fades) )); - ComboOption* vpu = new ComboOption ( - "video-pullup", - _("Pull-up / pull-down"), - mem_fun (*_session_config, &SessionConfiguration::get_video_pullup), - mem_fun (*_session_config, &SessionConfiguration::set_video_pullup) - ); - - vpu->add (4.1667 + 0.1, _("4.1667 + 0.1%")); - vpu->add (4.1667, _("4.1667")); - vpu->add (4.1667 - 0.1, _("4.1667 - 0.1%")); - vpu->add (0.1, _("0.1")); - vpu->add (0, _("none")); - vpu->add (-0.1, _("-0.1")); - vpu->add (-4.1667 + 0.1, _("-4.1667 + 0.1%")); - vpu->add (-4.1667, _("-4.1667")); - vpu->add (-4.1667 - 0.1, _("-4.1667 - 0.1%")); - - add_option (_("Sync"), vpu); - /* MISC */ add_option (_("Misc"), new OptionEditorHeading (_("Audio file format"))); @@ -279,8 +293,8 @@ SessionOptionEditor::SessionOptionEditor (Session* s) ComboOption* sf = new ComboOption ( "native-file-data-format", _("Sample format"), - mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format), - mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_data_format), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_data_format) ); sf->add (FormatFloat, _("32-bit floating point")); @@ -292,8 +306,8 @@ SessionOptionEditor::SessionOptionEditor (Session* s) ComboOption* hf = new ComboOption ( "native-file-header-format", _("File type"), - mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format), - mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_native_file_header_format), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_native_file_header_format) ); hf->add (BWF, _("Broadcast WAVE")); @@ -307,9 +321,9 @@ SessionOptionEditor::SessionOptionEditor (Session* s) ComboOption* lm = new ComboOption ( "layer-model", - _("Layering model"), - mem_fun (*_session_config, &SessionConfiguration::get_layer_model), - mem_fun (*_session_config, &SessionConfiguration::set_layer_model) + _("Layering model in overlaid mode"), + sigc::mem_fun (*_session_config, &SessionConfiguration::get_layer_model), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_layer_model) ); lm->add (LaterHigher, _("later is higher")); @@ -317,22 +331,49 @@ SessionOptionEditor::SessionOptionEditor (Session* s) lm->add (AddHigher, _("most recently added is higher")); add_option (_("Misc"), lm); - + add_option (_("Misc"), new OptionEditorHeading (_("Broadcast WAVE metadata"))); - + add_option (_("Misc"), new EntryOption ( "bwf-country-code", _("Country code"), - mem_fun (*_session_config, &SessionConfiguration::get_bwf_country_code), - mem_fun (*_session_config, &SessionConfiguration::set_bwf_country_code) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_bwf_country_code), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_bwf_country_code) )); add_option (_("Misc"), new EntryOption ( "bwf-organization-code", _("Organization code"), - mem_fun (*_session_config, &SessionConfiguration::get_bwf_organization_code), - mem_fun (*_session_config, &SessionConfiguration::set_bwf_organization_code) + sigc::mem_fun (*_session_config, &SessionConfiguration::get_bwf_organization_code), + sigc::mem_fun (*_session_config, &SessionConfiguration::set_bwf_organization_code) )); - add_option (_("Connections"), new ConnectionOptions (s)); + add_option (_("Connections"), new ConnectionOptions (this, s)); +} + +void +SessionOptionEditor::populate_sync_options (Session* s, Option* opt) +{ + ComboOption* sync_opt = dynamic_cast* > (opt); + + vector sync_opts = s->get_available_sync_options (); + + sync_opt->clear (); + + for (vector::iterator i = sync_opts.begin(); i != sync_opts.end(); ++i) { + sync_opt->add (*i, sync_source_to_string (*i)); + } +} + +void +SessionOptionEditor::follow_sync_state (std::string p, Session* s, Option* opt) +{ + ComboOption* sync_opt = dynamic_cast* > (opt); + if (p == "external-sync") { + if (s->config.get_external_sync()) { + sync_opt->set_sensitive (false); + } else { + sync_opt->set_sensitive (true); + } + } }