Jump to content

Piano template with centered dynamics: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
Line 1: Line 1:
Many piano scores have the dynamics centered between the two staves. This snippet demonstrates how this was achieved with older versions of LilyPond; the Dynamics context is now included by default (starting with LilyPond 2.13.29), and does not require to be defined manually.
Many piano scores have the dynamics centered between the two staves. This snippet demonstrates how this was achieved with older versions of LilyPond; the Dynamics context is now included by default (starting with LilyPond 2.13.29), and does not require to be defined manually.


<lilypond version="2.24.0">
<lilypond version="2.24">
%% http://lsr.di.unimi.it/LSR/Item?id=357
%% http://lsr.di.unimi.it/LSR/Item?id=357



Revision as of 18:56, 16 November 2025

Many piano scores have the dynamics centered between the two staves. This snippet demonstrates how this was achieved with older versions of LilyPond; the Dynamics context is now included by default (starting with LilyPond 2.13.29), and does not require to be defined manually.

\version "2.24"

%% http://lsr.di.unimi.it/LSR/Item?id=357

global = {
  \key c \major
  \time 4/4
}

upper = \relative c'' {
  \clef treble
  a4 b c d
}

lower = \relative c {
  \clef bass
  a2 c
}

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

pedal = {
  s2\sustainOn s\sustainOff
}

\score {
  \new PianoStaff = "PianoStaff_pf" <<
    \new Staff = "Staff_pfUpper" << \global \upper >>
    \new Dynamics = "Dynamics_pf" \dynamics
    \new Staff = "Staff_pfLower" << \global \lower >>
    \new Dynamics = "pedal" \pedal
  >>
  \layout { }
}

\score {
  \new PianoStaff = "PianoStaff_pf" <<
    \new Staff = "Staff_pfUpper" << \global \upper \dynamics \pedal >>
    \new Staff = "Staff_pfLower" << \global \lower \dynamics \pedal >>
  >>
  \midi { }
}