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