5.7.3 Real music example (LilyPond Learning Manual)

#### 5.7.3 Real music example

We end this section on tweaks by showing the steps to be taken to deal with a tricky example, which needs several adjustments to produce the desired output. The example has been deliberately chosen to illustrate the use of the Notation Reference to resolve unusual problems with notation. It is not representative of the more usual engraving process, so please do not let these difficulties put you off! Fortunately, difficulties like these are not very common.

The example is from Chopin’s Première Ballade, Op. 23, bars 6 to 9, the transition from the opening ‘Lento’ to ‘Moderato’.5 Here, first, is what we want the output to look like, but to avoid over-complicating the example too much we have left out the dynamics, fingering and pedalling, and we aren’t going to tweak the appearance as much as would be possible.

We note first that the right hand part in the third bar requires four voices. These are the five beamed eighth notes, the tied C, the half-note D which is merged with the eighth note D, and the dotted quarter note F-sharp, which is also merged with the eighth note at the same pitch. Everything else is in a single voice, so the easiest way is to introduce these extra three voices temporarily at the time they are needed. If you have forgotten how to do this, see I’m hearing voices and Explicitly instantiating voices. Here we choose to use explicitly instantiated voices for the polyphonic passage, as LilyPond is better able to avoid collisions if all voices are instantiated explicitly in this way.

So let us begin by entering the notes as two variables, setting up the staff structure in a score block, and seeing what LilyPond produces by default:

>     rhMusic = \relative {
>       \new Voice {
>         r2 c''4. g8 |
>         bes1~ |
>         \time 6/4
>         bes2. r8
>         % Start polyphonic section of four voices
>         <<
>           { c,8 d fis bes a }  % continuation of main voice
>           \new Voice {
>             \voiceTwo
>             c,8~ 2
>           }
>           \new Voice {
>             \voiceThree
>             s8 d2
>           }
>           \new Voice {
>             \voiceFour
>             s4 fis4.
>           }
>         >> |
>         g2.  % continuation of main voice
>       }
>     }

>     lhMusic = \relative {
>       r2 <c' g ees>2 |
>       <d g, d>1 |
>       r2. d,,4 r4 r |
>       r4
>     }

>     \score {
>       \new PianoStaff <<
>         \new Staff = "RH"  <<
>           \key g \minor
>           \rhMusic
>         >>
>         \new Staff = "LH" <<
>           \key g \minor
>           \clef "bass"
>           \lhMusic
>         >>
>       >>
>     }

All the notes are right, but the appearance is far from satisfactory. The tie collides with the change in time signature, some notes are not merged together, and several notation elements are missing. Let’s first deal with the easier things. We can easily add the left hand slur and the right hand phrasing slur, since these were all covered in the Tutorial. Doing this gives:

>     rhMusic = \relative {
>       \new Voice {
>         r2 c''4.\( g8 |
>         bes1~ |
>         \time 6/4
>         bes2. r8
>         % Start polyphonic section of four voices
>         <<
>           { c,8 d fis bes a }  % continuation of main voice
>           \new Voice {
>             \voiceTwo
>             c,8~ 2
>           }
>           \new Voice {
>             \voiceThree
>             s8 d2
>           }
>           \new Voice {
>             \voiceFour
>             s4 fis4.
>           }
>         >> |
>         g2.\)  % continuation of main voice
>       }
>     }

>     lhMusic = \relative {
>       r2 <c' g ees>2( |
>       <d g, d>1) |
>       r2. d,,4 r4 r |
>       r4
>     }

>     \score {
>       \new PianoStaff <<
>         \new Staff = "RH"  <<
>           \key g \minor
>           \rhMusic
>         >>
>         \new Staff = "LH" <<
>           \key g \minor
>           \clef "bass"
>           \lhMusic
>         >>
>       >>
>     }

The first bar is now correct. The second bar contains an arpeggio and is terminated by a double bar line. How do we do these, as they have not been mentioned in this Learning Manual? This is where we need to turn to the Notation Reference. Looking up ‘arpeggio’ and ‘bar line’ in the index quickly shows us that an arpeggio is produced by appending `\arpeggio` to a chord, and a double bar line is produced by the `\bar "||"` command. That’s easily done. We next need to correct the collision of the tie with the time signature. This is best done by moving the tie upwards.6 Moving objects was covered earlier in Moving objects, which says that objects positioned relative to the staff can be moved vertically by overriding their `staff-position` property, which is specified in half staff-space units relative to the center line of the staff. So the following override placed just before the first tied note would move the tie up to 3.5 half staff spaces above the center line:

