I have to try it. So far, I've used the more manual solution available in https://lsr.di.unimi.it/LSR/Item?id=451
/Mats
On 2024-01-24 18:39, YTG 1234 wrote:
betterIncipit =
#(define-music-function (incipit-music) (ly:music?)
(_i "Output @var{incipit-music} as an incipit.
@var{incipit-music} is typeset within a @code{MensuralStaff} if no other staff-like context is created; the result
is positioned before the main staff (as part of an @code{InstrumentName} grob)
to indicate the music's original notation.")
#{
\once \override Staff.InstrumentName.stencil =
#(lambda (grob)
(let* ((instrument-name (ly:grob-property grob 'long-text))
(align-x (ly:grob-property grob 'self-alignment-X 0))
(align-y (ly:grob-property grob 'self-alignment-Y 0)))
(set! (ly:grob-property grob 'long-text)
#{ \markup {
\score
{
$(if (member (ly:music-property incipit-music 'context-type) '(ChoirStaff DrumStaff GrandStaff GregorianTranscriptionStaff KievanStaff MensuralStaff OneStaff PetrucciStaff PianoStaff RhythmicStaff Staff StaffGroup StandaloneRhythmStaff TabStaff VaticanaStaff))
#{ { $incipit-music } #}
#{ \new MensuralStaff { $incipit-music } #})
\layout {
$(ly:grob-layout grob)
\context {
\Staff
\override InstrumentName.self-alignment-X = #align-x
\override InstrumentName.self-alignment-Y = #align-y
instrumentName = #instrument-name
}
indent-incipit-default = 15\mm
line-width = #(primitive-eval
'(or (false-if-exception indent)
indent-incipit-default))
indent = #(primitive-eval
'(or (false-if-exception (- line-width incipit-width))
(* 0.5 line-width)))
ragged-right = ##f
ragged-last = ##f
system-count = 1
}
}
}
#})
(set! (ly:grob-property grob 'self-alignment-Y) #f)
;; Do 'self-alignment-X RIGHT only for the first InstrumentName, which
;; actually is the incipit. Otherwise self-alignment-X for the
;; shortInstrumentName is not longer settable.
(let ((parts (ly:spanner-broken-into (ly:grob-original grob))))
(if (and (pair? parts) (equal? grob (car parts)))
(ly:grob-set-property! grob 'self-alignment-X RIGHT)))
(system-start-text::print grob)))
#}
)