On Fri, Jan 28, 2022 at 01:35:23PM +0100, David Kastrup wrote:
I cannot speak in general terms, but you need to keep
several sources
with different note lengths in sync. LilyPond, a music typesetter, does
this by using exact rational numbers. Exponential speedups/slowdowns
are pretty bad at managing the mapping of a rational note length grid to
a rational timeline, with nominators and denominators of manageable
size. So one needs to be somewhat careful about the formulas to employ.
I rational arithmetic is used to avoid accumulating small errors (that is
the normal use case) I don't see the need for it in this context.
Tempo ramps happen between begin and end points and as long as these
are accurate, there will be no accumlating error.
For example you could express time as integer microseconds and beats
as k / N with N something like 2^8 * 3^4 * 5 * 7 which allows all
common divisions of a beat to be exact with integer k [1].
The calculations that map time to beats or beats to time _within_
a tempo ramp can be safely done using floating point (as an offset
from the start point) and the results rounded to the rational format.
[1] And if ever you have to divide a beat by a number that doesn't
divide N, there is always the Bresenhan algorithm.
Ciao,
--
FA