Single-staff polyphony

Explicitly instantiating voices

The basic structure needed to achieve multiple independent voices in a single staff is illustrated in the following example:

\new Staff <<
  \new Voice = "first"
    \relative { \voiceOne r8 r16 g'' e8. f16 g8[ c,] f e16 d }
  \new Voice= "second"
    \relative { \voiceTwo d''16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
>>

[image of music]

Here, voices are instantiated explicitly and are given names. The \voiceOne\voiceFour commands set up the voices so that first and third voices get stems up, second and fourth voices get stems down, third and fourth voice note heads are horizontally shifted, and rests in the respective voices are automatically moved to avoid collisions. The \oneVoice command returns all the voice settings to the neutral default directions.

Note that Voice is a bottom-level context (see Bottom-level contexts – voices). In TabStaff one would use TabVoice instead.

Temporary polyphonic passages

A temporary polyphonic passage can be created with the following construct:

<< { \voiceOne … }
  \new Voice { \voiceTwo … }
>> \oneVoice

Here, the first expression within a temporary polyphonic passage is placed into the Voice context which was in use immediately before the polyphonic passage, and that same Voice context continues after the temporary section. Other expressions within the angle brackets are assigned to distinct temporary voices. This allows lyrics to be assigned to one continuing voice before, during and after a polyphonic section:

\relative <<
  \new Voice = "melody" {
    a'4
    <<
      {
        \voiceOne
        g f
      }
      \new Voice {
        \voiceTwo
        d2
      }
    >>
    \oneVoice
    e4
  }
  \new Lyrics \lyricsto "melody" {
  This is my song.
  }
>>

[image of music]

Here, the \voiceOne and \voiceTwo commands are required to define the settings of each voice.

In TabStaff one needs to use TabVoice.

If the same music should appear in Staff and TabStaff the general Bottom context may be used (see Bottom-level contexts – voices).

mus =
\relative
  \new Bottom = "melody" {
    a'4
    <<
      {
        \voiceOne
        g f
      }
      \new Bottom {
        \voiceTwo
        d2
      }
    >>
    \oneVoice
    e4
  }

<<
  \new Staff \mus
  \new Lyrics \lyricsto "melody" {
    This is my song.
  }
>>

<<
  \new TabStaff \mus
  \new Lyrics \lyricsto "melody" {
    This is my song.
  }
>>

[image of music]

The double backslash construct

The << {…} \\ {…} >> construct, where the two (or more) expressions are separated by double backslashes, behaves differently to the similar construct without the double backslashes: all the expressions within this construct are assigned to new Bottom contexts of the current type, typically Voice or TabVoice (see Bottom-level contexts – voices). These new Bottom contexts are created implicitly and are given the fixed names "1", "2", etc.

The first example could be typeset as follows:

<<
  \relative { r8 r16 g'' e8. f16 g8[ c,] f e16 d }
  \\
  \relative { d''16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
>>

[image of music]

This syntax can be used where it does not matter that temporary voices are created and then discarded. These implicitly created voices are given the settings equivalent to the effect of the \voiceOne\voiceFour commands, in the order in which they appear in the code.

In the following example, the intermediate voice has stems up, therefore we enter it in the third place, so it becomes voice three, which has the stems up as desired. Spacer rests are used to avoid printing doubled rests.

<<
  \relative { r8 g'' g g g f16 ees f8 d }
  \\
  \relative { ees'8 r ees r d r d r }
  \\
  \relative { d''8 s c s bes s a s }
>>

[image of music]

In all but the simplest works it is advisable to create explicit Voice contexts as explained in Contexts and engravers and Explicitly instantiating voices.

Voice order

When entering multiple voices in the input file, use the following order:

Voice 1: highest
Voice 2: lowest
Voice 3: second highest
Voice 4: second lowest
Voice 5: third highest
Voice 6: third lowest
etc.

Though this may seem counterintuitive, it simplifies the automatic layout process. Note that the odd-numbered voices are given up-stems, and the even-numbered voices are given down-stems:

\new Staff <<
  \time 2/4
  { f''2 }  % 1: highest
  \\
  { c'2  }  % 2: lowest
  \\
  { d''2 }  % 3: second-highest
  \\
  { e'2  }  % 4: second-lowest
  \\
  { b'2  }  % 5: third-highest
  \\
  { g'2  }  % 6: third-lowest
>>

[image of music]

When a different voice entry order is desired, the command \voices may be convenient:

\new Staff \voices 1,3,5,6,4,2 <<
  \time 2/4
  { f''2 }  % 1: highest
  \\
  { d''2 }  % 3: second-highest
  \\
  { b'2  }  % 5: third-highest
  \\
  { g'2  }  % 6: third-lowest
  \\
  { e'2  }  % 4: second-lowest
  \\
  { c'2  }  % 2: lowest
>>

[image of music]

Note: Lyrics and spanners (such as slurs, ties, hairpins, etc.) cannot be created ‘across’ voices.

Identical rhythms

In the special case that we want to typeset parallel pieces of music that have the same rhythm, we can combine them into a single Voice context, thus forming chords. To achieve this, enclose them in a simple simultaneous music construct within an explicit voice:

\new Voice <<
  \relative { e''4 f8 d e16 f g8 d4 }
  \relative { c''4 d8 b c16 d e8 b4 }
>>

[image of music]

This method leads to strange beamings and warnings if the pieces of music do not have the same rhythm.

Predefined commands

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

See also

Learning Manual: Voices contain music, Explicitly instantiating voices.

Notation Reference: Percussion staves, Invisible rests, Stems.

Snippets: Simultaneous notes.


LilyPond Notation Reference v2.25.20 (development-branch).