Product SiteDocumentation Site

12.7.6. Format the Score (Piano Dynamics)

Keyboard instruments use a unique notation when it comes to dynamics. Most instruments use only one staff per player, so the dynamics are, by convention, notated underneath that staff. Keyboard instruments usually use two staves (organs and complex piano music may use three). Because the dynamics are usually meant to apply to both staves, they are usually notated between the two staves. This is similar to notation beneath the upper staff, but in truth, piano dynamics tend to be placed in the middle between the staves - entering the dynamics as belonging to the upper staff, in LilyPond, will not produce that effect.
There is a way to notate dynamics between two staves in LilyPond, and it involves a little bit of thought to get it right. It also requires the addition of a significant number of commands, and the creation of a new context.
This process looks difficult, and may seem daunting. It's not necessary to understand all of the commands in the "PianoDynamics" Context in order to use the context, so there is no need to worry!

12.7.6.1. Prepare the "PianoDynamics" Context

It is probably easier to add these commands before inputting most of the score, but there is no reason why this context cannot be added to any score at any time.
Follow these steps to create a "PianoDynamics" Context:
  1. Between the left and right staves of the PianoStaff, add "\new PianoDynamics = "dynamics" \dynamics". For the Schubert score, this looks like:
    \new PianoStaff \with
     {
       instrumentName = "Piano"
     }
    <<
     \new Staff = "right" \right
     \new PianoDynamics = "dynamics" \dynamics
     \new Staff = "left" { \clef bass \left }
    >>
    
  2. To the layout section, add the following:
    % Everything below here is for the piano dynamics.
    % Define "PianoDynamics" context.
    \context
    {
    	\type "Engraver_group"
    	\name PianoDynamics
    	\alias Voice
    	\consists "Output_property_engraver"
    	\consists "Script_engraver"
    	\consists "New_dynamic_engraver"
    	\consists "Dynamic_align_engraver"
    	\consists "Text_engraver"
    	\consists "Skip_event_swallow_translator"
    	\consists "Axis_group_engraver"
    
    	\override DynamicLineSpanner #'Y-offset = #0
    	\override TextScript #'font-size = #2
    	\override TextScript #'font-shape = #'italic
    	\override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
    }
    
    % Modify "PianoStaff" context to accept Dynamics context.
    \context
    {
    	\PianoStaff
    	\accepts PianoDynamics
    }
    % End of PianoDynamics code.
    
    This creates a "PianoDynamics" context, and modifies the "PianoStaff" context so that it will accept a "PianoDynamics" context.
  3. Before the "\score" section, add a section called "dynamics," like this:
    dynamics =
    {
      % Dynamics go here.
    
    }
    
    This is where you will input the dynamics.