]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/horizontally-aligning-custom-dynamics-e.g.-sempre-pp,-piu-f,-subito-p.ly
4b658266599602270cd851943bf4aeb14f36c891
[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.12.2"
8
9 \header {
10   lsrtags = "expressive-marks, tweaks-and-overrides"
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 \header { title = "Horizontally aligning custom dynamics" }
56
57 \paper { ragged-right = ##f }
58
59 % Solution 1: Using a simple markup with a particular halign value
60 % Drawback: It's a markup, not a dynamic command, so \dynamicDown
61 %           etc. will have no effect
62 semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }
63
64 % Solution 2: Using a dynamic script & shifting with
65 %             \once \override ... #'X-offset = ..
66 % Drawback: \once \override needed for every invocation
67 semppK =
68 #(make-dynamic-script
69   (markup #:line
70           (#:normal-text
71            #:italic "sempre"
72            #:dynamic "pp")))
73
74 % Solution 3: Padding the dynamic script so the center-alignment
75 %             puts it at the correct position
76 % Drawback: the padding really reserves the space, nothing else can be there
77 semppT =
78 #(make-dynamic-script
79   (markup #:line
80           (#:normal-text
81            #:italic "sempre"
82            #:dynamic "pp"
83            #:hspace 7.1)))
84
85 % Solution 4: Dynamic, setting the dimensions of the additional text to 0
86 % Drawback: To lilypond "sempre" has no extent, so it might put
87 %           other stuff there => collisions
88 % Drawback: Also, there seems to be some spacing, so it's not exactly the
89 %           same alignment as without the additional text
90 semppM =
91 #(make-dynamic-script
92   (markup #:line
93           (#:with-dimensions '(0 . 0) '(0 . 0)
94                              #:right-align
95                              #:normal-text
96                              #:italic "sempre"
97                              #:dynamic "pp")))
98
99 % Solution 5: Dynamic with explicit shifting inside the scheme function
100 semppG =
101 #(make-dynamic-script
102   (markup #:hspace 0
103           #:translate '(-18.85 . 0)
104           #:line (#:normal-text
105                   #:italic "sempre"
106                   #:dynamic "pp")))
107
108 % Solution 6: Dynamic with explicit alignment. This has only effect
109 %             if one sets X-offset!
110 % Drawback: One needs to set DynamicText #'X-offset!
111 % Drawback: Aligned at the right edge of the additional text,
112 %           not at the center of pp
113 semppMII =
114 #(make-dynamic-script
115   (markup #:line (#:right-align
116                   #:normal-text
117                   #:italic "sempre"
118                   #:dynamic "pp")))
119
120 \context StaffGroup <<
121   \context Staff = "s" <<
122     \set Staff.instrumentName = #"Normal"
123     \relative c'' {
124       \key es \major
125       c4\pp c\p c c | c\ff c c\pp c
126     }
127   >>
128   \context Staff = "sMarkup" <<
129     \set Staff.instrumentName = \markup \column { Normal markup }
130     \relative c'' {
131       \key es \major
132       c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
133     }
134   >>
135   \context Staff = "sK" <<
136     \set Staff.instrumentName = \markup \column { Explicit shifting }
137     \relative c'' {
138       \key es \major
139       \once \override DynamicText #'X-offset = #-9.2
140       c4\semppK c\p c c
141       c4\ff c
142       \once \override DynamicText #'X-offset = #-9.2
143       c4\semppK c
144     }
145   >>
146   \context Staff = "sT" <<
147     \set Staff.instrumentName = \markup \column { Right padding }
148     \relative c'' {
149       \key es \major
150       c4\semppT c\p c c | c\ff c c\semppT c
151     }
152   >>
153   \context Staff = "sM" <<
154     \set Staff.instrumentName = \markup \column { Setting dimension "to zero" }
155     \relative c'' {
156       \key es \major
157       c4\semppM c\p c c | c\ff c c\semppM c
158     }
159   >>
160   \context Staff = "sG" <<
161     \set Staff.instrumentName = \markup \column { Shifting inside dynamics }
162     \relative c'' {
163       \key es \major
164       c4\semppG c\p c c | c\ff c c\semppG c
165     }
166   >>
167   \context Staff = "sMII" <<
168     \set Staff.instrumentName = \markup \column { Alignment inside dynamics }
169     \relative c'' {
170       \key es \major
171       % Setting to ##f (false) gives the same result
172       \override DynamicText #'X-offset = #0
173       c4\semppMII c\p c c | c\ff c c\semppMII c
174     }
175   >>
176 >>
177