+int64_t
+MIDIDM::parse_mclk (uint8_t* buf, pframes_t timestamp) const
+{
+ /* calculate time difference */
+#define MODCLK (16384) // 1<<(2*7)
+ const int64_t tc = (_monotonic_cnt + timestamp) & 0x3fff; // MODCLK - 1;
+ const int64_t ti = ((buf[2] & 0x7f) << 7) | (buf[1] & 0x7f);
+ const int64_t tdiff = (MODCLK + tc - ti) % MODCLK;
+#ifdef DEBUG_MIDIDM
+ printf("MCLK DELAY: #%5"PRId64" dt:%6"PRId64" [spl] (%6"PRId64" - %8"PRId64") @(%8"PRId64" + %d)\n",
+ _cnt_total, tdiff, tc, ti, _monotonic_cnt, timestamp);
+#endif
+ return tdiff;
+}
+
+int64_t
+MIDIDM::parse_mtc (uint8_t* buf, pframes_t timestamp) const
+{
+#define MODTC (2097152) // 1<<(3*7)
+ const int64_t tc = (_monotonic_cnt + timestamp) & 0x001FFFFF;
+ const int64_t ti = (buf[5] & 0x7f)
+ | ((buf[6] & 0x7f) << 7)
+ | ((buf[7] & 0x7f) << 14)
+ | ((buf[8] & 0x7f) << 21);
+ const int64_t tdiff = (MODTC + tc - ti) % MODTC;
+#ifdef DEBUG_MIDIDM
+ printf("MTC DELAY: #%5"PRId64" dt:%6"PRId64" [spl] (%6"PRId64" - %8"PRId64") @(%8"PRId64" + %d)\n",
+ _cnt_total, tdiff, tc, ti, _monotonic_cnt, timestamp);
+#endif
+ return tdiff;
+}