]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/horizontally-aligning-custom-dynamics-e.g.-sempre-pp,-piu-f,-subito-p.ly
Snippets: Replace \set Staff.instrumentName
[lilypond.git] / Documentation / snippets / horizontally-aligning-custom-dynamics-e.g.-sempre-pp,-piu-f,-subito-p.ly
1 % DO NOT EDIT this file manually; it is automatically
2 % generated from Documentation/snippets/new
3 % Make any changes in Documentation/snippets/new/
4 % and then run scripts/auxiliar/makelsr.py
5 %
6 % This file is in the public domain.
7 %% Note: this file works from version 2.19.56
8 \version "2.19.56"
9
10 \header {
11   lsrtags = "expressive-marks, tweaks-and-overrides, version-specific"
12
13   texidoc = "
14 Some dynamic expressions involve additional text, like @qq{sempre pp}.
15 Since dynamics are usually centered under the note, the \\pp would be
16 displayed way after the note it applies to.
17
18 To correctly align the @qq{sempre pp} horizontally, so that it is
19 aligned as if it were only the \\pp, there are several approaches:
20
21 * Simply use @code{\\once\\override DynamicText.X-offset = #-9.2}
22 before the note with the dynamics to manually shift it to the correct
23 position. Drawback: This has to be done manually each time you use that
24 dynamic markup...
25
26 * Add some padding (@code{#:hspace 7.1}) into the definition of your
27 custom dynamic mark, so that after lilypond center-aligns it, it is
28 already correctly aligned. Drawback: The padding really takes up that
29 space and does not allow any other markup or dynamics to be shown in
30 that position.
31
32 * Shift the dynamic script @code{\\once\\override ... .X-offset = ..}.
33 Drawback: @code{\\once\\override} is needed for every invocation!
34
35 * Set the dimensions of the additional text to 0 (using
36 @code{#:with-dimensions '(0 . 0) '(0 . 0)}). Drawback: To LilyPond
37 @qq{sempre} has no extent, so it might put other stuff there and create
38 collisions (which are not detected by the collision detection!). Also,
39 there seems to be some spacing, so it's not exactly the same alignment
40 as without the additional text
41
42 * Add an explicit shifting directly inside the scheme function for the
43 dynamic-script.
44
45 * Set an explicit alignment inside the dynamic-script. By default, this
46 won't have any effect, only if one sets X-offset! Drawback: One needs
47 to set @code{DynamicText.X-offset}, which will apply to all dynamic
48 texts! Also, it is aligned at the right edge of the additional text,
49 not at the center of pp.
50
51
52
53
54 "
55   doctitle = "Horizontally aligning custom dynamics (e.g. \"sempre pp\" \"piu f\" \"subito p\")"
56 } % begin verbatim
57
58 \paper {
59   ragged-right = ##f
60   indent = 2.5\cm
61 } % begin verbatim
62
63
64 % Solution 1: Using a simple markup with a particular halign value
65 % Drawback: It's a markup, not a dynamic command, so \dynamicDown
66 %           etc. will have no effect
67 semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }
68
69 % Solution 2: Using a dynamic script & shifting with
70 %             \once \override ...X-offset = ..
71 % Drawback: \once \override needed for every invocation
72 semppK =
73 #(make-dynamic-script
74   (markup #:line
75           (#:normal-text
76            #:italic "sempre"
77            #:dynamic "pp")))
78
79 % Solution 3: Padding the dynamic script so the center-alignment
80 %             puts it at the correct position
81 % Drawback: the padding really reserves the space, nothing else can be there
82 semppT =
83 #(make-dynamic-script
84   (markup #:line
85           (#:normal-text
86            #:italic "sempre"
87            #:dynamic "pp"
88            #:hspace 7.1)))
89
90 % Solution 4: Dynamic, setting the dimensions of the additional text to 0
91 % Drawback: To lilypond "sempre" has no extent, so it might put
92 %           other stuff there => collisions
93 % Drawback: Also, there seems to be some spacing, so it's not exactly the
94 %           same alignment as without the additional text
95 semppM =
96 #(make-dynamic-script
97   (markup #:line
98           (#:with-dimensions '(0 . 0) '(0 . 0)
99                              #:right-align
100                              #:normal-text
101                              #:italic "sempre"
102                              #:dynamic "pp")))
103
104 % Solution 5: Dynamic with explicit shifting inside the scheme function
105 semppG =
106 #(make-dynamic-script
107   (markup #:hspace 0
108           #:translate '(-18.85 . 0)
109           #:line (#:normal-text
110                   #:italic "sempre"
111                   #:dynamic "pp")))
112
113 % Solution 6: Dynamic with explicit alignment. This has only effect
114 %             if one sets X-offset!
115 % Drawback: One needs to set DynamicText.X-offset!
116 % Drawback: Aligned at the right edge of the additional text,
117 %           not at the center of pp
118 semppMII =
119 #(make-dynamic-script
120   (markup #:line (#:right-align
121                   #:normal-text
122                   #:italic "sempre"
123                   #:dynamic "pp")))
124
125 \new StaffGroup <<
126   \new Staff = "s" \with { instrumentName = \markup \column { Normal } }
127   <<
128     \relative c'' {
129       \key es \major
130       c4\pp c\p c c | c\ff c c\pp c
131     }
132   >>
133   \new Staff = "sMarkup" \with {
134     instrumentName = \markup \column { Normal markup }
135   }
136   <<
137     \relative c'' {
138       \key es \major
139       c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
140     }
141   >>
142   \new Staff = "sK" \with {
143     instrumentName = \markup \column { Explicit shifting }
144   }
145   <<
146     \relative c'' {
147       \key es \major
148       \once \override DynamicText.X-offset = #-9.2
149       c4\semppK c\p c c
150       c4\ff c
151       \once \override DynamicText.X-offset = #-9.2
152       c4\semppK c
153     }
154   >>
155   \new Staff = "sT" \with {
156     instrumentName = \markup \column { Right padding }
157   }
158   <<
159     \relative c'' {
160       \key es \major
161       c4\semppT c\p c c | c\ff c c\semppT c
162     }
163   >>
164   \new Staff = "sM" \with {
165     instrumentName = \markup \column { Set dimension "to zero" }
166   }
167   <<
168     \relative c'' {
169       \key es \major
170       c4\semppM c\p c c | c\ff c c\semppM c
171     }
172   >>
173   \new Staff = "sG" \with {
174     instrumentName = \markup \column { Shift inside dynamics}
175   }
176   <<
177     \relative c'' {
178       \key es \major
179       c4\semppG c\p c c | c\ff c c\semppG c
180     }
181   >>
182   \new Staff = "sMII" \with {
183     instrumentName = \markup \column { Alignment inside dynamics }
184   }
185   <<
186     \relative c'' {
187       \key es \major
188       % Setting to ##f (false) gives the same result
189       \override DynamicText.X-offset = #0
190       c4\semppMII c\p c c | c\ff c c\semppMII c
191     }
192   >>
193 >>
194
195 \layout { \override Staff.InstrumentName.self-alignment-X = #LEFT }