LilyPond snippets: Simultaneous notes

# Simultaneous notes

These snippets illustrate the Notation Reference, section Simultaneous notes.

## Additional voices to avoid collisions

In some instances of complex polyphonic music, additional voices are necessary to prevent collisions between notes. If more than four parallel voices are needed, additional voices can be added by defining a variable using the Scheme function `context-spec-music`.

    voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
    \relative c'' {
      \time 3/4 \key d \minor \partial 2
      <<
        { \voiceOne
          a4. a8
          e'4 e4. e8
          f4 d4. c8
        } \\ {
          \voiceThree
          f,2
          bes4 a2
          a4 s2
        } \\ {
          \voiceFive
          s2
          g4 g2
          f4 f2
        } \\ {
          \voiceTwo
          d2
          d4 cis2
          d4 bes2
        }
      >>
    }

## Changing a single note’s size in a chord

Individual note heads in a chord can be modified with the `\tweak` command inside a chord, by altering the `font-size` property.

Inside the chord (within the brackets `< >`), before the note to be altered, place the `\tweak` command, followed by `#'font-size` and define the proper size like `#-2` (a tiny notehead).

    \relative {
      <\tweak #'font-size #+2 c e g c \tweak #'font-size #-2 e>1^\markup { A tiny e }_\markup { A big c }
    }

## Changing partcombine texts

When using the automatic part combining feature, the printed text for the solo and unison sections may be changed:

    \new Staff <<
      \set Staff.soloText = #"girl"
      \set Staff.soloIIText = #"boy"
      \set Staff.aDueText = #"together"
      \partcombine
        \relative c'' {
          g4 g r r
          a2 g
        }
        \relative c'' {
          r4 r a( b)
          a2 g
        }
    >>

## Clusters

Clusters are a device to denote that a complete range of notes is to be played.

    fragment = \relative c' {
      c4 f <e d'>4
      <g a>8 <e a> a4 c2 <d b>4
      e2 c
    }

    <<
      \new Staff \fragment
      \new Staff \makeClusters \fragment
    >>

## Combining two parts on the same staff

The part combiner tool ( `\partcombine` command ) allows the combination of several different parts on the same staff. Text directions such as "solo" or "a2" are added by default; to remove them, simply set the property `printPartCombineTexts` to "false". For vocal scores (hymns), there is no need to add "solo"/"a2" texts, so they should be switched off. However, it might be better not to use it if there are any solos, as they won’t be indicated. In such cases, standard polyphonic notation may be preferable.

This snippet presents the three ways two parts can be printed on a same staff: standard polyphony, `\partcombine` without texts, and `\partcombine` with texts.

    musicUp = \relative c'' {
      \time 4/4
      a4 c4.( g8) a4 |
      g4 e' g,( a8 b) |
      c b a2.
    }

    musicDown = \relative c'' {
      g4 e4.( d8) c4 |
      r2 g'4( f8 e) |
      d2 \stemDown a
    }

    \score {
      <<
        <<
        \new Staff {
          \set Staff.instrumentName = "Standard polyphony  "
          << \musicUp \\ \musicDown >>
        }
        \new Staff \with { printPartCombineTexts = ##f } {
          \set Staff.instrumentName = "PartCombine without texts  "
          \partcombine \musicUp \musicDown
        }
        \new Staff {
          \set Staff.instrumentName = "PartCombine with texts  "
          \partcombine \musicUp \musicDown
        }
        >>
      >>
      \layout {
        indent = 6.0\cm
        \context {
          \Score
          \override SystemStartBar #'collapse-height = #30
        }
      }
    }

## Displaying complex chords

Here is a way to display a chord where the same note is played twice with different accidentals.

    fixA = {
      \once \override Stem #'length = #9
      \once \override Accidental #'extra-offset = #'(0.3 . 0)
    }
    fixB = {
      \once \override NoteHead #'extra-offset = #'(1.7 . 0)
      \once \override Stem #'rotation = #'(45 0 0)
      \once \override Stem #'extra-offset = #'(-0.2 . -0.2)
      \once \override Stem #'flag-style = #'no-flag
      \once \override Accidental #'extra-offset = #'(3.1 . 0)
    }

    \relative c' {
      << { \fixA <b d!>8 } \\ { \voiceThree \fixB dis } >> s
    }

## Double glissando

To connect chords with glissando lines, attach a second glissando to a hidden voice.

    \relative c {
      \clef bass
      <<
        {
          % new voice ( = \voiceOne), hidden
          \hideNotes
          % attach glissando to note heads
          e2\glissando g
        }
        \\
        {
          % original voice with chords rearranged so that
          % glissando is attached to a & c
          <e a,>2\glissando <g c,>
        }
      >>
    }

## Forcing horizontal shift of notes

When the typesetting engine cannot cope, the following syntax can be used to override typesetting decisions. The units of measure used here are staff spaces.

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

## Making an object invisible with the ’transparent property

Setting the `transparent` property will cause an object to be printed in "invisible ink": the object is not printed, but all its other behavior is retained. The object still takes up space, it takes part in collisions, and slurs, ties and beams can be attached to it.

This snippet demonstrates how to connect different voices using ties. Normally, ties only connect two notes in the same voice. By introducing a tie in a different voice, and blanking the first up-stem in that voice, the tie appears to cross voices.

    \relative c'' {
      \time 2/4
      <<
        {
          \once \override Stem #'transparent = ##t
          \once \override Stem #'length = #8
          b8 ~ b\noBeam
          \once \override Stem #'transparent = ##t
          \once \override Stem #'length = #8
          g8 ~ g\noBeam
        }
        \\
        {
          b8 g g e
        }
      >>
    }

## Suppressing warnings for clashing note columns

If notes from two voices with 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 "warning: ignoring too many clashing note columns" will appear when compiling the LilyPond file. This message can be suppressed by setting the `'ignore-collision` property of the `NoteColumn` object to `#t`.

    ignore = \override NoteColumn #'ignore-collision = ##t

    \relative c' {
      <<
        \ignore
        { \stemDown f2 g }
        \\
        { c2 c, }
      >>
    }

#### Snippets List