slave delta display
authorRobin Gareus <robin@gareus.org>
Wed, 17 Oct 2012 15:57:51 +0000 (15:57 +0000)
committerRobin Gareus <robin@gareus.org>
Wed, 17 Oct 2012 15:57:51 +0000 (15:57 +0000)
impl MClk slave, update format for LTC, MTC

negative delta: Ardour is behind,
positive delta: Ardour is ahead of ext clock.

git-svn-id: svn://localhost/ardour2/branches/3.0@13299 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/slave.h
libs/ardour/ltc_slave.cc
libs/ardour/midi_clock_slave.cc
libs/ardour/mtc_slave.cc

index ba9ec8fe27861c6b29593a22aeaf411507b523c8..8589473d3ba9193b29b6ea4f6ebc54a36c789adc 100644 (file)
@@ -38,6 +38,9 @@
 #include <ltc.h>
 #endif
 
+// used for approximate_current_delta():
+#define PLUSMINUS(A) ( ((A)<0) ? "\u2012" : (((A)>0) ? "+" : "\u00B1") )
+
 namespace MIDI {
        class Port;
 }
@@ -419,6 +422,7 @@ class MIDIClock_Slave : public Slave {
        bool give_slave_full_control_over_transport_speed() const { return true; }
 
        void set_bandwidth (double a_bandwith) { bandwidth = a_bandwith; }
+       std::string approximate_current_delta() const;
 
   protected:
        ISlaveSessionProxy* session;
@@ -462,6 +466,8 @@ class MIDIClock_Slave : public Slave {
        /// DLL filter coefficients
        double b, c, omega;
 
+       frameoffset_t  current_delta;
+
        void reset ();
        void start (MIDI::Parser& parser, framepos_t timestamp);
        void contineu (MIDI::Parser& parser, framepos_t timestamp);
index 0e4f50b55a35b90bda69c291c744b3153e8a6f1d..0247a5168f42bc3ec5dfba1e1bf9520790c81673 100644 (file)
@@ -549,13 +549,14 @@ LTC_Slave::approximate_current_delta() const
 {
        char delta[24];
        if (last_timestamp == 0 || frames_in_sequence < 2) {
-               snprintf(delta, sizeof(delta), "---");
+               snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
        } else if ((monotonic_cnt - last_timestamp) > 2 * frames_per_ltc_frame) {
                snprintf(delta, sizeof(delta), "flywheel");
        } else {
                // TODO if current_delta > 1 frame -> display timecode.
                // delta >0 if A3's transport is _behind_ LTC
-               snprintf(delta, sizeof(delta), "%+4" PRIi64 " sm", current_delta);
+               snprintf(delta, sizeof(delta), "%s%4" PRIi64 " sm",
+                               PLUSMINUS(-current_delta), abs(current_delta));
        }
        return std::string(delta);
 }
index 05c0e9e2ac866570b1396e46dc5a0526fe1cbc51..a54965557ab085f7b8626f8072295a098bcf09fe 100644 (file)
@@ -205,6 +205,7 @@ MIDIClock_Slave::reset ()
        _started  = true;
 
        // session->request_locate(0, false);
+       current_delta = 0;
 }
 
 void
@@ -343,6 +344,7 @@ MIDIClock_Slave::speed_and_position (double& speed, framepos_t& pos)
        }
 
        DEBUG_TRACE (DEBUG::MidiClock, string_compose ("speed_and_position: %1 & %2 <-> %3 (transport)\n", speed, pos, session->transport_frame()));
+       current_delta = pos - session->transport_frame();
 
        return true;
 }
@@ -354,3 +356,16 @@ MIDIClock_Slave::resolution() const
        return (framecnt_t) one_ppqn_in_frames * ppqn;
 }
 
+std::string
+MIDIClock_Slave::approximate_current_delta() const
+{
+       char delta[24];
+       if (last_timestamp == 0 || _starting) {
+               snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
+       } else {
+               snprintf(delta, sizeof(delta), "%s%4" PRIi64 " sm",
+                               PLUSMINUS(-current_delta), abs(current_delta));
+       }
+       return std::string(delta);
+}
+
index 9b81acf67cd0062382eeb3192adb11c722b14293..79f985e0a2018c095828efa2ddf1d931430e2a30 100644 (file)
@@ -664,10 +664,11 @@ MTC_Slave::approximate_current_delta() const
        SafeTime last;
        read_current (&last);
        if (last.timestamp == 0 || reset_pending) {
-               snprintf(delta, sizeof(delta), "---");
+               snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
        } else {
                // TODO if current_delta > 1 frame -> display timecode.
-               snprintf(delta, sizeof(delta), "%+4" PRIi64 " sm", current_delta);
+               snprintf(delta, sizeof(delta), "%s%4" PRIi64 " sm",
+                               PLUSMINUS(-current_delta), abs(current_delta));
        }
        return std::string(delta);
 }