1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
6 %% This file is in the public domain.
10 lsrtags = "expressive-marks, tweaks-and-overrides, version-specific"
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.
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:
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
25 * Add some padding (@code{#:hspace 7.1}) into the definition of your
26 custom dynamic mark, so that after lilypond center-aligns it, it is
27 already correctly aligned. Drawback: The padding really takes up that
28 space and does not allow any other markup or dynamics to be shown in
31 * Shift the dynamic script @code{\\once\\override ... .X-offset = ..}.
32 Drawback: @code{\\once\\override} is needed for every invocation!
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
41 * Add an explicit shifting directly inside the scheme function for the
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.
54 doctitle = "Horizontally aligning custom dynamics (e.g. \"sempre pp\" \"piu f\" \"subito p\")"
62 % Solution 1: Using a simple markup with a particular halign value
63 % Drawback: It's a markup, not a dynamic command, so \dynamicDown
64 % etc. will have no effect
65 semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }
67 % Solution 2: Using a dynamic script & shifting with
68 % \once \override ...X-offset = ..
69 % Drawback: \once \override needed for every invocation
77 % Solution 3: Padding the dynamic script so the center-alignment
78 % puts it at the correct position
79 % Drawback: the padding really reserves the space, nothing else can be there
88 % Solution 4: Dynamic, setting the dimensions of the additional text to 0
89 % Drawback: To lilypond "sempre" has no extent, so it might put
90 % other stuff there => collisions
91 % Drawback: Also, there seems to be some spacing, so it's not exactly the
92 % same alignment as without the additional text
96 (#:with-dimensions '(0 . 0) '(0 . 0)
102 % Solution 5: Dynamic with explicit shifting inside the scheme function
104 #(make-dynamic-script
106 #:translate '(-18.85 . 0)
107 #:line (#:normal-text
111 % Solution 6: Dynamic with explicit alignment. This has only effect
112 % if one sets X-offset!
113 % Drawback: One needs to set DynamicText.X-offset!
114 % Drawback: Aligned at the right edge of the additional text,
115 % not at the center of pp
117 #(make-dynamic-script
118 (markup #:line (#:right-align
123 \context StaffGroup <<
124 \context Staff = "s" <<
125 \set Staff.instrumentName = #"Normal"
127 \override Staff.InstrumentName.self-alignment-X = #LEFT
129 c4\pp c\p c c | c\ff c c\pp c
132 \context Staff = "sMarkup" <<
133 \set Staff.instrumentName = \markup \column { Normal markup }
135 \override Staff.InstrumentName.self-alignment-X = #LEFT
137 c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
140 \context Staff = "sK" <<
141 \set Staff.instrumentName = \markup \column { Explicit shifting }
143 \override Staff.InstrumentName.self-alignment-X = #LEFT
145 \once \override DynamicText.X-offset = #-9.2
148 \once \override DynamicText.X-offset = #-9.2
152 \context Staff = "sT" <<
153 \set Staff.instrumentName = \markup \column { Right padding }
155 \override Staff.InstrumentName.self-alignment-X = #LEFT
157 c4\semppT c\p c c | c\ff c c\semppT c
160 \context Staff = "sM" <<
161 \set Staff.instrumentName = \markup \column { Setting dimension "to zero" }
163 \override Staff.InstrumentName.self-alignment-X = #LEFT
165 c4\semppM c\p c c | c\ff c c\semppM c
168 \context Staff = "sG" <<
169 \set Staff.instrumentName = \markup \column { Shifting inside dynamics }
171 \override Staff.InstrumentName.self-alignment-X = #LEFT
173 c4\semppG c\p c c | c\ff c c\semppG c
176 \context Staff = "sMII" <<
177 \set Staff.instrumentName = \markup \column { Alignment inside dynamics }
179 \override Staff.InstrumentName.self-alignment-X = #LEFT
181 % Setting to ##f (false) gives the same result
182 \override DynamicText.X-offset = #0
183 c4\semppMII c\p c c | c\ff c c\semppMII c