]> git.donarmstrong.com Git - lilypond.git/blob - input/new/piano-template-with-centered-dynamics.ly
Merge master into nested-bookparts
[lilypond.git] / input / new / piano-template-with-centered-dynamics.ly
1 \version "2.11.61"
2
3 \header {
4   lsrtags = "expressive-marks,keyboards,template"
5   texidoc = "
6 Many piano scores have the dynamics centered between the two staves.
7 This requires a bit of tweaking to implement, but since the template is
8 right here, you don't have to do the tweaking yourself.
9 "
10   doctitle = "Piano template with centered dynamics"
11 }
12
13 global = {
14   \key c \major
15   \time 4/4
16 }
17
18 upper = \relative c'' {
19   \clef treble
20   a4 b c d
21 }
22
23 lower = \relative c {
24   \clef bass
25   a2 c
26 }
27
28 dynamics = {
29   s2\fff\> s4 s\!\pp
30 }
31
32 pedal = {
33   s2\sustainOn s\sustainOff
34 }
35
36 \score {
37   \new PianoStaff = "PianoStaff_pf" <<
38     \new Staff = "Staff_pfUpper" \upper
39     \new Dynamics = "Dynamics_pf" \dynamics
40     \new Staff = "Staff_pfLower" << \lower >>
41     \new Dynamics = "pedal" \pedal
42   >>
43
44   \layout {
45     % define Dynamics context
46     \context {
47       \type "Engraver_group"
48       \name Dynamics
49       \alias Voice
50       \consists "Output_property_engraver"
51       \consists "Piano_pedal_engraver"
52       \consists "Script_engraver"
53       \consists "New_dynamic_engraver"
54       \consists "Dynamic_align_engraver"
55       \consists "Text_engraver"
56       \consists "Skip_event_swallow_translator"
57       \consists "Axis_group_engraver"
58
59       pedalSustainStrings = #'("Ped." "*Ped." "*")
60       pedalUnaCordaStrings = #'("una corda" "" "tre corde")
61       \override DynamicLineSpanner #'Y-offset = #0
62       \override TextScript #'font-size = #2
63       \override TextScript #'font-shape = #'italic
64       \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
65     }
66     % modify PianoStaff context to accept Dynamics context
67     \context {
68       \PianoStaff
69       \accepts Dynamics
70     }
71   }
72 }
73
74 \score {
75   \new PianoStaff = "PianoStaff_pf" <<
76     \new Staff = "Staff_pfUpper" << \global \upper \dynamics \pedal >>
77     \new Staff = "Staff_pfLower" << \global \lower \dynamics \pedal >>
78   >>
79   \midi { }
80 }