- DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::speed_and_position eng-tme: %1 eng-pos: %2\n", now, sess_pos));
-
- double speed_flt = last.speed; ///< MTC speed from MTC-quarter-frame DLL
-
- /* interpolate position according to speed and time since last quarter-frame*/
- if (speed_flt == 0.0f) {
- elapsed = 0;
- } else {
- /* scale elapsed time by the current MTC speed */
- elapsed = (framecnt_t) rint (speed_flt * (now - last.timestamp));
- if (give_slave_full_control_over_transport_speed() && !engine_dll_reinitialized) {
- /* there is an engine vs MTC position frame-delta.
- * This mostly due to quantization and rounding of (speed * nframes)
- * but can also due to the session-process not calling
- * speed_and_position() every cycle under some circumstances.
- * Thus we use an other DLL to align the engine and the MTC
- */
-
- /* update engine DLL and calculate speed */
- const double e = double (last.position + elapsed - sess_pos);
- te0 = te1;
- te1 += be * e + ee2;
- ee2 += ce * e;
- speed_flt = (te1 - te0) / double(session.engine().samples_per_cycle());
- DEBUG_TRACE (DEBUG::MTC, string_compose ("engine DLL t0:%1 t1:%2 err:%3 spd:%4 ddt:%5\n", te0, te1, e, speed_flt, ee2 - session.engine().samples_per_cycle() ));
- }
- }