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