]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-indicators-to-staves-which-get-split-after-a-break.ly
Merge remote-tracking branch 'origin/master' into translation
[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} command, which adds
14 arrows in north-east and south-east directions at a bar line, to denote
15 that several voices sharing a staff will each continue on a staff of
16 their own in the next system.
17
18 "
19   doctitle = "Adding indicators to staves which get split after a break"
20 } % begin verbatim
21
22 #(define-markup-command (arrow-at-angle layout props angle-deg length fill)
23   (number? number? boolean?)
24   (let* (
25       (PI-OVER-180 (/ (atan 1 1) 34))
26       (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
27       (angle-rad (degrees->radians angle-deg))
28       (target-x (* length (cos angle-rad)))
29       (target-y (* length (sin angle-rad))))
30     (interpret-markup layout props
31       (markup
32       #:translate (cons (/ target-x 2) (/ target-y 2))
33       #:rotate angle-deg
34       #:translate (cons (/ length -2) 0)
35       #:concat (#:draw-line (cons length 0)
36       #:arrow-head X RIGHT fill)))))
37
38 splitStaffBarLine = {
39   \once \override Staff.BarLine.stencil =
40   #(lambda (grob)
41     (ly:stencil-combine-at-edge
42     (ly:bar-line::print grob)
43     X RIGHT
44     (grob-interpret-markup grob #{
45       \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
46         \translate #'(5.95 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
47         \translate #'(5.35 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t }#})
48     0))
49   \break
50 }
51
52 convDownStaffBarLine = {
53   \once \override Staff.BarLine.stencil =
54   #(lambda (grob)
55     (ly:stencil-combine-at-edge
56     (ly:bar-line::print grob)
57     X RIGHT
58     (grob-interpret-markup grob #{
59         \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
60           \translate #'(5.3 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t }#})
61       0))
62   \break
63 }
64
65 convUpStaffBarLine = {
66   \once \override Staff.BarLine.stencil =
67   #(lambda (grob)
68     (ly:stencil-combine-at-edge
69     (ly:bar-line::print grob)
70     X RIGHT
71     (grob-interpret-markup grob #{
72         \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
73           \translate #'(5.28 . .14)\arrow-at-angle #45 #(sqrt 8) ##t }#})
74       0))
75   \break
76 }
77
78
79 \score {
80   <<
81     \new ChoirStaff <<
82       \new Staff
83       \with {
84         instrumentName = #"H I + H II"
85       } {
86         \key f\minor
87         <<
88           \repeat unfold 4 f''1
89           \\
90           \repeat unfold 4 des''1
91         >>
92         \key f\major
93         \splitStaffBarLine
94       }
95       \new Staff \with { instrumentName = #"Low" } {
96         \key f\minor
97         <<
98           \repeat unfold 4 bes'1
99           \\
100           \repeat unfold 4 g'1
101         >>
102         \key f\major
103       }
104
105       \new Staff \with { shortInstrumentName = #"I" } {
106         \key f \major
107         R1*4
108         \repeat unfold 2 { r4 f''2 r4 } \repeat unfold 2 e''1
109         \key f\minor
110         \convDownStaffBarLine
111       }
112       \new Staff \with { shortInstrumentName = #"II" } {
113         \key f \major
114         R1*4
115         \repeat unfold 4 bes'2 \repeat unfold 2 c''1
116         \key f\minor
117         \convUpStaffBarLine
118       }
119
120       \new Staff \with { shortInstrumentName = #"L" } {
121         \key f\major
122         R1*4
123         <<
124           \repeat unfold 4 g'1
125           \\
126           \repeat unfold 4 c'1
127         >>
128         \key f\minor
129       }
130
131       \new Staff
132       \with {
133         shortInstrumentName = #"I+II"
134       } {
135         \key f\minor
136         R1*8
137         <<
138           \repeat unfold 4 f''1
139           \\
140           \repeat unfold 4 des''1
141         >>
142       }
143       \new Staff \with { shortInstrumentName = #"L" } {
144         \key f\minor
145         R1*8
146         <<
147           \repeat unfold 4 bes'1
148           \\
149           \repeat unfold 4 g'1
150         >>
151       }
152     >>
153   >>
154   \layout {
155     \context {
156       \Staff \RemoveEmptyStaves
157       \override VerticalAxisGroup #'remove-first = ##t
158     }
159   }
160 }
161 \paper {
162   ragged-right = ##t
163 }