4.2.2 Explicitly instantiating voices

Voice contexts can also be created manually inside a << >> block to create polyphonic music, using \voiceOne\voiceFour to indicate the required directions of stems, slurs, etc. In longer scores this method is clearer, as it permits the voices to be separated and to be given more descriptive names.

Specifically, the construct << \\ >> which we used in the previous section:

\new Staff {
  \relative {
    << { e'4 f g a } \\ { c,4 d e f } >>
  }
}

is equivalent to

\new Staff <<
  \new Voice = "1" { \voiceOne \relative { e'4 f g a } }
  \new Voice = "2" { \voiceTwo \relative { c'4 d e f } }
>>

Both of the above would produce

[image of music]

The \voiceXXX commands set the direction of stems, slurs, ties, articulations, text annotations, augmentation dots of dotted notes, and fingerings. \voiceOne and \voiceThree make these objects point upwards, while \voiceTwo and \voiceFour make them point downwards. These commands also generate a horizontal shift for each voice when this is required to avoid clashes of note heads. The command \oneVoice reverts the settings back to the normal values for a single voice.

Let us see in some simple examples exactly what effect \oneVoice, \voiceOne and voiceTwo have on markup, ties, slurs, and dynamics:

\relative {
  % Default behavior or behavior after \oneVoice
  c'4 d8~ 8 e4( f | g4 a) b-> c |
}

[image of music]

\relative {
  \voiceOne
  c'4 d8~ 8 e4( f | g4 a) b-> c |
  \oneVoice
  c,4 d8~ 8 e4( f | g4 a) b-> c |
}

[image of music]

\relative {
  \voiceTwo
  c'4 d8~ 8 e4( f | g4 a) b-> c |
  \oneVoice
  c,4 d8~ 8 e4( f | g4 a) b-> c |
}

[image of music]

Now let’s look at four different ways to notate the same passage of polyphonic music, each of which is advantageous in different circumstances, using the example from the previous section.

An expression that appears directly inside a << >> belongs to the main voice (but, note, not in a << \\ >> construct). This is useful when extra voices appear while the main voice is playing. Here is a more correct rendition of our example. The red diamond-shaped notes demonstrate that the main melody is now in a single voice context, permitting a phrasing slur to be drawn over them.

\new Staff \relative {
  \voiceOneStyle
  % This section is homophonic
  c'16^( d e f
  % Start simultaneous section of three voices
  <<
    % Continue the main voice in parallel
    { g4 f e | d2 e) | }
    % Initiate second voice
    \new Voice {
      % Set stems, etc., down
      \voiceTwo
      r8 e4 d c8~ | 8 b16 a b8 g~ 2 |
    }
    % Initiate third voice
    \new Voice {
      % Set stems, etc, up
      \voiceThree
      s2. | s4 b c2 |
    }
  >>
}

[image of music]

The \voices command can also be used for continuing a main voice into the simultaneous construct:

\new Staff \relative {
  \new Voice = "main" {
    \voiceOneStyle
    % This section is homophonic
    c'16^( d e f
    % Start simultaneous section of three voices
    \voices "main",2,3
    <<
      % Continue the main voice in parallel
      { g4 f e | d2 e) | }
      % Initiate second voice
    \\
      % Set stems, etc., down
      { r8 e4 d c8~ | 8 b16 a b8 g~ 2 | }
    \\
      % Initiate third voice
      % Set stems, etc, up
      { s2. | s4 b c2 | }
    >>
  }
}

[image of music]

More deeply nested polyphony constructs are possible, and if a voice appears only briefly this might be a more natural way to typeset the music:

\new Staff \relative {
  c'16^( d e f
  <<
    { g4 f e | d2 e) | }
    \new Voice {
      \voiceTwo
      r8 e4 d c8~ |
      <<
        { c8 b16 a b8 g~ 2 | }
        \new Voice {
          \voiceThree
          s4 b c2 |
        }
      >>
    }
  >>
}

[image of music]

This method of nesting new voices briefly is useful when only small sections of the music are polyphonic, but when the whole staff is largely polyphonic it can be clearer to use multiple voices throughout, using spacing notes to step over sections where the voice is silent, as here:

\new Staff \relative <<
  % Initiate first voice
  \new Voice {
    \voiceOne
    c'16^( d e f g4 f e | d2 e) |
  }
  % Initiate second voice
  \new Voice {
    % Set stems, etc, down
    \voiceTwo
    s4 r8 e4 d c8~ | 8 b16 a b8 g~ 2 |
  }
  % Initiate third voice
  \new Voice {
    % Set stems, etc, up
    \voiceThree
    s1 | s4 b c2 |
  }
>>

[image of music]

Note columns

Closely spaced notes in a chord, or notes occurring at the same time in different voices, are arranged in two, occasionally more, columns to prevent the note heads overlapping. These are called note columns. There are separate columns for each voice, and the currently specified voice-dependent shift is applied to the note column if there would otherwise be a collision. This can be seen in the example above. In bar 2 the C in voice two is shifted to the right relative to the D in voice one, and in the final chord the C in voice three is also shifted to the right relative to the other notes.

The \shiftOn, \shiftOnn, \shiftOnnn, and \shiftOff commands specify the degree to which notes and chords of the voice should be shifted if a collision would otherwise occur. By default, the outer voices (normally voices one and two) have \shiftOff specified, while the inner voices (three and four) have \shiftOn specified. When a shift is applied, voices one and three are shifted to the right and voices two and four to the left.

\shiftOnn and \shiftOnnn define further shift levels which may be specified temporarily to resolve collisions in complex situations – see Real music example.

A note column can contain just one note (or chord) from a voice with stems up and one note (or chord) from a voice with stems down. If notes from two voices which have their stems in the same direction are placed at the same position and both voices have no shift or the same shift specified, the error message “This voice needs a voiceXx or shiftXx setting” will be produced.

See also

Learning Manual: Moving objects.

Notation Reference: Multiple voices.


LilyPond — Learning Manual v2.24.4 (stable-branch).