`\once \override Tie.staff-position = 3.5`

This completes bar two, giving:

>     rhMusic = \relative {
>       \new Voice {
>         r2 c''4.\( g8 |
>         \once \override Tie.staff-position = 3.5
>         bes1~ |
>         \bar "||"
>         \time 6/4
>         bes2. r8
>         % Start polyphonic section of four voices
>         <<
>           { c,8 d fis bes a }  % continuation of main voice
>           \new Voice {
>             \voiceTwo
>             c,8~ 2
>           }
>           \new Voice {
>             \voiceThree
>             s8 d2
>           }
>           \new Voice {
>             \voiceFour
>             s4 fis4.
>           }
>         >> |
>         g2.\)  % continuation of main voice
>       }
>     }

>     lhMusic = \relative {
>       r2 <c' g ees>2( |
>       <d g, d>1)\arpeggio |
>       r2. d,,4 r4 r |
>       r4
>     }

>     \score {
>       \new PianoStaff <<
>         \new Staff = "RH"  <<
>           \key g \minor
>           \rhMusic
>         >>
>         \new Staff = "LH" <<
>           \key g \minor
>           \clef "bass"
>           \lhMusic
>         >>
>       >>
>     }

On to bar three and the start of the Moderato section. The tutorial showed how to add a tempo indication with the `\tempo` command, so adding “Moderato” is easy. But how do we merge notes in different voices together? This is where we need to turn again to the Notation Reference for help. A search for “merge” in the Notation Reference index quickly leads us to the commands for merging differently headed and differently dotted notes in Collision resolution. In our example we need to merge both types of note for the duration of the polyphonic section in bar 3, so using the information we find in the Notation Reference we add

    \mergeDifferentlyHeadedOn
    \mergeDifferentlyDottedOn

to the start of that section and

    \mergeDifferentlyHeadedOff
    \mergeDifferentlyDottedOff

to the end, giving:

These overrides have merged the two F-sharp notes, but not the two on D. Why not? The answer is there in the same section in the Notation Reference – notes being merged must have stems in opposite directions and two notes cannot be merged successfully if there is a third note in the same note column. Here the two D’s both have upward stems and there is a third note – the C. We know how to change the stem direction using `\stemDown`, and the Notation Reference also says how to move the C – apply a shift using one of the `\shift` commands. But which one? The C is in voice two which has shift off, and the two D’s are in voices one and three, which have shift off and shift on, respectively. So we have to shift the C a further level still using `\shiftOnn` to avoid it interfering with the two D’s. Applying these changes gives:

>     rhMusic = \relative {
>       \new Voice {
>         r2 c''4.\( g8 |
>         \once \override Tie.staff-position = 3.5
>         bes1~ |
>         \bar "||"
>         \time 6/4
>         bes2.\tempo "Moderato" r8
>         \mergeDifferentlyHeadedOn
>         \mergeDifferentlyDottedOn
>         % Start polyphonic section of four voices
>         <<
>           { c,8 d fis bes a }  % continuation of main voice
>           \new Voice {
>             \voiceTwo
>             % Move the c2 out of the main note column
>             % so the merge will work
>             c,8~ \shiftOnn c2
>           }
>           \new Voice {
>             \voiceThree
>             % Stem on the d2 must be down to permit merging
>             s8 \stemDown d2
>           }
>           \new Voice {
>             \voiceFour
>             s4 fis4.
>           }
>         >> |
>         \mergeDifferentlyHeadedOff
>         \mergeDifferentlyDottedOff
>         g2.\)  % continuation of main voice
>       }
>     }

>     lhMusic = \relative {
>       r2 <c' g ees>2( |
>       <d g, d>1)\arpeggio |
>       r2. d,,4 r4 r |
>       r4
>     }

>     \score {
>       \new PianoStaff <<
>         \new Staff = "RH"  <<
>           \key g \minor
>           \rhMusic
>         >>
>         \new Staff = "LH" <<
>           \key g \minor
>           \clef "bass"
>           \lhMusic
>         >>
>       >>
>     }

