[icon]

GNU LilyPond

Welcome to the home of the GNU Music Typesetter

What is LilyPond
General information
Simple examples
Complex examples
Download
GNU/Linux binaries
Windows
Source code
Documentation
Tutorial
Manual
Glossary
other ...

Support
Mailing lists
Search
WikiWiki
FAQs

External sites
lilypond.org/development
lilypond.org/stable
ftp.lilypond.org
Mutopia
Other music online

Node:Polyphony, Next:, Previous:Staff notation, Up:Reference Manual



Polyphony

Polyphonic parts, i.e. parts with more than one voice on a staff can be typeset with LilyPond.

The easiest way to enter such fragments, is the Scheme function voicify-music. It will split chords using the separator \\, to make multiple voices. You can use it for small, short-lived voices (make a chord of voices) or for single chords:

\context Voice = VA \apply #voicify-music \relative c'' {
 c4 < { f d e  } \\ { b c2 } > c4 < g' \\ c, \\  f \\ d >
}

[picture of music]

The function voicify-music instantiates Voice

contexts, bearing the names "1", "2", etc.

To explicity typeset polyphonic music, instantiate a separate Voice context for each part, and assign a stem direction to each part.

\context Staff
< \context Voice = VA { \stemUp b'4 a' g' f' e' }
  \context Voice = VB { \stemDown g'4 g' g' g' g' } >

[picture of music]

When there are more than two voices on a staff, you must also indicate which voice should moved horizontally in case of a collision. This can be done with the identifiers \shiftOff, \shiftOn, \shiftOnn, etc. (which sets the grob property horizontal-shift in NoteColumn ).

  \context Staff \notes\relative c''<
       \context Voice=one {
       \shiftOff \stemUp e4
       }
       \context Voice=two {
          \shiftOn \stemUp cis
       }
       \context Voice=three {
         \shiftOnn \stemUp ais
       }
       \context Voice=four {
          \shiftOnnn \stemUp fis
       }
  >

[picture of music]

The most convenient way is to use the identifiers \voiceOne through \voiceFour, which also set slur and tie directions in the correct manner.

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

[picture of music]

Normally, note heads with a different number of dots are not merged, but if you set the grob property merge-differently-dotted, they are:

  \context Staff <
  \context Voice = VA { \voiceOne
     g'8 g'8
     \property Staff.NoteCollision \override #'merge-differently-dotted = ##t
     g'8 g'8
  }
  \context Voice = VB { \voiceTwo [g'8. f16] [g'8. f'16] }
  >

[picture of music]

LilyPond also vertically shifts rests that are opposite of a stem.

\context Staff <
\context Voice {  \stemUp c''4  }
\context Voice =VB { r4 }
>

[picture of music]

Note head collisions (horizontal shifting of note heads) are handled by the NoteCollision grob. RestCollision

handles vertical shifting of rests.

BUGS

Resolving collisions is a very intricate subject, and LilyPond only handles a few situations. When it can not cope, you are advised to use force-hshift of the NoteColumn grob and staff-position of the Rest grob to override typesetting decisions.

Go back to index of LilyPond.

Please send GNU LilyPond questions and comments to lilypond-user@gnu.org.

Please send comments on these web pages to lilypond@packages.debian.org

Copyright (c) 1997--2001 Han-Wen Nienhuys and Jan Nieuwenhuizen.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.


This page was built from LilyPond-1.4.12 (stable-branch) by

Anthony Fok <lilypond@packages.debian.org>, Tue Mar 12 01:35:39 2002 HKT.