\version "2.25.20" %% SNIPPET %% %%Adding indicators to staves which get split after a break %%This snippet defines the: %\splitStaffBarLine, convUpStaffBarLine and convDownStaffBarLine commands. %These add arrows at a bar line, to denote that several voices sharing a staff will each continue on a staff of their own in the next system, or that voices split in this way recombine. #(define-markup-command (arrow-at-angle layout props angle-deg length fill) (number? number? boolean?) (let* ( (PI-OVER-180 (/ (atan 1 1) 34)) (degrees->radians (lambda (degrees) (* degrees PI-OVER-180))) (angle-rad (degrees->radians angle-deg)) (target-x (* length (cos angle-rad))) (target-y (* length (sin angle-rad)))) (interpret-markup layout props (markup #:translate (cons (/ target-x 2) (/ target-y 2)) #:rotate angle-deg #:translate (cons (/ length -2) 0) #:concat (#:draw-line (cons length 0) #:arrow-head X RIGHT fill))))) splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) { \combine \arrow-at-angle #45 #(sqrt 8) ##t \arrow-at-angle #-45 #(sqrt 8) ##t } splitStaffBarLine = { \once \override Staff.BarLine.stencil = #(lambda (grob) (ly:stencil-combine-at-edge (ly:bar-line::print grob) X RIGHT (grob-interpret-markup grob splitStaffBarLineMarkup) 0)) %\break } convDownStaffBarLine = { \once \override Staff.BarLine.stencil = #(lambda (grob) (ly:stencil-combine-at-edge (ly:bar-line::print grob) X RIGHT (grob-interpret-markup grob #{ \markup\with-dimensions #'(0 . 0) #'(0 . 0) { \translate #'(0 . -.13)\arrow-at-angle #-30 #(sqrt 30) ##t }#}) 0)) %\break } convUpStaffBarLine = { \once \override Staff.BarLine.stencil = #(lambda (grob) (ly:stencil-combine-at-edge (ly:bar-line::print grob) X RIGHT (grob-interpret-markup grob #{ \markup\with-dimensions #'(0 . 0) #'(0 . 0) { \translate #'(0 . -3.70)\arrow-at-angle #30 #(sqrt 30) ##t }#}) 0)) %\break } %% switch = { \new Staff = "switch" \with { \RemoveAllEmptyStaves } { % switch staff code c''1 d'' e'' f'' \stopStaff \splitStaffBarLine s1 \override Staff.StaffSymbol.line-positions = #'(-11 -9 -7 -5 -3) \set Staff.clefPosition = -9 \set Staff.middleCPosition = -13 \startStaff << %% First let's create the lower staff (bass clef). \override Score.BreakAlignment.break-align-orders = #(make-vector 3 '( staff-bar clef )) \clef bass \set Staff.clefPosition = -5 \set Staff.middleCPosition = -1 \set Staff.middleCClefPosition = -1 { \repeat unfold 2 {c1 d e f} \break % breaking the line just to test the converging together. \once \override Staff.Clef.X-extent = #'(-1 . 0) %{ Had to use this Clef.-X because the clef was going inside the initial left wall of the bar.%} c1 d e f \stopStaff \convUpStaffBarLine s1} %% Now to create the second staff (in this case, upper staff). {\new Staff \with { \remove Time_signature_engraver alignAboveContext = "switch" \magnifyStaff #1 \override VerticalAxisGroup.default-staff-staff-spacing = #'((basic-distance . 3) (minimum-distance . 4) (padding . 0) (stretchability . 10)) %{firstClef = ##f%} } { % higher staff code \override Score.BreakAlignment.break-align-orders = #(make-vector 3 '( staff-bar clef )) \clef treble \set Staff.clefPosition = -1 \set Staff.middleCPosition = 1 \set Staff.middleCClefPosition = 1 { \repeat unfold 3 {c1 d e f} \stopStaff \convDownStaffBarLine s1} }} % end higher staff code & variable >> \revert Score.BreakAlignment.break-align-orders \revert Staff.StaffSymbol.line-positions \startStaff \clef treble \relative c'' {\time 5/8 {\repeat unfold 4 {c8 b a g a}}} \once \override Score.TimeSignature.break-visibility = #'#(#f #t #t) } % end Switch Staff } % end Switch variable MelodyInUnison = { \new Staff \with { \RemoveAllEmptyStaves } { % MelodyInUnison staff code \relative c'' {{\repeat unfold 2 {c1 d e f}}} } % end of MelodyInUnison Staff } % end of MelodyInUnison variable music = { \MelodyInUnison \break \switch \revert Score.BreakAlignment.break-align-orders \revert Staff.StaffSymbol.line-positions \break \time 4/4 \MelodyInUnison } % end music variable \score { \music }