# Writing dynamics separately with Lilypond

I've recently been engraving more and more with Lilypond, and I stumbled upon a .ly file on Mutopia (public domain scores engraved with Lilypond) where the dynamics and articulations are written separately from the pitches, like so :

\score {
<<
\new PianoStaff <<
\new Staff = "upper" \pianoThemeUpper
\new Dynamics { \global \themeDynamics }
\new Staff = "lower" \pianoThemeLower
>>
>>
}


So instead of having a very heavy right hand staff for the piano with all the dynamics and articulations on top of the pitches, they are in a separate place. It seemed neat and like a good idea, so I tried it for my next score.

I wrote the score as :

\version "2.20.0"

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

%%%%%%%%
%% THEME
%%%%%%%%

themeUpper = \relative c' {
r2 f4 bes |
bes d8 bes f4 bes |
bes2 bes4 <d, bes'>8 < f c'> |
< bes d>4 < c e>8 < bes d> < f c'>4 <d bes'> |
< f a c> f \breathe f bes |
bes d8 bes f4 bes|
bes2 <bes  d,>4 <c  f,> |
<d  bes> <ees  c>8 <d  bes> <c a>4 <a f'> |
<bes  d,>2 r |
\bar "|."
}

themeLower = \relative c {
r1 |
bes4 <f' bes d> f, <f' bes d> |
bes,4 <f' bes d> f, <f' bes> |
bes,4 <f' bes d> f, <f' bes> |
f, <f' a c> \breathe r2 |
bes,4 <f' bes d> f, <f' bes d> |
bes,4 <f' bes d> f, <f' bes d> |
bes,4 <f' bes d> f, <f' a ees'> |
<bes bes,>2 r |
}

%%%%%%%%%%%
%% DYNAMICS
%%%%%%%%%%%

themeDynamics = {
s2 \mf s2 |
s1 |
s2. \< s4 \! |
}

%%%%%%%%%%%%%%%
%% PIANO SCORES
%%%%%%%%%%%%%%%

pianoThemeUpper = {
\clef "treble"
\global
<<
\new Voice {
\themeUpper
}
>>
}

pianoThemeLower = {
\clef "bass"
\global
<<
\new Voice {
\themeLower
}
>>
}

%%%%%%%%
%% SCORE
%%%%%%%%

\score {
<<
\new PianoStaff <<
\new Staff = "upper" \pianoThemeUpper
\new Dynamics { \global \themeDynamics }
\new Staff = "lower" \pianoThemeLower
>>
>>
}


And obtained :

When I actually would have liked :

If you have a close look at my dynamics, they look like :

themeDynamics = {
s2 \mf s2 |
s1 |
s2. \< s4 \! |
}


And for me, it seems that :

1. in the first bar, I wait a minim, then indicate a mezzo forte, then wait another minim
2. in the third bar, I wait for a pointed minim, start a crescendo, and end it at the end of the bar.

Obviously, I didn't do that. So my question is two-fold :

1. Is it good practice to separate the dynamics from the pitches, like I think it is (making the notation a little lighter) ? Please note that I know this score is a very simple one, I made it so for the example.
2. If it is a good idea to separate the dynamics, how do I do it ? I have very obviously and painfully missed something here, and I'd like to become more fluent with Lilypond.
• I think that should be an e-flat instead of an e-natural in the fourth bar. Jun 27 '20 at 19:27
• Am I the only one not seeing the code sample after: " they look like :"?
– Tom
Jun 27 '20 at 19:52
• @Tom_C No indeed, you're not the only one. I can't see it anymore, though I definitely saw it multiple times before Jun 27 '20 at 20:03
• Maybe a random copyright owner complained ;)
– Tom
Jun 27 '20 at 20:28
• Whole bar rest is centred in the middle of the bar. r1 just puts the whole bar rest in the position of the half-note rest which is wrong. R1 would be correct.
– user70304
Jun 29 '20 at 0:25

Ad 1) Yes, it certainly is a very good practice. Larger scores would be a pain to manage without this. (It's also good for cases when you need a dynamic that does not attach to any particular notes in the music, e. g. you can write c1 in your music and s2\< s\> in your dynamics to make a crescendo-decrescendo pair on the single note.)
Ad 2) You have missed the fact that the dynamics are attached to the note after that they come (like pretty much everything else). So in the same way as c4-. adds a staccato to the C and not to the next note, c4\< starts a crescendo at the C and not at the next note.
And the s behaves just like a normal note. So s2\mf means that the mf is attached to this rest, not to the one after.
All in all, if you rewrite your first bar to s2 s\mf and your third and fourth to s2. s4\< | s1\!, you should get what you want.
• Thank you very much. There is one detail that still confuses me, though. Where do I write \override BreathingSign.text = \markup {\musicglyph #"scripts.caesura.curved"} and \override DynamicLineSpanner.staff-padding = #3, now ? I can't seem to write them anywhere where they actually do what I expect them to :( Jun 27 '20 at 22:22
• @JambonSama: I think you should leave the breath marks in the individual voices (as well as the articulations like staccatos). The override can then be put into your variable with global settings. As for the second one, no wonder that does not work (the separate dynamics line is surely a different object), but I don't know how to fix that. You can look through the documentation for the Dynamics and you will surely find the object name in the internals reference. Most probably you will want to do something like \new Dynamics \with { staff-padding = #3 } { ... }, but I don't know for sure. Jun 28 '20 at 0:31
• @JambonSama, I put voltas etc. in all voices because I feel that's the correct way (each voice in separation needs to be repeated etc.) You can make another normal voice if you want, fill it with s's and put the voltas in there. Then you would have to append it using << >> to whatever you want to typeset. Jul 1 '20 at 20:56