LTC generator config
authorRobin Gareus <robin@gareus.org>
Tue, 23 Oct 2012 23:32:36 +0000 (23:32 +0000)
committerRobin Gareus <robin@gareus.org>
Tue, 23 Oct 2012 23:32:36 +0000 (23:32 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13324 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/option_editor.h
gtk2_ardour/rc_option_editor.cc
gtk2_ardour/rc_option_editor.h
libs/ardour/ardour/rc_configuration_vars.h
libs/ardour/session_ltc.cc

index 6ea38648b0b8eaa92d22e923b5c1438487526106..07c11ac8b457d36a96624665baecfef3c62bb61c 100644 (file)
@@ -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.
  */
index 1a85bee2db48478878573f3c00d7d5fc31d01ff5..091f31b2177ccac478aedafe5b75e194d10be594 100644 (file)
@@ -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 ()
 {
index 76978d43176fae663784449ff435c9cbc5886f2e..392865d2d8d9b3736d3205c2a355deacfffb5b9c 100644 (file)
@@ -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<ARDOUR::ListenPosition>* _listen_position;
        VisibilityGroup _mixer_strip_visibility;
        ComboOption<ARDOUR::SyncSource>* _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;
 };
index b05b90fa14e4a3cffded7d35c10d2080bf16ad56..ea44c60682b4a59a0ed182906b281a7461cf3089 100644 (file)
@@ -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 */
 
index 298225502440244f11263864f01be0b280ad7055..95d7d2861c759cd7eacc046214ba7e8f90b78cde 100644 (file)
@@ -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