Next: , Previous: Single staff, Up: Templates


A.2 Piano templates

A.2.1 Solo piano

Here is a simple piano staff with some notes.

     
     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.instrumentName = "Piano  "
                    \new Staff = "upper" \upper
                    \new Staff = "lower" \lower
                 >>
                 \layout { }
                 \midi { }
              }
     

[image of music]

A.2.2 Piano and melody with lyrics

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

     
     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 { }
              }
     

[image of music]

A.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).

     
     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 { }
              }
     

[image of music]

A.2.4 Piano centered dynamics

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

     
     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)
           \override DynamicLineSpanner #'Y-offset = #0
           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
           
           \consists "Skip_event_swallow_translator"
           
           \consists "Axis_group_engraver"
         }
         \context {
           \PianoStaff
           \accepts Dynamics
         }
       }
     }
     \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
         }
       }
     }

[image of music]



Next: , Previous: Single staff, Up: Templates

Cette page documente LilyPond-2.11.40 (branche de développement).

Rapportez toute anomalie en français à lilypond-user-fr@gnu.org ou en anglais à http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs

Vos suggestions à propos de la documentation sont les bienvenues.

Otros idiomas: deutsch.