Piano templates - GNU LilyPond
Description: GNU LilyPond

Next: String quartet, Previous: Single staff, Up: Example templates

### D.2 Piano templates

#### D.2.1 Solo piano

Here is a simple piano staff.

>          \version "2.7.39"
>          upper = \relative c'' {
>             \clef treble
>             \key c \major
>             \time 4/4

>             a b c d
>          }

>          lower = \relative c {
>             \clef bass
>             \key c \major
>             \time 4/4

>             a2 c
>          }

>          \score {
>             \new PianoStaff <<
>                \set PianoStaff.instrument = "Piano  "
>                \new Staff = "upper" \upper
>                \new Staff = "lower" \lower
>             >>
>             \layout { }
>             \midi { \tempo 4=60 }
>          }

#### D.2.2 Piano and melody with lyrics

Here is a typical song format: one staff with the melody and lyrics, with piano accompaniment underneath.

>          \version "2.7.39"
>          melody = \relative c'' {
>             \clef treble
>             \key c \major
>             \time 4/4

>             a b c d
>          }

>          text = \lyricmode {
>             Aaa Bee Cee Dee
>          }

>          upper = \relative c'' {
>             \clef treble
>             \key c \major
>             \time 4/4

>             a b c d
>          }

>          lower = \relative c {
>             \clef bass
>             \key c \major
>             \time 4/4

>             a2 c
>          }

>          \score {
>             <<
>                \new Voice = "mel" {
>                    \autoBeamOff
>                    \melody
>                }
>                \new Lyrics \lyricsto mel \text

>                \new PianoStaff <<
>                   \new Staff = "upper" \upper
>                   \new Staff = "lower" \lower
>                >>
>             >>
>             \layout {
>                \context { \RemoveEmptyStaffContext }
>             }
>             \midi { \tempo 4=60 }
>          }

#### D.2.3 Piano centered lyrics

Instead of having a full staff for the melody and lyrics, you can place the lyrics between the piano staff (and omit the separate melody staff).

>          \version "2.7.39"
>          upper = \relative c'' {
>             \clef treble
>             \key c \major
>             \time 4/4

>             a b c d
>          }

>          lower = \relative c {
>             \clef bass
>             \key c \major
>             \time 4/4

>             a2 c
>          }

>          text = \lyricmode {
>             Aaa Bee Cee Dee
>          }

>          \score {
>            \new GrandStaff <<
>              \new Staff = upper { \new Voice = "singer" \upper }
>              \new Lyrics \lyricsto "singer" \text
>              \new Staff = lower {
>                \clef bass
>                \lower
>              }
>            >>
>            \layout {
>              \context { \GrandStaff \accepts "Lyrics" }
>              \context { \Lyrics \consists "Bar_engraver" }
>            }
>            \midi { \tempo 4=60 }
>          }

#### D.2.4 Piano centered dynamics

Many piano scores have the dynamics centered between the two staffs. This requires a bit of tweaking to implement, but since the template is right here, you don't have to do the tweaking yourself.

>          \version "2.7.39"
>          upper = \relative c'' {
>            \clef treble
>            \key c \major
>            \time 4/4

>            a b c d
>          }

>          lower = \relative c {
>            \clef bass
>            \key c \major
>            \time 4/4

>            a2 c
>          }

>          dynamics = {
>            s2\fff\> s4
>            s\!\pp
>          }

>          pedal = {
>            s2\sustainDown s2\sustainUp
>          }

>          \score {
>            \new PianoStaff <<
>              \new Staff = "upper" \upper
>              \new Dynamics = "dynamics" \dynamics
>              \new Staff = "lower" <<
>                \clef bass
>                \lower
>              >>
>              \new Dynamics = "pedal" \pedal
>            >>
>            \layout {
>              \context {
>                \type "Engraver_group"
>                \name Dynamics
>                \alias Voice % So that \cresc works, for example.
>                \consists "Output_property_engraver"

>                \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
>                pedalSustainStrings = #'("Ped." "*Ped." "*")
>                pedalUnaCordaStrings = #'("una corda" "" "tre corde")

>                \consists "Piano_pedal_engraver"
>                \consists "Script_engraver"
>                \consists "Dynamic_engraver"
>                \consists "Text_engraver"

>                \override TextScript #'font-size = #2
>                \override TextScript #'font-shape = #'italic
>                \override DynamicText #'extra-offset = #'(0 . 2.5)
>                \override Hairpin #'extra-offset = #'(0 . 2.5)

>                \consists "Skip_event_swallow_translator"

>                \consists "Axis_group_engraver"
>              }
>              \context {
>                \PianoStaff
>                \accepts Dynamics
>                \override VerticalAlignment #'forced-distance = #7
>              }
>            }
>          }
>          \score {
>            \new PianoStaff <<
>              \new Staff = "upper" << \upper \dynamics >>
>              \new Staff = "lower" << \lower \dynamics >>
>              \new Dynamics = "pedal" \pedal
>            >>
>            \midi {
>              \context {
>                \type "Performer_group"
>                \name Dynamics
>                \consists "Piano_pedal_performer"
>              }
>              \context {
>                \PianoStaff
>                \accepts Dynamics
>              }
>            }
>          }

This page is for LilyPond-2.8.8 (stable-branch).

Other languages: English.
Using automatic language selection.