What I'm trying to achieve is to make single centered incipit bar for the staff group of two instruments. As for now, my code produces three incipits; I tried omitting particular Staff.InstrumentName but it also removes the shortInstrumentName, which is unwanted.
Here's my code:
\version "2.22.1"
incipit =
#(define-music-function (parser location incipit-music) (ly:music?)
#{
\once \override Staff.InstrumentName.self-alignment-X = #RIGHT
\once \override Staff.InstrumentName.self-alignment-Y = ##f
\once \override Staff.InstrumentName.padding = #1
\once \override Staff.InstrumentName.stencil =
#(lambda (grob)
(let* ((instrument-name (ly:grob-property grob 'long-text)))
(set! (ly:grob-property grob 'long-text)
#{ \markup
\score
{
{ \context Staff \with {
} $incipit-music
}
\layout { $(ly:grob-layout grob)
line-width = \indent
indent =
#(primitive-eval
'(or (false-if-exception (- indent incipit-width))
(* 0.5 indent)))
ragged-right = ##f
ragged-last = ##f
system-count = #1
}
}
#})
(system-start-text::print grob)))
#})
IandII.Incipit = <<
\new Voice = "IandII.Incipit" <<
{
\set Staff.instrumentName = #"I and II"
\clef G
\time 4/4
<g' c''>1 \bar ""
}
>>
>>
scoreI = \relative c'' {
c1 \break c
}
scoreII = \relative c'' {
g1 \break g
}
scoreIPart = \new Staff \with {
%\omit Staff.InstrumentName
shortInstrumentName = "I"
} \scoreI
scoreIIPart = \new Staff \with {
%\omit Staff.InstrumentName
shortInstrumentName = "II"
} \scoreII
\score {
\new StaffGroup \with {
instrumentName = ""
\incipit \IandII.Incipit
}
{ <<
\scoreIPart
\scoreIIPart
>> }
\layout {
indent = 6\cm
incipit-width = 3\cm
}
}
Could you give me a hint how to get it right? Any help would be greatly appreciated!
Best,
Marcin