tweaks to be ready for more information timecode display in Timecode clock mode
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 12 Oct 2012 22:04:21 +0000 (22:04 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 12 Oct 2012 22:04:21 +0000 (22:04 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13264 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h
libs/ardour/ardour/session.h
libs/ardour/ardour/slave.h
libs/ardour/ltc_slave.cc
libs/ardour/mtc_slave.cc
libs/ardour/session_process.cc
libs/ardour/session_transport.cc

index 19f01ff7d1bfe5d312cbfbb104f435a33bf24bd2..04ed4dbbd4bb924c3b58350d12fccbcd74c89be5 100644 (file)
@@ -73,6 +73,7 @@
 #include "ardour/session_route.h"
 #include "ardour/session_state_utils.h"
 #include "ardour/session_utils.h"
+#include "ardour/slave.h"
 
 #include "timecode/time.h"
 
@@ -1105,8 +1106,17 @@ ARDOUR_UI::update_timecode_format ()
        char buf[64];
 
        if (_session) {
+               bool matching;
+               TimecodeSlave* tcslave;
+
+               if ((tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
+                       matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
+               } else {
+                       matching = true;
+               }
+                       
                snprintf (buf, sizeof (buf), S_("Timecode|TC: <span foreground=\"%s\">%sfps</span>"), 
-                         rand() % 2 ? X_("red") : X_("green"), 
+                         matching ? X_("red") : X_("green"),
                          Timecode::timecode_format_name (_session->config.get_timecode_format()).c_str());
        } else {
                snprintf (buf, sizeof (buf), "TC: n/a");
index 03a7ca33bac00eef3050014214a4915fee49a2a3..f041c3f5ceb2339fe193aaf74d10402e9b81526e 100644 (file)
 #include "gtkmm2ext/utils.h"
 #include "gtkmm2ext/rgb_macros.h"
 
-#include "ardour/types.h"
+#include "ardour/profile.h"
 #include "ardour/session.h"
+#include "ardour/slave.h"
 #include "ardour/tempo.h"
-#include "ardour/profile.h"
+#include "ardour/types.h"
 
 #include "ardour_ui.h"
 #include "audio_clock.h"
@@ -150,6 +151,7 @@ AudioClock::set_font ()
        Glib::RefPtr<Gtk::Style> style = get_style ();
        Pango::FontDescription font; 
        Pango::AttrFontDesc* font_attr;
+       uint32_t font_size;
 
        if (!is_realized()) {
                font = get_font_for_style (get_name());
@@ -157,19 +159,30 @@ AudioClock::set_font ()
                font = style->get_font();
        }
 
-       font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
+       font_size = font.get_size();
 
+       font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
+       
        normal_attributes.change (*font_attr);
        editing_attributes.change (*font_attr);
 
        /* now a smaller version of the same font */
 
        delete font_attr;
-       font.set_size ((int) lrint (font.get_size() * info_font_scale_factor));
+       font.set_size ((int) lrint (font_size * info_font_scale_factor));
        font.set_weight (Pango::WEIGHT_NORMAL);
        font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
  
        info_attributes.change (*font_attr);
+
+       /* and an even smaller one */
+
+       delete font_attr;
+       font.set_size ((int) lrint (font_size * info_font_scale_factor * 0.75));
+       font.set_weight (Pango::WEIGHT_BOLD);
+       font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
+       small_info_attributes.change (*font_attr);
        
        delete font_attr;
 
@@ -250,6 +263,7 @@ AudioClock::set_colors ()
        
        normal_attributes.change (*foreground_attr);
        info_attributes.change (*foreground_attr);
+       small_info_attributes.change (*foreground_attr);
        editing_attributes.change (*foreground_attr);
        editing_attributes.change (*editing_attr);
 
@@ -260,8 +274,13 @@ AudioClock::set_colors ()
        }
 
        if (_left_layout) {
-               _left_layout->set_attributes (info_attributes);
-               _right_layout->set_attributes (info_attributes);
+               if (_mode == Timecode) {
+                       _left_layout->set_attributes (small_info_attributes);
+                       _right_layout->set_attributes (small_info_attributes);
+               } else {
+                       _left_layout->set_attributes (info_attributes);
+                       _right_layout->set_attributes (info_attributes);
+               }
        }
 
        queue_draw ();
@@ -919,7 +938,12 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset)
        } 
 
        if (when == last_when && !force) {
-               return;
+               if (_mode != Timecode) {
+                       /* timecode may need to force display of TC source
+                        * time, so don't return early.
+                        */
+                       return;
+               }
        }
 
        if (!editing) {
@@ -1083,25 +1107,35 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
        if (_left_layout) {
 
                if (_session->config.get_external_sync()) {
+                       Slave* slave = _session->slave();
+
                        switch (Config->get_sync_source()) {
                        case JACK:
                                _left_layout->set_text ("JACK");
                                break;
                        case MTC:
-                               _left_layout->set_text ("MTC");
+                               if (slave) {
+                                       _left_layout->set_text (string_compose ("MTC %1", dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
+                               } else {
+                                       _left_layout->set_text ("MTC --pending--");
+                               }
                                break;
                        case MIDIClock:
                                _left_layout->set_text ("M-Clock");
                                break;
                        case LTC:
-                               _left_layout->set_text ("LTC");
+                               if (slave) {
+                                       _left_layout->set_text (string_compose ("LTC %1", dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
+                               } else {
+                                       _left_layout->set_text ("LTC --pending--");
+                               }
                                break;
                        }
                } else {
                        _left_layout->set_text ("INT");
                }
 
-               _right_layout->set_text ("TBDiscussed");
+               _right_layout->set_text ("77:77:77:77");
        }
 }
 
@@ -1984,7 +2018,7 @@ AudioClock::set_mode (Mode m)
 
        switch (_mode) {
        case Timecode:
-               mode_based_info_ratio = 0.5;
+               mode_based_info_ratio = 0.57; // trial and error, could be affected by font metrics
                insert_map.push_back (11);
                insert_map.push_back (10);
                insert_map.push_back (8);
@@ -2026,6 +2060,16 @@ AudioClock::set_mode (Mode m)
                break;
        }
 
+       if (_left_layout) {
+               if (_mode == Timecode) {
+                       _left_layout->set_attributes (small_info_attributes);
+                       _right_layout->set_attributes (small_info_attributes);
+               } else {
+                       _left_layout->set_attributes (info_attributes);
+                       _right_layout->set_attributes (info_attributes);
+               }
+       }
+
        set (last_when, true);
 
         if (!is_transient) {
index ed96ac43d40e9e85b03ae032afb8ddc6aa892f59..6235bbaf6906f0412f2a7fa6e3fa74d9387a5e29 100644 (file)
@@ -114,6 +114,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        Pango::AttrList normal_attributes;
        Pango::AttrList editing_attributes;
        Pango::AttrList info_attributes;
+       Pango::AttrList small_info_attributes;
 
        int first_height;
        int first_width;
index 499c431c8b1261c986c3baea72c4369fe83ca560..5e1245294b4137b59ebd489b71599bcc1666bc00 100644 (file)
@@ -800,6 +800,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        };
 
        SlaveState slave_state() const { return _slave_state; }
+        Slave* slave() const { return _slave; }
 
        boost::shared_ptr<SessionPlaylists> playlists;
 
index 24fd79c9434f40c943192127df495ce9c9e84738..48da6954176eac3fc4d6c89e79c0742ac311e856 100644 (file)
@@ -230,6 +230,13 @@ class TimecodeSlave : public Slave {
     TimecodeSlave () {}
 
     virtual Timecode::TimecodeFormat apparent_timecode_format() const = 0;
+
+    /* this is intended to be used by a UI and polled from a timeout. it should
+       return a string describing the current position of the TC source. it 
+       should NOT do any computation, but should use a cached value
+       of the TC source position.
+    */
+    virtual std::string approximate_current_position() const = 0;
 };
 
 class MTC_Slave : public TimecodeSlave {
@@ -250,6 +257,7 @@ class MTC_Slave : public TimecodeSlave {
        bool give_slave_full_control_over_transport_speed() const;
 
         Timecode::TimecodeFormat apparent_timecode_format() const;
+        std::string approximate_current_position() const;
 
   private:
        Session&    session;
@@ -325,6 +333,7 @@ public:
        bool give_slave_full_control_over_transport_speed() const;
 
         Timecode::TimecodeFormat apparent_timecode_format() const;
+        std::string approximate_current_position() const;
 
   private:
        int parse_ltc(const jack_nframes_t, const jack_default_audio_sample_t * const, const framecnt_t);
index 14cb3ae59d1cdb29e5d2d7fc4b6bf3f3e36c90e3..01dd3cdfae11ab4072246353937f10c7133a6abc 100644 (file)
@@ -253,3 +253,9 @@ LTC_Slave::apparent_timecode_format () const
        /* XXX to be computed, determined from incoming stream */
        return timecode_25;
 }
+
+std::string 
+LTC_Slave::approximate_current_position() const
+{
+       return "88:88:88:88";
+}
index 1c2770ed45d7bd181170e859e4b6670ed8be0bf3..c568cd5d6a461bc6f0e7fc4a4ffe3a25e83dd910 100644 (file)
@@ -626,3 +626,9 @@ MTC_Slave::apparent_timecode_format () const
 {
        return mtc_timecode;
 }
+
+std::string 
+MTC_Slave::approximate_current_position() const
+{
+       return "88:88:88:88";
+}
index 0cba1e807cd7ad9c76d89df4c1ff3addefcf597f..273a40366da94135f3b3ff0656e86d1bd2dfb499 100644 (file)
@@ -1119,6 +1119,7 @@ Session::process_event (SessionEvent* ev)
                break;
 
        case SessionEvent::SetSyncSource:
+               DEBUG_TRACE (DEBUG::Slave, "seen request for new slave\n");
                use_sync_source (ev->slave);
                break;
 
index d4a0a010c91de53c3d9ea5d9ff87001376114f90..6141716301c23615e5fb8db2331b50dbcf8c0386 100644 (file)
@@ -99,6 +99,7 @@ Session::request_sync_source (Slave* new_slave)
        _was_seamless = seamless;
 
        ev->slave = new_slave;
+       DEBUG_TRACE (DEBUG::Slave, "sent request for new slave\n");
        queue_event (ev);
 }
 
@@ -1323,6 +1324,8 @@ Session::use_sync_source (Slave* new_slave)
        delete _slave;
        _slave = new_slave;
 
+       DEBUG_TRACE (DEBUG::Slave, string_compose ("set new slave to %1\n", _slave));
+
        send_full_time_code (_transport_frame);
 
        boost::shared_ptr<RouteList> rl = routes.reader();