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