temporal: slightly reduce overflow risk (see comment)
This commit is contained in:
@@ -502,8 +502,9 @@ TempoPoint::quarters_at_superclock (superclock_t sc) const
|
||||
const superclock_t whole_seconds = sc / superclock_ticks_per_second;
|
||||
const superclock_t remainder = sc - (whole_seconds * superclock_ticks_per_second);
|
||||
|
||||
const superclock_t supernotes = ((_super_note_type_per_second) * whole_seconds) + int_div_round (superclock_t ((_super_note_type_per_second) * remainder), superclock_ticks_per_second);
|
||||
const superclock_t superbeats = int_div_round (supernotes * 4, (superclock_t) _note_type);
|
||||
const int64_t supernotes = ((_super_note_type_per_second) * whole_seconds) + int_div_round (superclock_t ((_super_note_type_per_second) * remainder), superclock_ticks_per_second);
|
||||
/* multiply after divide to reduce overflow risk */
|
||||
const int64_t superbeats = int_div_round (supernotes, (superclock_t) _note_type) * 4;
|
||||
|
||||
/* convert superbeats to beats:ticks */
|
||||
int32_t b;
|
||||
|
||||
Reference in New Issue
Block a user