I make separate score-blocks for the PDF and the MIDI. Something like the following. Note that, for the PDF, the dynamics in \pianoCentredDynamics
are separate from the Staffs containing the notes in \rhMusic
and \lhMusic
. By contrast, for the MIDI for the RH, the dynamics and \rhMusic
are put in parallel and all assigned to the Staff -- and similarly for the LH.
\version "2.18.2"
\include "english.ly"
\header {
} % header
\paper
{
#(set-paper-size "a4")
}
global =
{
\key bf \major
\tempo 4=96
\time 3/4
}
rhMusic =
{
d'2. ef'4 f'g'a'bf'c''d''2.
}
pianoCentredDynamics =
{
s2.\pp s\< s s\ff
}
lhMusic =
{
\clef bass
bf,2. c4 d ef f g a bf2.
}
pedalling =
{
}
% Score-block for the layout
\score
{
\new GrandStaff
<<
\new Staff = "rh" << \global \rhMusic >>
\new Dynamics = "dynamics" \pianoCentredDynamics
\new Staff = "lh" << \global \lhMusic >>
\new Dynamics = "pedal" \pedalling
>>
\layout
{
}
}
% Score-block for the MIDI
\score
{
\unfoldRepeats %\articulate
\new PianoStaff
<<
% See http://lilypond.1069038.n5.nabble.com/Sustain-in-midi-output-of-Piano-Centered-Dynamics-Template-td31012.html
\new Dynamics = "dynamics" \pianoCentredDynamics
\new Dynamics = "pedal" \pedalling
\new Staff = "rh" << \global \rhMusic \pianoCentredDynamics \pedalling >>
\new Staff = "lh" << \global \lhMusic \pianoCentredDynamics \pedalling >>
>>
\midi
{
% See http://lilypond.1069038.n5.nabble.com/Sustain-in-midi-output-of-Piano-Centered-Dynamics-Template-td31012.html
\context {
\type "Performer_group"
\name Dynamics
\consists "Piano_pedal_performer"
}
\context {
\PianoStaff
\accepts Dynamics
}
\context
{
\Staff
\consists "Dynamic_performer"
}
}
} % score for MIDI