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