
How long should a unit of time be?
==================================

MIDI's tempo-independent unit, the clock, is "1/24th of a quarter
note", i.e. 1/3 of a demisemiquaver.  Rosegarden 2.1 uses a unit of
one hemidemisemiquaver; this is not evenly expressible in MIDI clocks.
Rosegarden 2.1 can also handle dotted hemidemis in some contexts.

We probably need no better than hemidemi resolution (modulo tuplet
grouping); but we want to be able to represent MIDI clocks and
Rosegarden 2.1 hemidemis and dotted hemidemis without loss, so we will
need an effective resolution down to 1/6 hemidemisemiquaver.

Let's settle on that, then:

           1 unit  = 1/4 clock
           4 units =   1 clock
           6 units = 3/2 clocks = 1 hemidemisemiquaver
          12 units =   3 clocks = 1 demisemiquaver
          24 units =   6 clocks = 1 semiquaver
          48 units =  12 clocks = 1 quaver
          96 units =  24 clocks = 1 crotchet
         192 units =  48 clocks = 1 minim
         384 units =  96 clocks = 1 semibreve
         768 units = 192 clocks = 1 breve

and the longest note, a dotted breve, is 1152 units long.

Assuming a 32-bit signed long, a Time object is therefore good for
durations just shy of 2^26 / 3 crotchets, or nearly 5.6 million bars
in 4/4 time.  I think.

The delta-times in MIDI files are represented in terms of the
timebase, defined in the MIDI file-format standard as the number of
delta-time units per crotchet.  So to convert from MIDI file deltas to
our time units, multiply by 96 and divide by the timebase.

Obviously, helper functions should be provided to do these conversions.


_Chris Cannam_
