Hi Jason, Sorry that I haven't been able to follow your project as closely as I wanted to. Your progress sounds great!
> Does anyone know how the process of parsing tuplet fractions goes? At
> what location in the codebase does the original tuplet numerator and
> denominator become a Moment? Where the TupletNumber.text function is
> invoked to store in Scheme? Once I understand, then the rest of the
> journey shouldn't be too hard for me.
\tuplet is defined like this in ly/music-functions-init.ly:
tuplet =
#(define-music-function (ratio tuplet-span music)
(fraction? (ly:duration? '()) ly:music?)
[...]
(make-music 'TimeScaledMusic
'element (ly:music-compress
music
(ly:make-moment (cdr ratio) (car ratio)))
'numerator (cdr ratio)
'denominator (car ratio)
'duration tuplet-span))
so it stores the numerator and the denominator as two properties
of the TimeScaledMusic object. The latter is iterated by
lily/tuplet-iterator.cc,
which emits a TupletSpanEvent first, then iterates the inner
music, and emits another TupletSpanEvent at the end. There
is this code:
if (d == START)
{
set_property (ev, "numerator", get_property (mus, "numerator"));
set_property (ev, "denominator", get_property (mus, "denominator"));
set_property (ev, "tweaks", get_property (mus, "tweaks"));
set_property (ev, "length", spanner_duration_.smobbed_copy ());
}
which makes the first event contain "numerator" and "denominator"
functions copied from the TimeScaledMusic.
The event is also where TupletNumber reads its text, via
tuplet-number::calc-denominator-text in scm/output-lib.scm
(which is defined as the default callback for the TupletNumber.text
property in scm/define-grobs.scm):
(define-public (tuplet-number::calc-denominator-text grob)
(number->string (ly:event-property (event-cause grob) 'denominator)))
Bottom line: if you have the first TupletSpanEvent somewhere, you should
be able to read the numerator and denominator as
from_scm<int> (get_property (event, "numerator"))
from_scm<int> (get_property (event, "denominator"))
Best,
Jean
signature.asc
Description: This is a digitally signed message part
