/* no clock messages ever, or no clock messages for 1/4 second ? conclude that its stopped */
- if (!last_timestamp || (now > last_timestamp && ((now - last_timestamp) > (ENGINE->sample_rate() / 4)))) {
- current.update (current.position, 0, 0);
+ if (!current.timestamp || (now > current.timestamp && ((now - current.timestamp) > (ENGINE->sample_rate() / 4)))) {
_bpm = 0.0;
_running = false;
_current_delta = 0;
return;
}
- if (!_running && midi_clock_count == 0 && session_pos) {
- current.update (*session_pos, now, current.speed);
- DEBUG_TRACE (DEBUG::MidiClock, string_compose ("set sbp to %1\n", current.position));
- }
-
if (session_pos) {
const samplepos_t current_pos = current.position + ((now - current.timestamp) * current.speed);
_current_delta = current_pos - *session_pos;
* (quarters per minute, and fully initialize the DLL
*/
- e = timestamp - last_timestamp;
+ e = timestamp - current.timestamp;
const samplecnt_t samples_per_quarter = e * 24;
_bpm = (ENGINE->sample_rate() * 60.0) / samples_per_quarter;
t1 += b * e + e2;
e2 += c * e;
- const double samples_per_quarter = (timestamp - last_timestamp) * 24.0;
+ const double samples_per_quarter = (timestamp - current.timestamp) * 24.0;
const double instantaneous_bpm = (ENGINE->sample_rate() * 60.0) / samples_per_quarter;
const double lpf_coeff = 0.05;
_session->transport_sample(), // transport
e, // error
(t1 - t0) / one_ppqn_in_samples, // appspeed
- timestamp - last_timestamp, // read delta
+ timestamp - current.timestamp, // read delta
one_ppqn_in_samples, // should-be delta
(t1 - t0), // t1-t0
t0, // t0
_running
));
-
- last_timestamp = timestamp;
}
void
if (_running) {
_running = false;
- _speed = 0;
- last_timestamp = 0;
// we need to go back to the last MIDI beat (6 ppqn)
// and lets hope the tempo didnt change in the meantime :)
//
// find out the last MIDI beat: go back #midi_clocks mod 6
// and lets hope the tempo didnt change in those last 6 beats :)
- current.update (current.position - (midi_clock_count % 6) * one_ppqn_in_samples, timestamp, current.speed);
+ current.update (current.position - (midi_clock_count % 6) * one_ppqn_in_samples, 0, 0);
}
}
MIDIClock_TransportMaster::delta_string() const
{
char delta[80];
- if (last_timestamp == 0 || starting()) {
+ SafeTime last;
+ current.safe_read (last);
+
+ 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",