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