Am Sonntag, 21. Juli 2024, 08:12:07 MESZ schrieb Fennel:
> Valentino,
> 
> Your function seems to not work for polyphonic passages as in the example
> below. Is there a fix for the function, would using \voiceOne and \voiceTwo
> explicitly for this polyphonic context make a difference?
> 

Hello Fennel,

the issue here is that Horizontal Brackets require NoteHeads, and in your case 
there are none (the Brackets would not be printed in any case). If you want to 
use them in this case, add the engraver to the Staff context instead. But then 
also your polyphonic structure is a mess (your group definition is outside of 
the << ... >>, so it comes only after the notes). Finally there is some issue 
with order, so I‘ve adjusted the engraver slightly:

\version "2.24.3"
#(define (outside-staff-collecting-engraver context)
   (let* ((span_up #f) (span_down #f) (elts '()))
   (make-engraver
    ((initialize engraver)
     (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '()))
     (ly:grob-set-property! span_up 'transparent #t)
     (ly:grob-set-property! span_up 'direction UP)
     (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '()))
     (ly:grob-set-property! span_down 'transparent #t)
     (ly:grob-set-property! span_down 'direction DOWN))
    (acknowledgers
     ((outside-staff-interface engraver grob source-engraver)
      (set! elts (cons grob elts))))
    ((process-acknowledged engraver)
     (for-each
      (lambda (grob)
        (if (assoc-get 'align (ly:grob-property grob 'details))
            (let* ((d (ly:grob-property grob 'direction))
                   (span (if (= d UP) span_up span_down)))
              (display grob)
              (display (ly:spanner-bound grob LEFT))
              (ly:grob-set-parent! grob Y span)
              (if (null? (ly:spanner-bound span LEFT))
                  (ly:spanner-set-bound! span LEFT
                                         (if (ly:spanner? grob)
                                             (ly:spanner-bound grob LEFT)
                                             grob)))
              (ly:spanner-set-bound! span RIGHT
                                     (if (ly:spanner? grob)
                                         (ly:spanner-bound grob LEFT)
                                         grob))
              (ly:grob-set-property! grob 'outside-staff-priority #f)
              (ly:grob-set-property! grob 'Y-offset 0))))
      elts)
     (set! elts '())))))

\layout {
  \context {
    \Staff
    \consists #outside-staff-collecting-engraver
    \consists Horizontal_bracket_engraver
    \override HorizontalBracket.direction = #UP
  }
  \context {
    \Voice
    \remove Horizontal_bracket_engraver
  }
}

\relative c {
\override Staff.HorizontalBracket.details.align = ##t
  <<
    <<
      { c\startTextSpan c c c\stopTextSpan | }
      \\
      { g g g g | }
      \\
      { a a a a }
    >>
    { s\startGroup s s s\stopGroup }
  >>
}

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

Reply via email to