MIDIClock_Slave::MIDIClock_Slave (Session& s, MIDI::Port& p, int ppqn)
: ppqn (ppqn)
- , bandwidth (1.0 / 60.0) // 1 BpM = 1 / 60 Hz
+ , bandwidth (10.0 / 60.0) // 1 BpM = 1 / 60 Hz
{
session = (ISlaveSessionProxy *) new SlaveSessionProxy(s);
rebind (p);
MIDIClock_Slave::MIDIClock_Slave (ISlaveSessionProxy* session_proxy, int ppqn)
: session(session_proxy)
, ppqn (ppqn)
- , bandwidth (1.0 / 60.0) // 1 BpM = 1 / 60 Hz
+ , bandwidth (10.0 / 60.0) // 1 BpM = 1 / 60 Hz
{
reset ();
}
calculate_filter_coefficients();
// calculate loop error
- // we use session->audible_frame() instead of t1 here
+ // we use session->transport_frame() instead of t1 here
// because t1 is used to calculate the transport speed,
// so the loop will compensate for accumulating rounding errors
- error = (double(should_be_position) - double(session->audible_frame()));
+ error = (double(should_be_position) - double(session->transport_frame()));
e = error / double(session->frame_rate());
+ current_delta = error;
// update DLL
t0 = t1;
// calculate speed
speed = ((t1 - t0) * session->frame_rate()) / one_ppqn_in_frames;
- // provide a 3% deadzone to lock the speed
- if (fabs(speed - 1.0) <= 0.03)
+ // provide a 0.1% deadzone to lock the speed
+ if (fabs(speed - 1.0) <= 0.001)
speed = 1.0;
// calculate position
}
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("speed_and_position: %1 & %2 <-> %3 (transport)\n", speed, pos, session->transport_frame()));
- current_delta = pos - session->transport_frame();
return true;
}
if (last_timestamp == 0 || _starting) {
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
} else {
- snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%s%" PRIi64 "</span> sm",
+ snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%s%" PRIi64 "</span>sm",
LEADINGZERO(abs(current_delta)), PLUSMINUS(-current_delta), abs(current_delta));
}
return std::string(delta);