Hi, Thank you so much, it works superb! And also thanks a million for your adjustments of my code - it looks just terrific.
Best, Marcin wt., 28 wrz 2021 o 00:10 Thomas Morley <thomasmorle...@gmail.com> napisaĆ(a): > Am Sa., 25. Sept. 2021 um 17:39 Uhr schrieb Marcin Damianiak > <theem...@gmail.com>: > > > > Dear All, > > > > I'd like to ask for a little bit of help with the following matter: > > > > 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 > > The override for InstrumentName.stencil applied at StaffGroup-level > will work on all child-Staffs as well. > > Iiuc, you don't want InstrumentName.long-text for those children, as a > workaround you could simply omit the stencil of the first grob of the > broken InstrumentName. > How about below (with several other adjustments of your code-example)? > > > \version "2.22.1" > > %% from property-init.ly, > %% slightly modified (making the printed context-type optional) > incipit = > #(define-music-function (context-type incipit-music) > ((string? "MensuralStaff") ly:music?) > (_i "Output @var{incipit-music} before the main staff as an indication of > its appearance in the original music. Optional @var{context-type} > determines > the type of it, defaulting to MensuralStaff.") > #{ > \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 > { > \new $context-type \with { > \override InstrumentName.self-alignment-X = #align-x > \override InstrumentName.self-alignment-Y = #align-y > instrumentName = #instrument-name > } > { > $incipit-music > } > \layout { > $(ly:grob-layout grob) > 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 > \context { > \Score > \remove "Default_bar_line_engraver" > } > } > } > } > #}) > (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))) > #}) > > #(define omit-first-spanner-stencil > (lambda (grob) > "Omit first (of possibly broken) spanner-stencil(s)." > (if (not (ly:spanner? grob)) > (ly:error "Grob ~a is not a spanner" grob) > (let* ((orig (ly:grob-original grob)) > (siblings (ly:spanner-broken-into orig)) > ;; search properties in reverse order, to avoid catching > this > ;; procedure > (stil-proc > (assoc-get > 'stencil > (reverse (ly:grob-basic-properties grob))))) > (if (and (pair? siblings) (equal? grob (car siblings))) > #f > (if (procedure? stil-proc) > (stil-proc grob) > stil-proc)))))) > > omitFirstInstrumentName = > \override InstrumentName.stencil = #omit-first-spanner-stencil > > %%%%%%%%%%%%%%%%%%%%%%%% > %% EXAMPLE > %%%%%%%%%%%%%%%%%%%%%%%% > > IandII.Incipit = { <g' c''>1 } > > musI = \relative c'' { c1 \break c } > > musII = \relative c'' { g1 \break g } > > staffI = > \new Staff > \with { > \omitFirstInstrumentName > instrumentName = "I" > shortInstrumentName = "I" > } > \musI > > staffII = > \new Staff > \with { > \omitFirstInstrumentName > instrumentName = "II" > shortInstrumentName = "II" > } > \musII > > \score { > \new StaffGroup > \with { > instrumentName = "I and II" > \incipit "Staff" \IandII.Incipit > } > << > \staffI > \staffII > >> > > \layout { > indent = 5\cm > incipit-width = 3\cm > } > } > > HTH, > Harm >