Le 01/06/2022 à 17:04, Simon Bailey a écrit :
A bit more work and I now have the following:\version "2.23.9" #(set-object-property! 'phrase-length 'backend-type? integer?) #(define (counter-stencil grob) (let* ((counter (string->number (ly:grob-property grob 'text))) (phrase-length (ly:grob-property grob 'phrase-length))) (if (and (eq? (modulo counter phrase-length) 1) (>= counter phrase-length)) (ly:stencil-aligned-to (grob-interpret-markup grob (markup (number->string (ceiling (/ counter phrase-length))))) Y CENTER)))) \defineBarLine "!|" #'("!|" "" "!|") repeatCounting = #(define-music-function (n bar-length phrase-length music) (index? ly:music? integer? ly:music?) #{ << \repeat unfold #n { #music \bar "!|" } { \set countPercentRepeats = ##t \hide PercentRepeat \override PercentRepeatCounter.phrase-length = #phrase-length \override PercentRepeatCounter.stencil = #counter-stencil \repeat percent #(* phrase-length n) { #bar-length } } >> #}) \new Staff \relative c' { \repeatCounting 4 s1 2 {c4 d e f | g f e d } \break c1 \time 7/4 \repeatCounting 4 s4*7 3 {c4 d e f r r r | g f e d r r r| c1 r2 r4 } } How can I find out the following two bits of information? 1. What is the duration of a measure dependent on the current time signature?
In an engraver :-) (ly:context-property context 'measureLength) You can't get it in the music function, since timing is not established at that point (just think that the time signature could come from another element of a << >> construct, for example). Remember, though, that the time signature might change in the middle of the repeat. Thus it will be a bit more reliable to actually acknowledge the PercentRepeatCount grobs and increment a counter whenever you see one.
2. How long is a given musical expression (in measures or beats)?
(ly:music-length your-music) Best, Jean
