]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/horizontally-aligning-custom-dynamics-e.g.-sempre-pp,-piu-f,-subito-p.ly
Merge master into nested-bookparts
[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.11.62"
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 \header { title = "Horizontally aligning custom dynamics" }
51 \layout { ragged-right = ##t }
52
53 % Solution 1: Using a simple markup with a particular halign value
54 % Drawback: It's a markup, not a dynamic command, so \dynamicDown etc. will have no effect
55 semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }
56
57 % Solution 2: Using a dynamic script and shifting with \once\override ... #'X-offset = ..
58 % Drawback: \once\override needed for every invocation
59 semppK = #(make-dynamic-script (markup #:line( #:normal-text #:italic "sempre" #:dynamic "pp")))
60
61 % Solution 3: Padding the dynamic script so the center-alignment puts it to the correct position
62 % Drawback: the padding really reserves the space, nothing else can be there
63 semppT = #(
64   make-dynamic-script (
65     markup #:line (
66       #:normal-text #:italic "sempre" #:dynamic "pp" #:hspace 7.1
67     )
68   )
69 )
70
71 % Solution 4: Dynamic, setting the dimensions of the additional text to 0
72 % Drawback: To lilypond "sempre" has no extent, so it might put other stuff there => collisions
73 % Drawback: Also, there seems to be some spacing, so it's not exactly the 
74 %           same alignment as without the additional text
75 semppM = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0) '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
76
77 % Solution 5: Dynamic with explicit shifting inside the scheme function
78 semppG = #(make-dynamic-script
79   (markup
80     #:hspace 0 #:translate (cons -18.85 0 )
81     #:line( #:normal-text #:italic "sempre" #:dynamic "pp"))
82 )
83
84 % Solution 6: Dynamic with explicit alignment. This has only effect, if one sets X-offset!
85 % Drawback: One needs to set DynamicText #'X-offset!
86 % Drawback: Aligned at the right edge of the additional text, not at the center of pp
87 semppMII = #(make-dynamic-script (markup #:line(#:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
88
89
90 \context StaffGroup <<
91   \context Staff="s" << \set Staff.instrumentName = "Normal"
92        \relative c'' { \key es \major c4\pp c\p c c | c\ff c c\pp c } 
93   >>
94   \context Staff="sMarkup" << \set Staff.instrumentName = \markup\column{"Normal" "Markup"}
95        \relative c'' { \key es \major c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c} 
96   >>
97   \context Staff="sK" << \set Staff.instrumentName = \markup\column{"Explicit" "shifting"}
98        \relative c'' { \key es \major 
99            \once \override DynamicText #'X-offset = #-9.2 c4\semppK c\p c c | 
100            c\ff c \once \override DynamicText #'X-offset = #-9.2  c\semppK c } 
101   >>
102   \context Staff="sT" << \set Staff.instrumentName = \markup\column{"Right" "padding"}
103        \relative c'' { \key es \major c4\semppT c\p c c | c\ff c c\semppT c } 
104   >>
105   \context Staff="sM" << \set Staff.instrumentName = \markup\column{"Setting" "dimension" "to zero"}
106        \relative c'' { \key es \major c4\semppM c\p c c | c\ff c c\semppM c } 
107   >>
108   \context Staff="sG" << \set Staff.instrumentName = \markup\column{"Shifting" "inside" "dynamics"}
109        \relative c'' { \key es \major c4\semppG c\p c c | c\ff c c\semppG c} 
110   >>
111   \context Staff="sMII" << \set Staff.instrumentName = \markup\column{"Alignment" "inside" "dynamics"}
112     \relative c'' { \key es \major 
113       \override DynamicText #'X-offset = #0  % Setting to ##f (false) gives the same resul
114       c4\semppMII c\p c c | c\ff c c\semppMII c } 
115     >>
116 >>
117