Nearly there. Only two problems remain: The downward stem on the merged D should not be there, and the C would be better positioned to the right of the D’s. We know how to do both of these from the earlier tweaks: we make the stem transparent, and move the C with the `force-hshift` property. Here’s the final result:

>     rhMusic = \relative {
>       \new Voice {
>         r2 c''4.\( g8 |
>         \once \override Tie.staff-position = 3.5
>         bes1~ |
>         \bar "||"
>         \time 6/4
>         bes2.\tempo "Moderato" r8
>         \mergeDifferentlyHeadedOn
>         \mergeDifferentlyDottedOn
>         % Start polyphonic section of four voices
>         <<
>           { c,8 d fis bes a }  % continuation of main voice
>           \new Voice {
>             \voiceTwo
>             c,8~
>             % Reposition the c2 to the right of the merged note
>             \once \override NoteColumn.force-hshift = 1.0
>             % Move the c2 out of the main note column
>             % so the merge will work
>             \shiftOnn
>             c2
>           }
>           \new Voice {
>             \voiceThree
>             s8
>             % Stem on the d2 must be down to permit merging
>             \stemDown
>             % Stem on the d2 should be invisible
>             \tweak Stem.transparent ##t
>             d2
>           }
>           \new Voice {
>             \voiceFour
>             s4 fis4.
>           }
>         >> |
>         \mergeDifferentlyHeadedOff
>         \mergeDifferentlyDottedOff
>         g2.\)  % continuation of main voice
>       }
>     }

>     lhMusic = \relative {
>       r2 <c' g ees>2( |
>       <d g, d>1)\arpeggio |
>       r2. d,,4 r4 r |
>       r4
>     }

>     \score {
>       \new PianoStaff <<
>         \new Staff = "RH"  <<
>           \key g \minor
>           \rhMusic
>         >>
>         \new Staff = "LH" <<
>           \key g \minor
>           \clef "bass"
>           \lhMusic
>         >>
>       >>
>     }

#### Footnotes

##### (5)

This is taken from an older edition that deviates from the Urtext version as shown by Henle, for example.

##### (6)

An alternative would be to adjust `Tie.details.height-limit`, making the tie more concave.

#### LilyPond Learning Manual v2.26.0 (stable-branch).

- 1 Installing
  - 1.1 Graphical setup
  - 1.2 Command line setup
- 2 Tutorial
  - 2.1 Compiling a file
  - 2.2 How to write input files
    - 2.2.1 Input characters
    - 2.2.2 Simple notation
      - Pitches
      - Durations (rhythms)
      - Rests
      - Time signature
      - Tempo marks
      - Clef
      - All together
    - 2.2.3 Working on input files
  - 2.3 Dealing with errors
  - 2.4 How to read the manuals
    - 2.4.1 Omitted material
    - 2.4.2 Clickable examples
    - 2.4.3 Overview of manuals
- 3 Common notation
  - 3.1 Single-staff notation
    - 3.1.1 Bar lines and bar checks
      - Bar lines
      - Bar checks
    - 3.1.2 Pitches and key signatures
      - Pitch alterations
      - Key signatures
      - Warning: key signatures and pitches
    - 3.1.3 Ties and slurs
      - Ties
      - Slurs
      - Phrasing slurs
      - Warnings: slurs vs. ties
    - 3.1.4 Articulations and dynamics
      - Articulations
      - Fingerings
      - Dynamics
    - 3.1.5 Adding text
    - 3.1.6 Automatic and manual beams
    - 3.1.7 Advanced rhythmic commands
      - Partial measure
      - Tuplets
      - Grace notes
  - 3.2 Multiple notes at once
    - 3.2.1 Music expressions explained
      - Analogy: mathematical expressions
      - Simultaneous music expressions: multiple staves
      - Simultaneous music expressions: single-staff
    - 3.2.2 Multiple staves
    - 3.2.3 Staff groups
    - 3.2.4 Combining notes into chords
    - 3.2.5 Single-staff polyphony
  - 3.3 Songs
    - 3.3.1 Setting simple songs
    - 3.3.2 Aligning lyrics to a melody
    - 3.3.3 Lyrics to multiple staves
  - 3.4 Final touches
    - 3.4.1 Organizing pieces with variables
    - 3.4.2 Adding titles
    - 3.4.3 Absolute note names
    - 3.4.4 After the tutorial
