MTC-slave: print error if framerate mismatch
authorRobin Gareus <robin@gareus.org>
Wed, 10 Oct 2012 20:37:56 +0000 (20:37 +0000)
committerRobin Gareus <robin@gareus.org>
Wed, 10 Oct 2012 20:37:56 +0000 (20:37 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13231 d708f5d6-7413-0410-9779-e7cbd77b26cf

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

index be6b9665604cbab03af32f8d999804555b0ead7d..8379c689cea586e8f486b25fff3435e159509495 100644 (file)
@@ -260,6 +260,10 @@ class MTC_Slave : public Slave {
        int            busy_guard1;
        int            busy_guard2;
 
+       TimecodeFormat mtc_timecode;
+       TimecodeFormat a3e_timecode;
+       bool           printed_timecode_warning;
+
        /* DLL - chase MTC */
        double t0; ///< time at the beginning of the MTC quater frame
        double t1; ///< calculated end of the MTC quater frame
index f5b70317ddc72a69a8c7bc16e107ed6f3f6aa1fb..e46e9eb9553087743cc77007977e5e71a117cc09 100644 (file)
@@ -61,6 +61,10 @@ MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p)
 
        last_mtc_fps_byte = session.get_mtc_timecode_bits ();
 
+       mtc_timecode = timecode_60; // track changes of MTC timecode
+       a3e_timecode = timecode_60; // track canges of Ardour's timecode
+       printed_timecode_warning = false;
+
        reset (true);
        rebind (p);
 }
@@ -332,11 +336,29 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now)
        }
 
        if (reset_tc) {
-               if (!did_reset_tc_format) {
-                       saved_tc_format = session.config.get_timecode_format();
-                       did_reset_tc_format = true;
+               TimecodeFormat cur_timecode = session.config.get_timecode_format();
+               if (0 /* TODO preferences  */) {
+                       /* enforce time-code */
+                       if (!did_reset_tc_format) {
+                               saved_tc_format = cur_timecode;
+                               did_reset_tc_format = true;
+                       }
+                       if (cur_timecode != tc_format) {
+                               warning << _("Session and MTC framerate mismatch.") << endmsg;
+                       }
+                       session.config.set_timecode_format (tc_format);
+               } else {
+                       /* only warn about TC mismatch */
+                       if (mtc_timecode != tc_format) printed_timecode_warning = false;
+                       if (a3e_timecode != cur_timecode) printed_timecode_warning = false;
+
+                       if (cur_timecode != tc_format && ! printed_timecode_warning) {
+                               warning << _("Session and MTC framerate mismatch.") << endmsg;
+                               printed_timecode_warning = true;
+                       }
                }
-               session.config.set_timecode_format (tc_format);
+               mtc_timecode = tc_format;
+               a3e_timecode = cur_timecode;
        }
 
        DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC at %1 TC %2 = mtc_frame %3 (from full message ? %4)\n",