]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-indicators-to-staves-which-get-split-after-a-break.ly
Imported Upstream version 2.19.45
[lilypond.git] / Documentation / snippets / adding-indicators-to-staves-which-get-split-after-a-break.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.18.0"
8
9 \header {
10   lsrtags = "staff-notation, symbols-and-glyphs, vocal-music"
11
12   texidoc = "
13 This snippet defines the @code{\\splitStaffBarLine},
14 @code{convUpStaffBarLine} and @code{convDownStaffBarLine} commands.
15 These add arrows at a bar line, to denote that several voices sharing a
16 staff will each continue on a staff of their own in the next system, or
17 that voices split in this way recombine.
18
19 "
20   doctitle = "Adding indicators to staves which get split after a break"
21 } % begin verbatim
22
23 #(define-markup-command (arrow-at-angle layout props angle-deg length fill)
24    (number? number? boolean?)
25    (let* (
26            (PI-OVER-180 (/ (atan 1 1) 34))
27            (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
28            (angle-rad (degrees->radians angle-deg))
29            (target-x (* length (cos angle-rad)))
30            (target-y (* length (sin angle-rad))))
31      (interpret-markup layout props
32        (markup
33         #:translate (cons (/ target-x 2) (/ target-y 2))
34         #:rotate angle-deg
35         #:translate (cons (/ length -2) 0)
36         #:concat (#:draw-line (cons length 0)
37                    #:arrow-head X RIGHT fill)))))
38
39
40 splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
41   \combine
42   \arrow-at-angle #45 #(sqrt 8) ##t
43   \arrow-at-angle #-45 #(sqrt 8) ##t
44 }
45
46 splitStaffBarLine = {
47   \once \override Staff.BarLine.stencil =
48   #(lambda (grob)
49      (ly:stencil-combine-at-edge
50       (ly:bar-line::print grob)
51       X RIGHT
52       (grob-interpret-markup grob splitStaffBarLineMarkup)
53       0))
54   \break
55 }
56
57 convDownStaffBarLine = {
58   \once \override Staff.BarLine.stencil =
59   #(lambda (grob)
60      (ly:stencil-combine-at-edge
61       (ly:bar-line::print grob)
62       X RIGHT
63       (grob-interpret-markup grob #{
64         \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
65           \translate #'(0 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t
66         }#})
67       0))
68   \break
69 }
70
71 convUpStaffBarLine = {
72   \once \override Staff.BarLine.stencil =
73   #(lambda (grob)
74      (ly:stencil-combine-at-edge
75       (ly:bar-line::print grob)
76       X RIGHT
77       (grob-interpret-markup grob #{
78         \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
79           \translate #'(0 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
80         }#})
81       0))
82   \break
83 }
84
85
86 \paper {
87   ragged-right = ##t
88   short-indent = 10\mm
89 }
90
91 separateSopranos = {
92   \set Staff.instrumentName = "AI AII"
93   \set Staff.shortInstrumentName = "AI AII"
94   \splitStaffBarLine
95   \change Staff = "up"
96 }
97 convSopranos = {
98   \convDownStaffBarLine
99   \change Staff = "shared"
100   \set Staff.instrumentName = "S A"
101   \set Staff.shortInstrumentName = "S A"
102 }
103
104 sI = {
105   \voiceOne
106   \repeat unfold 4 f''2
107   \separateSopranos
108   \repeat unfold 4 g''2
109   \convSopranos
110   \repeat unfold 4 c''2
111 }
112 sII = {
113   s1*2
114   \voiceTwo
115   \change Staff = "up"
116   \repeat unfold 4 d''2
117 }
118 aI = {
119   \voiceTwo
120   \repeat unfold 4 a'2
121   \voiceOne
122   \repeat unfold 4 b'2
123   \convUpStaffBarLine
124   \voiceTwo
125   \repeat unfold 4 g'2
126 }
127 aII = {
128   s1*2
129   \voiceTwo
130   \repeat unfold 4 g'2
131 }
132 ten = {
133   \voiceOne
134   \repeat unfold 4 c'2
135   \repeat unfold 4 d'2
136   \repeat unfold 4 c'2
137 }
138 bas = {
139   \voiceTwo
140   \repeat unfold 4 f2
141   \repeat unfold 4 g2
142   \repeat unfold 4 c2
143 }
144
145 \score {
146   <<
147     \new ChoirStaff <<
148       \new Staff = up \with {
149         instrumentName = "SI SII"
150         shortInstrumentName = "SI SII"
151       } {
152         s1*4
153       }
154
155       \new Staff = shared \with {
156         instrumentName = "S A"
157         shortInstrumentName = "S A"
158       } <<
159         \new Voice = sopI \sI
160         \new Voice = sopII \sII
161         \new Voice = altI \aI
162         \new Voice = altII \aII
163       >>
164       \new Lyrics \with {
165         alignBelowContext = up
166       }
167       \lyricsto sopII { e f g h }
168       \new Lyrics \lyricsto altI { a b c d e f g h i j k l }
169
170       \new Staff = men \with {
171         instrumentName = "T B"
172         shortInstrumentName = "T B"
173       } <<
174         \clef F
175         \new Voice = ten \ten
176         \new Voice = bas \bas
177       >>
178       \new Lyrics \lyricsto bas { a b c d e f g h i j k l }
179     >>
180   >>
181   \layout {
182     \context {
183       \Staff \RemoveEmptyStaves
184       \override VerticalAxisGroup.remove-first = ##t
185     }
186   }
187 }