- 4 Fundamental concepts
  - 4.1 How LilyPond input files work
    - 4.1.1 Introduction to the LilyPond file structure
    - 4.1.2 A score is a (single) compound musical expression
    - 4.1.3 Nesting music expressions
    - 4.1.4 Structure of a note entry
    - 4.1.5 On the un-nestedness of brackets and ties
  - 4.2 Voices contain music
    - 4.2.1 I’m hearing voices
    - 4.2.2 Explicitly instantiating voices
    - 4.2.3 Voices and vocals
  - 4.3 Contexts and engravers
    - 4.3.1 Contexts explained
    - 4.3.2 Creating contexts
    - 4.3.3 Engravers explained
    - 4.3.4 Modifying context properties
    - 4.3.5 Adding and removing engravers
  - 4.4 Extending the templates
    - 4.4.1 Soprano and cello
    - 4.4.2 Four-part SATB vocal score
    - 4.4.3 Building a score from scratch
    - 4.4.4 Saving typing with variables and functions
    - 4.4.5 Scores and parts
- 5 Tweaking output
  - 5.1 Tweaking basics
    - 5.1.1 Objects and interfaces
    - 5.1.2 Naming conventions of objects and properties
    - 5.1.3 Tweaking methods
      - The `\override` command
      - The `\revert` command
      - The `\once` prefix
      - The `\tweak` and `\offset` commands
      - The `\single` prefix
  - 5.2 The Internals Reference manual
    - 5.2.1 Properties of layout objects
    - 5.2.2 Properties found in interfaces
    - 5.2.3 Types of properties
  - 5.3 Appearance of objects
    - 5.3.1 Visibility and color of objects
      - The `stencil` property
      - The `break-visibility` property
      - The `transparent` property
      - The `color` property
    - 5.3.2 Size of objects
    - 5.3.3 Length and thickness of objects
  - 5.4 Offsets and alignments
  - 5.5 Placement of objects
    - 5.5.1 Automatic behavior
    - 5.5.2 Within-staff objects
      - The `direction` property
      - Fingering
    - 5.5.3 Outside-staff objects
      - The `outside-staff-priority` property
      - The `\textLengthOn` command
      - Dynamics placement
      - Grob sizing
  - 5.6 Vertical spacing
  - 5.7 Collisions of objects
    - 5.7.1 Moving objects
    - 5.7.2 Fixing overlapping notation
      - The `padding` property
      - The `right-padding` property
      - The `staff-padding` property
      - The `self-alignment-X` property
      - The `staff-position` property
      - The `extra-offset` property
      - The `positions` property
      - The `force-hshift` property
    - 5.7.3 Real music example
  - 5.8 Further tweaking
    - 5.8.1 Other uses for tweaks
      - Tying notes across voices
      - Simulating a fermata in MIDI
    - 5.8.2 Using variables for layout adjustments
    - 5.8.3 Style sheets
    - 5.8.4 Other sources of information
    - 5.8.5 Advanced tweaks with Scheme
- Appendix A Templates
  - A.1 Built-in templates
    - A.1.1 SATB template
    - A.1.2 SSAATTBB template
  - A.2 Single staff templates
    - A.2.1 Notes only
    - A.2.2 Notes and lyrics
    - A.2.3 Notes and chords
    - A.2.4 Notes, lyrics, and chords
  - A.3 Piano templates
    - A.3.1 Solo piano
    - A.3.2 Piano and melody with lyrics
    - A.3.3 Piano-centered lyrics
  - A.4 String quartet templates
    - A.4.1 String quartet
    - A.4.2 String quartet parts
  - A.5 Vocal ensembles templates
    - A.5.1 SATB vocal score
    - A.5.2 SATB vocal score and automatic piano reduction
    - A.5.3 SATB with aligned contexts
    - A.5.4 SATB on four staves
    - A.5.5 Solo verse and two-part refrain
    - A.5.6 Hymn tunes
    - A.5.7 Psalms
  - A.6 Orchestral templates
    - A.6.1 Orchestra, choir and piano
  - A.7 Ancient notation templates
    - A.7.1 Transcription of mensural music
    - A.7.2 Gregorian transcription template
  - A.8 Other templates
    - A.8.1 Jazz combo
- Appendix B GNU Free Documentation License
- Appendix C Index