Hello Werner,

while it is probably not the best way to do it, here is a pragmatical solution 
to the problem.

Cheers,
Valentin

Am Samstag, 21. Mai 2022, 13:38:24 CEST schrieb Werner LEMBERG:
> Let's assume that I have 40 bars of flute 1 and 2 in a single staff of
> a full score.  At the very beginning of these bars I write "a 2", and
> I want this remark repeated at the beginning of every staff where this
> is still true.  [Obviously I'm not using `\partCombine` :-)]
> 
> Has anyone already set up such a thing?  I looked into the LSR but
> could find something related.  It seems to me that a text spanner
> could do it, but it shouldn't interact with any other (text) spanners.
> 
> 
>     Werner

#(set-object-property! 'staffAnnotation 'translation-type? markup?)
#(set-object-property! 'staffAnnotationBreakVisibility 'translation-type? vector?)

#(define (staff-annotation-engraver context)
   (let* ((last-annot '()))
    (make-engraver
     (acknowledgers
      ((bar-line-interface engraver grob source-engraver)
       (let* ((annot (ly:context-property context 'staffAnnotation))
              (break-visibility (ly:context-property context 'staffAnnotationBreakVisibility begin-of-line-visible)))
         (if (markup? annot)
             (let ((grob (ly:engraver-make-grob engraver 'RehearsalMark '())))
               (ly:grob-set-property! grob 'break-visibility break-visibility)
               (ly:grob-set-property! grob 'text annot)
               (ly:grob-set-property! grob 'self-alignment-X LEFT))))))
     ((process-music engraver)
      (let* ((annot (ly:context-property context 'staffAnnotation)))
        (if (and (markup? annot) (not (equal? annot last-annot)))
            (let ((grob (ly:engraver-make-grob engraver 'RehearsalMark '()))
                  (br-grob (ly:engraver-make-grob engraver 'RehearsalMark '())))
              (ly:grob-set-property! grob 'break-visibility center-visible)
              (ly:grob-set-property! grob 'text annot)
              (ly:grob-set-property! grob 'self-alignment-X LEFT)
              (ly:grob-set-property! grob 'non-musical (equal? (ly:context-property context 'measurePosition) (ly:make-moment 0)))
              (ly:grob-set-property! br-grob 'break-visibility end-of-line-visible)
              (ly:grob-set-property! br-grob 'text (markup #:concat ("(" annot ")")))
              (ly:grob-set-property! br-grob 'self-alignment-X RIGHT)))
        (set! last-annot annot))))))

\layout {
  \context {
    \Staff
    \consists #staff-annotation-engraver
  }
}

{
  c'1
  \set Staff.staffAnnotation = "a 2" 1 \break 1 1 1 \break 1 1
  \set Staff.staffAnnotation = "a 3" 1 \break 1
  \set Staff.staffAnnotation = "a 4" \break 1 2
  \set Staff.staffAnnotation = "a 42" 2 1 
  \unset Staff.staffAnnotation \break 1
}

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to