1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Deals with potential precision pitfall.

This commit is contained in:
Thomas Harte 2018-05-02 21:26:39 -04:00
parent 4b4ea4a103
commit 3787d094ec

View File

@ -205,9 +205,14 @@ void Drive::setup_track() {
assert(track_time_now >= Time(0) && current_event_.length <= Time(1));
Time time_found = track_->seek_to(track_time_now);
assert(time_found >= Time(0) && time_found < Time(1) && time_found <= track_time_now);
offset = track_time_now - time_found;
// time_found can be greater than track_time_now if limited precision caused rounding
if(time_found <= track_time_now) {
offset = track_time_now - time_found;
} else {
offset.set_zero();
}
get_next_event(offset);
}