]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-indicators-to-staves-which-get-split-after-a-break.ly
528b3f3853911c3c053c4335f34319a68c29de74
[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.dsi.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.16.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 and degrees->radians are taken from flag-styles.scm
26           (PI-OVER-180 (/ (atan 1 1) 45))
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 splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
40   \combine
41     \arrow-at-angle #45 #(sqrt 8) ##f
42     \arrow-at-angle #-45 #(sqrt 8) ##f
43 }
44
45 splitStaffBarLine = {
46   \once \override Staff.BarLine #'stencil =
47     #(lambda (grob)
48        (ly:stencil-combine-at-edge
49         (ly:bar-line::print grob)
50         X RIGHT
51         (grob-interpret-markup grob splitStaffBarLineMarkup)
52         0))
53   \break
54 }
55
56 \paper {
57   ragged-right = ##t
58   short-indent = 5\mm
59 }
60
61 \score {
62   <<
63     \new ChoirStaff <<
64       \new Staff \with { instrumentName = #"High I + II" } {
65         <<
66           \repeat unfold 4 f''1
67           \\
68           \repeat unfold 4 d''1
69         >>
70         \splitStaffBarLine
71       }
72       \new Staff \with { instrumentName = #"Low" } {
73         <<
74           \repeat unfold 4 b'1
75           \\
76           \repeat unfold 4 g'1
77         >>
78       }
79
80       \new Staff \with { shortInstrumentName = #"H I" } {
81         R1*4
82         \repeat unfold 2 { r4 f''2 r4 } \repeat unfold 2 e''1
83       }
84       \new Staff \with { shortInstrumentName = #"H II" } {
85         R1*4
86         \repeat unfold 4 b'2 \repeat unfold 2 c''1
87       }
88       \new Staff \with { shortInstrumentName = #"L" } {
89         R1*4
90         <<
91           \repeat unfold 4 g'1
92           \\
93           \repeat unfold 4 c'1
94         >>
95       }
96     >>
97   >>
98   \layout {
99     \context {
100       \Staff \RemoveEmptyStaves
101       \override VerticalAxisGroup #'remove-first = ##t
102     }
103   }
104 }