From 6f15ec961801599b6a76926f2a4ba6e96c7335e6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 23 Oct 2012 23:32:36 +0000 Subject: LTC generator config git-svn-id: svn://localhost/ardour2/branches/3.0@13324 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/option_editor.h | 42 ++++++++++++++++++++++++++++++ gtk2_ardour/rc_option_editor.cc | 33 ++++++++++++++++++++++- gtk2_ardour/rc_option_editor.h | 10 ++++--- libs/ardour/ardour/rc_configuration_vars.h | 4 ++- libs/ardour/session_ltc.cc | 5 ++-- 5 files changed, 87 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index 6ea38648b0..07c11ac8b4 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -285,6 +285,48 @@ private: }; +/** Component which provides the UI for a GTK HScale. + */ +class HSliderOption : public Option +{ +public: + + /** Construct an ComboOption. + * @param i id + * @param n User-visible name. + * @param g Slot to get the variable's value. + * @param s Slot to set the variable's value. + */ + HSliderOption ( + std::string const & i, + std::string const & n, + Gtk::Adjustment &adj + ) + : Option (i, n) + { + _label = manage (new Gtk::Label (n + ":")); + _label->set_alignment (0, 0.5); + _hscale = manage (new Gtk::HScale(adj)); + } + + void set_state_from_config () { } + + void add_to_page (OptionEditorPage* p) + { + add_widgets_to_page (p, _label, _hscale); + } + + void set_sensitive (bool yn) { + _hscale->set_sensitive (yn); + } + + Gtk::Widget& tip_widget() { return *_hscale; } + +private: + Gtk::Label* _label; + Gtk::HScale* _hscale; +}; + /** Component which provides the UI to handle an enumerated option using a GTK ComboBox. * The template parameter is the enumeration. */ diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 1a85bee2db..091f31b217 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -1106,13 +1106,36 @@ RCOptionEditor::RCOptionEditor () add_option (_("Transport"), new BoolOption ( "send-ltc", - _("Generate Linear/Longitudinal Time Code"), + _("Enable LTC generator"), sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_ltc), sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_ltc) )); + + _ltc_send_continuously = new BoolOption ( + "ltc-send-continuously", + _("send LTC while stopped"), + sigc::mem_fun (*_rc_config, &RCConfiguration::get_ltc_send_continuously), + sigc::mem_fun (*_rc_config, &RCConfiguration::set_ltc_send_continuously) + ); + Gtkmm2ext::UI::instance()->set_tip + (_ltc_send_continuously->tip_widget(), + _("If enabled, Ardour will continue to send LTC information even when the transport (playhead) is not moving.")); + add_option (_("Transport"), _ltc_send_continuously); + + _ltc_volume_adjustment = new Gtk::Adjustment(-18, -50, 0, .5, 3); + _ltc_volume_adjustment->set_value (20 * log10(_rc_config->get_ltc_output_volume())); + _ltc_volume_adjustment->signal_value_changed().connect (sigc::mem_fun (*this, &RCOptionEditor::ltc_generator_volume_changed)); + _ltc_volume_slider = new HSliderOption("ltcvol", ("LTC generator level:"), *_ltc_volume_adjustment); + + Gtkmm2ext::UI::instance()->set_tip + (_ltc_volume_slider->tip_widget(), + _("Specify the Peak Volume of the generated LTC signal in dbFS. A good value is 0dBu ^= -18dbFS in an EBU calibrated system.")); + + add_option (_("Transport"), _ltc_volume_slider); #endif parameter_changed ("sync-source"); + parameter_changed ("send-ltc"); /* EDITOR */ @@ -1763,9 +1786,17 @@ RCOptionEditor::parameter_changed (string const & p) _sync_framerate->set_sensitive (false); break; } + } else if (p == "send-ltc") { + bool const s = Config->get_send_ltc (); + _ltc_send_continuously->set_sensitive (s); + _ltc_volume_slider->set_sensitive (s); } } +void RCOptionEditor::ltc_generator_volume_changed () { + _rc_config->set_ltc_output_volume (pow(10, _ltc_volume_adjustment->get_value() / 20)); +} + void RCOptionEditor::populate_sync_options () { diff --git a/gtk2_ardour/rc_option_editor.h b/gtk2_ardour/rc_option_editor.h index 76978d4317..392865d2d8 100644 --- a/gtk2_ardour/rc_option_editor.h +++ b/gtk2_ardour/rc_option_editor.h @@ -38,14 +38,18 @@ public: private: void parameter_changed (std::string const &); + void ltc_generator_volume_changed (); ARDOUR::RCConfiguration* _rc_config; BoolOption* _solo_control_is_listen_control; ComboOption* _listen_position; VisibilityGroup _mixer_strip_visibility; ComboOption* _sync_source; - BoolOption* _sync_framerate; - BoolOption* _sync_genlock; - ComboStringOption* _ltc_port; + BoolOption* _sync_framerate; + BoolOption* _sync_genlock; + ComboStringOption* _ltc_port; + HSliderOption* _ltc_volume_slider; + Gtk::Adjustment* _ltc_volume_adjustment; + BoolOption* _ltc_send_continuously; PBD::ScopedConnection parameter_change_connection; }; diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index b05b90fa14..ea44c60682 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -53,7 +53,9 @@ CONFIG_VARIABLE (bool, timecode_source_is_synced, "timecode-source-is-synced", t CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", JACK) CONFIG_VARIABLE (std::string, ltc_source_port, "ltc-source-port", "system:capture_1") CONFIG_VARIABLE (bool, send_ltc, "send-ltc", false) -CONFIG_VARIABLE (std::string, ltc_output_port, "ltc-sink-port", "") +CONFIG_VARIABLE (bool, ltc_send_continuously, "ltc-send-continuously", true) +CONFIG_VARIABLE (std::string, ltc_output_port, "ltc-output-port", "") +CONFIG_VARIABLE (float, ltc_output_volume, "ltc-output-volume", 0.125893) /* control surfaces */ diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc index 2982255024..95d7d2861c 100644 --- a/libs/ardour/session_ltc.cc +++ b/libs/ardour/session_ltc.cc @@ -96,7 +96,8 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end return nframes; } - DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX %1 to %2 / %3\n", start_frame, end_frame, nframes)); + /* range from libltc (38..218) || - 128.0 -> (-90..90) */ + const float ltcvol = Config->get_ltc_output_volume()/(90.0); // pow(10, db/20.0)/(90.0); /* all systems go. Now here's the plan: * @@ -293,7 +294,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end // (6a) while ((ltc_buf_off < ltc_buf_len) && (txf < nframes)) { const float v1 = ltc_enc_buf[ltc_buf_off++] - 128.0; - const jack_default_audio_sample_t val = (jack_default_audio_sample_t) (v1*smult); + const jack_default_audio_sample_t val = (jack_default_audio_sample_t) (v1*ltcvol); out[txf++] = val; } #ifdef LTC_GEN_FRAMEDBUG -- cgit v1.2.3