continue with MTC debugging

git-svn-id: svn://localhost/ardour2/branches/3.0@6235 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-12-01 02:04:10 +00:00
parent 929f9a101a
commit 1614402e50
2 changed files with 42 additions and 30 deletions

View file

@ -245,6 +245,7 @@ class MTC_Slave : public Slave, public sigc::trackable {
void update_mtc_time (const MIDI::byte *, bool); void update_mtc_time (const MIDI::byte *, bool);
void update_mtc_status (MIDI::Parser::MTC_Status); void update_mtc_status (MIDI::Parser::MTC_Status);
void read_current (SafeTime *) const; void read_current (SafeTime *) const;
double compute_apparent_speed (nframes64_t);
}; };
class MIDIClock_Slave : public Slave, public sigc::trackable { class MIDIClock_Slave : public Slave, public sigc::trackable {

View file

@ -78,9 +78,12 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/)
qtr = (long) (session.frames_per_timecode_frame() / 4); qtr = (long) (session.frames_per_timecode_frame() / 4);
mtc_frame += qtr; mtc_frame += qtr;
double speed = compute_apparent_speed (now);
current.guard1++; current.guard1++;
current.position = mtc_frame; current.position = mtc_frame;
current.timestamp = now; current.timestamp = now;
current.speed = speed;
current.guard2++; current.guard2++;
last_inbound_frame = now; last_inbound_frame = now;
@ -146,7 +149,6 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
} else { } else {
double speed;
/* We received the last quarter frame 7 quarter frames (1.75 mtc /* We received the last quarter frame 7 quarter frames (1.75 mtc
frames) after the instance when the contents of the mtc quarter frames) after the instance when the contents of the mtc quarter
@ -157,9 +159,26 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
mtc_frame += (long) (1.75 * session.frames_per_timecode_frame()) + session.worst_output_latency(); mtc_frame += (long) (1.75 * session.frames_per_timecode_frame()) + session.worst_output_latency();
double speed = compute_apparent_speed (now);
current.guard1++;
current.position = mtc_frame;
current.timestamp = now;
current.speed = speed;
current.guard2++;
DEBUG_TRACE (DEBUG::MTC, string_compose ("stored TC frame = %1 @ %2, sp = %3\n", mtc_frame, now, speed));
}
last_inbound_frame = now;
}
double
MTC_Slave::compute_apparent_speed (nframes64_t now)
{
if (current.timestamp != 0) { if (current.timestamp != 0) {
speed = (double) ((mtc_frame - current.position) / (double) (now - current.timestamp)); double speed = (double) ((mtc_frame - current.position) / (double) (now - current.timestamp));
DEBUG_TRACE (DEBUG::MTC, string_compose ("instantaneous speed = %1 from %2 - %3 / %4 - %5\n", DEBUG_TRACE (DEBUG::MTC, string_compose ("instantaneous speed = %1 from %2 - %3 / %4 - %5\n",
speed, mtc_frame, current.position, now, current.timestamp)); speed, mtc_frame, current.position, now, current.timestamp));
@ -181,20 +200,12 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
DEBUG_TRACE (DEBUG::MTC, string_compose ("speed smoothed to %1\n", speed)); DEBUG_TRACE (DEBUG::MTC, string_compose ("speed smoothed to %1\n", speed));
} }
return speed;
} else { } else {
speed = 0; return 0;
} }
current.guard1++;
current.position = mtc_frame;
current.timestamp = now;
current.speed = speed;
current.guard2++;
DEBUG_TRACE (DEBUG::MTC, string_compose ("stored TC frame = %1 @ %2, sp = %3\n", mtc_frame, now, speed));
}
last_inbound_frame = now;
} }
void void