]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/adding-indicators-to-staves-which-get-split-after-a-break.ly
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / Documentation / snippets / adding-indicators-to-staves-which-get-split-after-a-break.ly
1 %% Do not edit this file; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% This file is in the public domain.
4 \version "2.13.10"
5
6 \header {
7   lsrtags = "staff-notation, vocal-music"
8
9   texidoc = "
10 This snippet defines the @code{\\splitStaffBarLine} command, which adds
11 arrows in north-east and south-east directions at a bar line, to denote
12 that several voices sharing a staff will each continue on a staff of
13 their own in the next system.
14
15 "
16   doctitle = "Adding indicators to staves which get split after a break"
17 } % begin verbatim
18
19 #(define-markup-command (arrow-at-angle layout props angle-deg length fill)
20    (number? number? boolean?)
21    (let* (
22           ;; PI-OVER-180 and degrees->radians are taken from flag-styles.scm
23           (PI-OVER-180 (/ (atan 1 1) 45))
24           (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
25           (angle-rad (degrees->radians angle-deg))
26           (target-x (* length (cos angle-rad)))
27           (target-y (* length (sin angle-rad))))
28      (interpret-markup layout props
29                        (markup
30                         #:translate (cons (/ target-x 2) (/ target-y 2))
31                         #:rotate angle-deg
32                         #:translate (cons (/ length -2) 0)
33                         #:concat (#:draw-line (cons length 0)
34                                               #:arrow-head X RIGHT fill)))))
35
36 splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
37   \combine
38     \arrow-at-angle #45 #(sqrt 8) ##f
39     \arrow-at-angle #-45 #(sqrt 8) ##f
40 }
41
42 splitStaffBarLine = {
43   \once \override Staff.BarLine #'stencil =
44     #(lambda (grob)
45        (ly:stencil-combine-at-edge
46         (ly:bar-line::print grob)
47         X RIGHT
48         (grob-interpret-markup grob splitStaffBarLineMarkup)
49         0 0))
50   \break
51 }
52
53 \paper {
54   ragged-right = ##t
55   short-indent = 5\mm
56 }
57
58 \score {
59   <<
60     \new ChoirStaff <<
61       \new Staff \with { instrumentName = #"High I + II" } {
62         <<
63           \repeat unfold 4 f''1
64           \\
65           \repeat unfold 4 d''1
66         >>
67         \splitStaffBarLine
68       }
69       \new Staff \with { instrumentName = #"Low" } {
70         <<
71           \repeat unfold 4 b'1
72           \\
73           \repeat unfold 4 g'1
74         >>
75       }
76
77       \new Staff \with { shortInstrumentName = #"H I" } {
78         R1*4
79         \repeat unfold 2 { r4 f''2 r4 } \repeat unfold 2 e''1
80       }
81       \new Staff \with { shortInstrumentName = #"H II" } {
82         R1*4
83         \repeat unfold 4 b'2 \repeat unfold 2 c''1
84       }
85       \new Staff \with { shortInstrumentName = #"L" } {
86         R1*4
87         <<
88           \repeat unfold 4 g'1
89           \\
90           \repeat unfold 4 c'1
91         >>
92       }
93     >>
94   >>
95   \layout {
96     \context {
97       \RemoveEmptyStaffContext
98       \override VerticalAxisGroup #'remove-first = ##t
99     }
100   }
101 }
102