\version "2.19.25" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% A function to add labels to analysis brackets. Allows for different text %% if broken between staves. %% %% Use with \tweak. For example: -\tweak #'stencil #(label "antecedent" "ant." "") %% This will add "antecedent" to the bracket if unbroken (or to the first piece, if %% broken), "ant." to the first broken piece, and an empty string to the next piece %% (if there is one). If no "" were specified, all pieces after the first would be %% labelled "ant." %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #(define (add-label grob text) ;; adapted from LSR snippet, "Center text below hairpin dynamics" (ly:stencil-aligned-to (ly:stencil-combine-at-edge (ly:stencil-aligned-to (ly:horizontal-bracket::print grob) X CENTER) Y (ly:grob-property grob 'direction) (ly:stencil-aligned-to (grob-interpret-markup grob (markup text)) X CENTER) 0.2) X LEFT)) #(define ((label . text) grob) (let* ((orig (ly:grob-original grob)) (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '()))) (define (helper text siblings) ;; step through the pieces to find the current one, and modify its stencil (if (eq? (car siblings) grob) (add-label grob (car text)) (if (or (null? (cdr siblings)) (null? (cdr text))) (add-label grob (car text)) ;; if not enough text for pieces, use last given (helper (cdr text) (cdr siblings))))) (if (pair? siblings) (helper text siblings) (add-label grob (car text))))) gluck = \relative c'' { \time 3/4 \key f \major \override HorizontalBracket.direction = #UP c4-\tweak stencil #(label "contrasting period" "contrasting period")\startGroup -\tweak stencil #(label "a" "a" )\startGroup a8( bes c f) f4( e d) c d8( c bes c) \appoggiatura bes4 a2 g4 \stopGroup f'8-\tweak stencil #(label "b" "b")\startGroup r a, r d r c4( e, f) g8( bes) a4 g8( f) f2 \stopGroup \stopGroup r4 \bar "||" } \score { \new Staff \gluck \layout { \context { \Voice \consists "Horizontal_bracket_engraver" } } }