Up: Polyphony



5.4.1 Writing polyphonic music

The easiest way to enter fragments with more than one voice on a staff is to split chords using the separator \\. You can use it for small, short-lived voices or for single chords

     \context Staff \relative c'' {
       c4 << { f d e } \\ { b c2 } >>
       c4 << g' \\ b, \\ f' \\ d >>
     }

[image of music]

The separator causes Voice (lilypond-internals) contexts1 to be instantiated. They bear the names "1", "2", etc. In each of these contexts, vertical direction of slurs, stems, etc., is set appropriately. Specifically,

<< \upper \\ \lower >>

is equivalent to

<<
  \context Voice = "1" { \voiceOne \upper }
  \context Voice = "2" { \voiceTwo \lower }
>>

This can also be done by instantiating Voice (lilypond-internals) contexts by hand, and using \voiceOne, up to \voiceFour to assign a stem directions and horizontal shift for each part

     \relative c''
     \context Staff <<
       \new Voice { \voiceOne cis2 b }
       \new Voice { \voiceThree b4 ais ~ ais4 gis4 }
       \new Voice { \voiceTwo fis4~ fis4 f ~ f } >>

[image of music]

The command \oneVoice will revert back to the normal setting. Defining voices (either with the separator \\ or with \voiceXXX) will set the direction of stems, slurs, ties, articulations, text annotations, augmentation dots of dotted notes, and fingerings. \voiceOne makes these objects point upwards, while \voiceTwo makes them point down.

Normally, note heads with a different number of dots are not merged, but when the object property merge-differently-dotted is set in the NoteCollision (lilypond-internals) object, they are merged

     \context Voice << {
       g8 g8
       \override Staff.NoteCollision
         #'merge-differently-dotted = ##t
       g8 g8
     } \\ { g8.[ f16] g8.[ f16] } >>

[image of music]

Similarly, you can merge half note heads with eighth notes, by setting merge-differently-headed

     \context Voice << {
       c8 c4.
       \override Staff.NoteCollision
         #'merge-differently-headed = ##t
     c8 c4. } \\ { c2 c2 } >>

[image of music]

LilyPond also vertically shifts rests that are opposite of a stem, for example

     \context Voice << c''4 \\ r4 >>

[image of music]

Predefined commands

\oneVoice, \voiceOne, \voiceTwo, \voiceThree, \voiceFour.

\shiftOn, \shiftOnn, \shiftOnnn, \shiftOff: these commands specify in what chords of the current voice should be shifted. The outer voices (normally: voice one and two) have \shiftOff, while the inner voices (three and four) have \shiftOn. \shiftOnn and \shiftOnnn define further shift levels.

When LilyPond cannot cope, the force-hshift property of the NoteColumn (lilypond-internals) object and pitched rests can be used to override typesetting decisions.

     \relative <<
     {
       <d g>
       <d g>
     } \\ {
       <b f'>
       \once \override NoteColumn #'force-hshift = #1.7
       <b f'>
     } >>

[image of music]

See also

Program reference: the objects responsible for resolving collisions are NoteCollision (lilypond-internals) and RestCollision (lilypond-internals) .

Examples: input/regression/collision-dots.ly, input/regression/collision-head-chords.ly, input/regression/collision-heads.ly, input/regression/collision-mesh.ly, and input/regression/collisions.ly.

Bugs

When using merge-differently-headed with an upstem eighth or a shorter note, and a downstem half note, the eighth note gets the wrong offset.

There is no support for clusters where the same note occurs with different accidentals in the same chord. In this case, it is recommended to use enharmonic transcription, or to use special cluster notation (see Clusters).


Footnotes

[1] Polyphonic voices are sometimes called “layers” in other notation packages


Read comments on this page, or add one.

This page is for LilyPond-2.5.11 (development-branch).

Report errors to <bug-lilypond@gnu.org>.

Other languages: English.
Using automatic language selection.