+ omega = 2.0 * M_PI * qtr / 2.0 / double(session.frame_rate());
+ b = 1.4142135623730950488 * omega;
+ c = omega * omega;
+
+ e2 = qtr;
+ t0 = double(tme);
+ t1 = t0 + e2;
+ DEBUG_TRACE (DEBUG::MTC, string_compose ("[re-]init MTC DLL %1 %2 %3\n", t0, t1, e2));
+}
+
+/* called from MIDI parser */
+void
+MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, framepos_t now)
+{
+ busy_guard1++;
+ const double qtr_d = quarter_frame_duration;
+
+ mtc_frame_dll += qtr_d * (double) transport_direction;
+ mtc_frame = rint(mtc_frame_dll);
+
+ DEBUG_TRACE (DEBUG::MTC, string_compose ("qtr frame %1 at %2 -> mtc_frame: %3\n", which_qtr, now, mtc_frame));
+
+ double mtc_speed = 0;
+ if (first_mtc_timestamp != 0) {
+ /* update MTC DLL and calculate speed */
+ const double e = mtc_frame_dll - (double)transport_direction * ((double)now - (double)current.timestamp + t0);
+ t0 = t1;
+ t1 += b * e + e2;
+ e2 += c * e;
+
+ mtc_speed = (t1 - t0) / qtr_d;
+ DEBUG_TRACE (DEBUG::MTC, string_compose ("qtr frame DLL t0:%1 t1:%2 err:%3 spd:%4 ddt:%5\n", t0, t1, e, mtc_speed, e2 - qtr_d));
+
+ current.guard1++;
+ current.position = mtc_frame;
+ current.timestamp = now;
+ current.speed = mtc_speed;
+ current.guard2++;
+
+ last_inbound_frame = now;
+ }
+