summaryrefslogtreecommitdiff
path: root/libs/ardour/mtc_slave.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-03-02 22:52:39 +0000
committerRobin Gareus <robin@gareus.org>2013-03-02 22:52:39 +0000
commitea29eb0d7dcc334b87f6ac3a8f884a5edb7d2ed4 (patch)
tree59f6c8ddbefe5b22dec7e151af7bba91ca9b743b /libs/ardour/mtc_slave.cc
parent97abc198035163e202415fbb9ccb375ea8f90dc8 (diff)
fix MTC slave+generator for non integer quarter_frame_duration
e.g. 44.1k [SPS] / 30 [fps] / 4 [MTC-frames per timecode-frame] = 367.5 [samples per MTC-frame] git-svn-id: svn://localhost/ardour2/branches/3.0@14115 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/mtc_slave.cc')
-rw-r--r--libs/ardour/mtc_slave.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc
index b3992598d3..a1005ff953 100644
--- a/libs/ardour/mtc_slave.cc
+++ b/libs/ardour/mtc_slave.cc
@@ -56,6 +56,7 @@ MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p)
reset_pending = 0;
reset_position = false;
mtc_frame = 0;
+ mtc_frame_dll = 0;
engine_dll_initstate = 0;
busy_guard1 = busy_guard2 = 0;
@@ -261,16 +262,16 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, framepos_t now)
{
busy_guard1++;
const double qtr_d = quarter_frame_duration;
- const framepos_t qtr = rint(qtr_d);
- mtc_frame += qtr * transport_direction;
+ 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 - (double(transport_direction) * (double(now) - double(current.timestamp) + t0));
+ const double e = mtc_frame_dll - (double)transport_direction * ((double)now - (double)current.timestamp + t0);
t0 = t1;
t1 += b * e + e2;
e2 += c * e;
@@ -463,6 +464,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now)
if (first_mtc_timestamp == 0 || current.timestamp == 0) {
first_mtc_timestamp = now;
init_mtc_dll(mtc_frame, qtr);
+ mtc_frame_dll = mtc_frame;
}
current.guard1++;
current.position = mtc_frame;