mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-22 14:46:34 +01:00
continue with MTC debugging
git-svn-id: svn://localhost/ardour2/branches/3.0@6235 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
929f9a101a
commit
1614402e50
2 changed files with 42 additions and 30 deletions
|
|
@ -245,6 +245,7 @@ class MTC_Slave : public Slave, public sigc::trackable {
|
|||
void update_mtc_time (const MIDI::byte *, bool);
|
||||
void update_mtc_status (MIDI::Parser::MTC_Status);
|
||||
void read_current (SafeTime *) const;
|
||||
double compute_apparent_speed (nframes64_t);
|
||||
};
|
||||
|
||||
class MIDIClock_Slave : public Slave, public sigc::trackable {
|
||||
|
|
|
|||
|
|
@ -77,10 +77,13 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/)
|
|||
|
||||
qtr = (long) (session.frames_per_timecode_frame() / 4);
|
||||
mtc_frame += qtr;
|
||||
|
||||
double speed = compute_apparent_speed (now);
|
||||
|
||||
current.guard1++;
|
||||
current.position = mtc_frame;
|
||||
current.timestamp = now;
|
||||
current.speed = speed;
|
||||
current.guard2++;
|
||||
|
||||
last_inbound_frame = now;
|
||||
|
|
@ -146,7 +149,6 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
|
|||
|
||||
} else {
|
||||
|
||||
double speed;
|
||||
|
||||
/* We received the last quarter frame 7 quarter frames (1.75 mtc
|
||||
frames) after the instance when the contents of the mtc quarter
|
||||
|
|
@ -156,47 +158,56 @@ 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();
|
||||
|
||||
if (current.timestamp != 0) {
|
||||
|
||||
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",
|
||||
speed, mtc_frame, current.position, now, current.timestamp));
|
||||
|
||||
accumulator[accumulator_index++] = speed;
|
||||
|
||||
if (accumulator_index >= accumulator_size) {
|
||||
have_first_accumulated_speed = true;
|
||||
accumulator_index = 0;
|
||||
}
|
||||
|
||||
if (have_first_accumulated_speed) {
|
||||
double total = 0;
|
||||
|
||||
for (int32_t i = 0; i < accumulator_size; ++i) {
|
||||
total += accumulator[i];
|
||||
}
|
||||
|
||||
speed = total / accumulator_size;
|
||||
DEBUG_TRACE (DEBUG::MTC, string_compose ("speed smoothed to %1\n", speed));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
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",
|
||||
speed, mtc_frame, current.position, now, current.timestamp));
|
||||
|
||||
accumulator[accumulator_index++] = speed;
|
||||
|
||||
if (accumulator_index >= accumulator_size) {
|
||||
have_first_accumulated_speed = true;
|
||||
accumulator_index = 0;
|
||||
}
|
||||
|
||||
if (have_first_accumulated_speed) {
|
||||
double total = 0;
|
||||
|
||||
for (int32_t i = 0; i < accumulator_size; ++i) {
|
||||
total += accumulator[i];
|
||||
}
|
||||
|
||||
speed = total / accumulator_size;
|
||||
DEBUG_TRACE (DEBUG::MTC, string_compose ("speed smoothed to %1\n", speed));
|
||||
}
|
||||
|
||||
return speed;
|
||||
|
||||
} else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MTC_Slave::handle_locate (const MIDI::byte* mmc_tc)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue