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