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