1 @c -*- coding: utf-8; mode: texinfo; -*-
3 @node Simultaneous notes
4 @section Simultaneous notes
6 Polyphony in music refers to having more than one voice occurring in
7 a piece of music. Polyphony in LilyPond refers to having more than
8 one voice on the same staff.
17 @subsection Single voice
25 @unnumberedsubsubsec Chords
29 A chord is formed by a enclosing a set of pitches between @code{<}
30 and @code{>}. A chord may be followed by a duration, and a set of
31 articulations, just like simple notes
33 @lilypond[verbatim,ragged-right,fragment,quote,relative=1]
37 For more information about chords, see @ref{Introducing chord names}.
41 @unnumberedsubsubsec Clusters
45 A cluster indicates a continuous range of pitches to be played. They
46 can be denoted as the envelope of a set of notes. They are entered by
47 applying the function @code{makeClusters} to a sequence of
49 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
50 \makeClusters { <c e > <b f'> }
53 Ordinary notes and clusters can be put together in the same staff,
54 even simultaneously. In such a case no attempt is made to
55 automatically avoid collisions between ordinary notes and clusters.
59 Program reference: @internalsref{ClusterSpanner},
60 @internalsref{ClusterSpannerBeacon},
61 @internalsref{Cluster_spanner_engraver}.
63 Examples: @lsr{contemporary,cluster@/.ly}.
67 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
68 accurately. Use @code{<g a>8 <e a>8} instead.
73 @subsection Multiple voices
77 * Explicitly instantiating voices::
78 * Collision Resolution::
79 * Automatic part combining::
80 * Writing music in parallel::
84 @unnumberedsubsubsec Basic polyphony
88 The easiest way to enter fragments with more than one voice on a staff
89 is to enter each voice as a sequence (with @code{@{...@}}), and combine
90 them simultaneously, separating the voices with @code{\\}
94 @lilypond[quote,verbatim,fragment]
95 \new Staff \relative c' {
99 { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
105 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
106 voices are sometimes called @q{layers} in other notation packages}
108 to be instantiated. They bear the names @code{"1"}, @code{"2"}, etc. In
109 each of these contexts, vertical direction of slurs, stems, etc., is set
112 These voices are all separate from the voice that contains the notes just
113 outside the @code{<< \\ >>} construct. This should be noted when making
114 changes at the voice level. This also means that slurs and ties cannot go
115 into or out of a @code{<< \\ >>} construct. Conversely, parallel voices
116 from separate @code{<< \\ >>} constructs on the same staff are the
117 same voice. Here is the same example, with different noteheads and
119 voice. Note that the change to the note-head style in the main voice does
121 the inside of the @code{<< \\ >>} constructs. Also, the change to the
123 voice in the first @code{<< \\ >>} construct is effective in the second
124 @code{<< \\ >>}, and the voice is tied across the two constructs.
126 @cindex note heads, styles
128 @lilypond[quote,verbatim,fragment]
129 \new Staff \relative c' {
130 \override NoteHead #'style = #'cross
131 \override NoteHead #'color = #red
135 { \override NoteHead #'style = #'triangle
136 \override NoteHead #'color = #blue
141 { c8 b16 a b8 g ~ g2 } \\
142 { \override NoteHead #'style = #'slash
143 \override NoteHead #'color = #green
149 Polyphony does not change the relationship of notes within a
150 @code{\relative @{ @}} block. Each note is calculated relative
151 to the note immediately preceding it.
154 \relative @{ noteA << noteB \\ noteC >> noteD @}
157 @code{noteC} is relative to @code{noteB}, not @code{noteA};
158 @code{noteD} is relative to @code{noteC}, not @code{noteB} or
162 @node Explicitly instantiating voices
163 @unnumberedsubsubsec Explicitly instantiating voices
165 @internalsref{Voice} contexts can also be instantiated manually
166 inside a @code{<< >>} block to create polyphonic music, using
167 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions
168 and a horizontal shift for each part.
172 << \upper \\ \lower >>
180 \new Voice = "1" @{ \voiceOne \upper @}
181 \new Voice = "2" @{ \voiceTwo \lower @}
185 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
186 articulations, text annotations, augmentation dots of dotted
187 notes, and fingerings. @code{\voiceOne} and @code{\voiceThree} make
188 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
189 make them point downwards.
190 The command @code{\oneVoice} will revert back to the normal setting.
192 An expression that appears directly inside a @code{<< >>} belongs to
193 the main voice. This is useful when extra voices appear while the main
194 voice is playing. Here is a more correct rendition of the example from
195 the previous section. The crossed colored noteheads demonstrate that the main
196 melody is now in a single voice context.
198 @lilypond[quote,ragged-right,verbatim]
199 \new Staff \relative c' {
200 \override NoteHead #'style = #'cross
201 \override NoteHead #'color = #red
206 \new Voice="1" { \voiceTwo
207 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
210 \new Voice { \voiceThree
219 The correct definition of the voices allows the melody to be slurred.
220 @lilypond[quote,ragged-right,verbatim]
221 \new Staff \relative c' {
226 \context Voice="1" { \voiceTwo
227 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
230 \new Voice { \voiceThree
239 Avoiding the @code{\\} separator also allows nesting polyphony
240 constructs, which in some case might be a more natural way to typeset
243 @lilypond[quote,ragged-right,verbatim]
244 \new Staff \relative c' {
249 \context Voice="1" { \voiceTwo
253 \new Voice { \voiceThree
265 In some instances of complex polyphonic music, you may need additional
266 voices to avoid collisions between notes. Additional voices are added
267 by defining an identifier, as shown below:
269 @lilypond[quote,verbatim,ragged-right,relative=2]
270 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
273 { \voiceOne g4 ~ \stemDown g32[ f( es d c b a b64 )g] } \\
281 @node Collision Resolution
282 @unnumberedsubsubsec Collision Resolution
284 Normally, note heads with a different number of dots are not merged, but
285 when the object property @code{merge-differently-dotted} is set in
286 the @internalsref{NoteCollision} object, they are merged:
288 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
291 \override Staff.NoteCollision
292 #'merge-differently-dotted = ##t
294 } \\ { g8.[ f16] g8.[ f16] } >>
297 Similarly, you can merge half note heads with eighth notes, by setting
298 @code{merge-differently-headed}:
300 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
303 \override Staff.NoteCollision
304 #'merge-differently-headed = ##t
305 c8 c4. } \\ { c2 c2 } >>
309 @code{merge-differently-headed} and @code{merge-differently-dotted}
310 only apply to opposing stem directions (ie. Voice 1 & 2).
312 LilyPond also vertically shifts rests that are opposite of a stem,
315 @lilypond[quote,ragged-right,fragment,verbatim]
316 \new Voice << c''4 \\ r4 >>
319 If three or more notes line up in the same column,
320 @code{merge-differently-headed} cannot
321 successfully complete the merge of the two notes that should be merged.
322 To allow the merge to work properly, apply a @code{\shift} to the note that
323 should not be merged. In the first measure of following example,
324 @code{merge-differently-headed} does not work (the half-note head is
325 solid). In the second measure, @code{\shiftOn} is applied to move the
326 top @code{g} out of the column, and @code{merge-differently-headed}
329 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
330 \override Staff.NoteCollision #'merge-differently-headed = ##t
333 { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
334 { \voiceFour e,,2 e'2}
337 { d'=''2 \shiftOn g2 } \\
338 { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
339 { \voiceFour e,,2 e'2}
352 @funindex \voiceThree
364 @code{\shiftOff}: these commands specify the
365 degree to which chords of the current voice should be shifted.
366 The outer voices (normally: voice one and
367 two) have @code{\shiftOff}, while the inner voices (three and four)
368 have @code{\shiftOn}. @code{\shiftOnn} and @code{\shiftOnnn} define
369 further shift levels.
371 When LilyPond cannot cope, the @code{force-hshift}
372 property of the @internalsref{NoteColumn} object and pitched rests can
373 be used to override typesetting decisions.
375 @lilypond[quote,verbatim,ragged-right]
382 \once \override NoteColumn #'force-hshift = #1.7
390 Program reference: the objects responsible for resolving collisions are
391 @internalsref{NoteCollision} and @internalsref{RestCollision}.
396 When using @code{merge-differently-headed} with an upstem eighth or a
397 shorter note, and a downstem half note, the eighth note gets the wrong
400 There is no support for clusters where the same note occurs with
401 different accidentals in the same chord. In this case, it is
402 recommended to use enharmonic transcription, or to use special cluster
403 notation (see @ref{Clusters}).
406 @node Automatic part combining
407 @unnumberedsubsubsec Automatic part combining
408 @cindex automatic part combining
409 @cindex part combiner
411 Automatic part combining is used to merge two parts of music onto a
412 staff. It is aimed at typesetting orchestral scores. When the two
413 parts are identical for a period of time, only one is shown. In
414 places where the two parts differ, they are typeset as separate
415 voices, and stem directions are set automatically. Also, solo and
416 @emph{a due} parts are identified and can be marked.
418 The syntax for part combining is
421 \partcombine @var{musicexpr1} @var{musicexpr2}
425 The following example demonstrates the basic functionality of the part
426 combiner: putting parts on one staff, and setting stem directions and
429 @lilypond[quote,verbatim,ragged-right,fragment]
430 \new Staff \partcombine
431 \relative g' { g g a( b) c c r r }
432 \relative g' { g g r4 r e e g g }
435 The first @code{g} appears only once, although it was
436 specified twice (once in each part). Stem, slur, and tie directions are
437 set automatically, depending whether there is a solo or unisono. The
438 first part (with context called @code{one}) always gets up stems, and
439 @q{Solo}, while the second (called @code{two}) always gets down stems and
442 If you just want the merging parts, and not the textual markings, you
443 may set the property @code{printPartCombineTexts} to false
445 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
447 \set Staff.printPartCombineTexts = ##f
449 \relative g' { g a( b) r }
450 \relative g' { g r4 r f }
454 To change the text that is printed for solos or merging, you may
455 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
458 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
460 \set Score.soloText = #"ichi"
461 \set Score.soloIIText = #"ni"
462 \set Score.aDueText = #"tachi"
464 \relative g' { g4 g a( b) r }
465 \relative g' { g4 g r r f }
469 Both arguments to @code{\partcombine} will be interpreted as
470 @internalsref{Voice} contexts. If using relative octaves,
471 @code{\relative} should be specified for both music expressions, i.e.,
475 \relative @dots{} @var{musicexpr1}
476 \relative @dots{} @var{musicexpr2}
480 A @code{\relative} section that is outside of @code{\partcombine} has
481 no effect on the pitches of @var{musicexpr1} and @var{musicexpr2}.
485 Program reference: @internalsref{PartCombineMusic}.
489 When @code{printPartCombineTexts} is set, when the two voices play the
490 same notes on and off, the part combiner may typeset @code{a2} more
491 than once in a measure.
493 @code{\partcombine} cannot be inside @code{\times}.
495 @code{\partcombine} cannot be inside @code{\relative}.
497 Internally, the @code{\partcombine} interprets both arguments as
498 @code{Voice}s named @code{one} and @code{two}, and then decides when
499 the parts can be combined. Consequently, if the arguments switch to
500 differently named @internalsref{Voice} contexts, the events in those
504 @node Writing music in parallel
505 @unnumberedsubsubsec Writing music in parallel
507 @cindex Writing music in parallel
508 @cindex Interleaved music
510 Music for multiple parts can be interleaved
512 @lilypond[quote,fragment,verbatim]
513 \parallelMusic #'(voiceA voiceB) {
514 r8 g'16[ c''] e''[ g' c'' e''] r8 g'16[ c''] e''[ g' c'' e''] |
516 r8 a'16[ d''] f''[ a' d'' f''] r8 a'16[ d''] f''[ a' d'' f''] |
520 \new Staff \new Voice \voiceA
521 \new Staff \new Voice \voiceB
525 This works quite well for piano music
527 @lilypond[quote,verbatim]
531 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
533 r8 g'16[ c''] e''[ g' c'' e''] r8 g'16[ c''] e''[ g' c''
536 r8 a16[ d'] f'[ a d' f'] r8 a16[ d'] f'[ a d' f'] |
540 a'8 b' c'' d'' e'' f'' g'' a'' |
542 c16 d e f d e f g e f g a f g a b |