1 @c -*- coding: utf-8; mode: texinfo; -*-
3 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5 When revising a translation, copy the HEAD committish of the
6 version that you are working on. See TRANSLATION for details.
11 @node Simultaneous notes
12 @section Simultaneous notes
14 @lilypondfile[quote]{simultaneous-headword.ly}
16 Polyphony in music refers to having more than one voice occurring
17 in a piece of music. Polyphony in LilyPond refers to having more
18 than one voice on the same staff.
27 @subsection Single voice
35 @subsubsection Chorded notes
38 @cindex brackets, angle
43 A chord is formed by a enclosing a set of pitches between @code{<} and
44 @code{>}. A chord may be followed by a duration and/or a set of
45 articulations, just like simple notes:
47 @lilypond[verbatim,quote,relative=1]
48 <c e g>2 <c f a>4-> <e g c>-.
51 For more information about chords, see @ref{Chord notation}.
59 @rlearning{Combining notes into chords}.
65 @rlsr{Simultaneous notes}.
69 For some reason, music expressions like @code{<< @{ g8 e8 @} a4 >>}
70 that should automatically turn into chords, appear splitted in two
71 staves. To avoid this, use explicit chords instead as in
76 @subsubsection Clusters
79 @funindex \makeClusters
81 A cluster indicates a continuous range of pitches to be played. They
82 can be denoted as the envelope of a set of notes. They are entered by
83 applying the function @code{\makeClusters} to a sequence of chords,
86 @lilypond[quote,relative=2,verbatim]
87 \makeClusters { <g b>2 <c g'> }
90 Ordinary notes and clusters can be put together in the same staff,
91 even simultaneously. In such a case no attempt is made to
92 automatically avoid collisions between ordinary notes and clusters.
100 @rlsr{Simultaneous notes}.
103 @rinternals{ClusterSpanner},
104 @rinternals{ClusterSpannerBeacon},
105 @rinternals{Cluster_spanner_engraver}.
107 @c Examples: @rlsr{contemporary,cluster@/.ly}.
111 Clusters only look good if they span at least two chords; otherwise
112 they appear too narrow.
114 Clusters do not have a stem and can not indicate durations by
115 themselves. Separate clusters would need a separating rest between
118 @node Multiple voices
119 @subsection Multiple voices
122 * Collision resolution::
123 * Automatic part combining::
124 * Writing music in parallel::
127 @node Collision resolution
128 @subsubsection Collision resolution
130 @cindex merging notes
131 @cindex note collisions
137 @cindex shift rest, automatic
139 Note heads with equal durations are automatically merged, while
140 note heads with unequal durations are not merged. Rests opposite
141 a stem are shifted vertically.
143 @c old material to delete, I think. -gp
144 @c Normally, equal note heads with the same number of dots and the same
145 @c note head are automatically merged, while note heads with different note
146 @c heads and/or a different number of dots are not.
147 @c The following example
148 @c has two cases of this, plus an undesired merging (the half-note head
149 @c @code{e} is solid):
150 @c Note that LilyPond has vertically shifted the rest, which is opposite
153 @lilypond[quote,verbatim,relative=2]
169 Note heads with different note heads may be merged:
170 @c First we will merge the initial half note head with the eighth
171 @c note by setting the @code{merge-differently-headed} property of the
172 @c @code{NoteCollision} object:
174 @lilypond[quote,verbatim,relative=2]
177 \override Staff.NoteCollision #'merge-differently-headed = ##t
191 Note heads with different dots may be merged:
192 @c Similarly, you can merge differently dotted note heads:
194 @lilypond[quote,relative=2,verbatim]
197 \override Staff.NoteCollision #'merge-differently-headed = ##t
198 \override Staff.NoteCollision #'merge-differently-dotted = ##t
214 The collision on the second measure happens because
215 @code{merge-differently-headed} cannot successfully complete the merge
216 when three or more notes line up in the same column (in fact, you will
217 obtain a warning for this reason). To allow the merge to work
218 properly, apply a @code{\shift} to the note that should not be merged.
219 Here, @code{\shiftOn} is applied to move the top @code{g} out of the
220 column, and @code{merge-differently-headed} works properly.
222 @lilypond[quote,relative=2,verbatim]
225 \override Staff.NoteCollision #'merge-differently-headed = ##t
226 \override Staff.NoteCollision #'merge-differently-dotted = ##t
241 Merging notes by setting @code{merge-differently-headed} and
242 @code{merge-differently-dotted} only works for opposing stem
243 directions (i.e., to @code{Voice}s 1 and 2).
245 @cindex multiple voices
246 @cindex polyphonic music
247 @cindex shifting voices
249 In some instances of complex polyphonic music, you may need
250 additional voices to avoid collisions between notes. Additional
251 voices are added by defining an variable, as shown below:
253 @lilypond[quote,verbatim]
254 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
257 { \voiceOne g2. ~ \stemDown g32[ f( es d c b a b64) g] } \\
258 { \voiceThree b4 } \\
273 @funindex \voiceThree
278 @c undocumented?: --FV
279 @funindex \voiceNeutralStyle
280 @funindex \voiceOneStyle
281 @funindex \voiceTwoStyle
282 @funindex \voiceThreeStyle
283 @funindex \voiceFourStyle
299 @code{\shiftOff}: these commands specify the degree to which
300 chords of the current voice should be shifted. The outer voices
301 (normally: voices one and two) have @code{\shiftOff}, while the
302 inner voices (three and four) have @code{\shiftOn}.
303 @code{\shiftOnn} and @code{\shiftOnnn} define further shift
306 When LilyPond cannot cope, the @code{force-hshift} property of the
307 @code{NoteColumn} object and pitched rests can be used to
308 override typesetting decisions.
310 @lilypond[quote,verbatim,relative=1]
316 \once \override NoteColumn #'force-hshift = #1.7
328 @rlearning{Multiple notes at once},
329 @rlearning{Voices contain music},
330 @rlearning{Collisions of objects}.
333 @rlsr{Simultaneous notes}.
336 @rinternals{NoteColumn}.
337 The objects responsible for resolving collisions
339 @rinternals{NoteCollision} and
340 @rinternals{RestCollision}.
345 When using @code{merge-differently-headed} with an upstem eighth or a
346 shorter note, and a downstem half note, the eighth note stem gets a
347 slightly wrong offset because of the different width of the half note
350 @c investigate! Sometimes it works, sometimes not. --FV
351 It is not clear in which circumpstances you can succesfully merge
352 different note heads that are at the same time differently dotted.
354 There is no support for clusters where the same note occurs with
355 different accidentals in the same chord. In this case, it is
356 recommended to use enharmonic transcription, or to use special
357 cluster notation (see @ref{Clusters}).
360 @node Automatic part combining
361 @subsubsection Automatic part combining
363 @cindex automatic part combining
364 @cindex part combiner
365 @cindex combining parts
366 @funindex \partcombine
368 Automatic part combining is used to merge two parts of music onto a
369 staff. It is aimed at typesetting orchestral scores. When the two
370 parts are identical for a period of time, only one is shown. In
371 places where the two parts differ, they are typeset as separate
372 voices, and stem directions are set automatically. Also, solo and
373 @notation{a due} parts are identified and marked by default.
375 The syntax for part combining is:
378 \partcombine @var{musicexpr1} @var{musicexpr2}
381 The following example demonstrates the basic functionality of the part
382 combiner: putting parts on one staff and setting stem directions and
383 polyphony. The same variables are used for the independent
384 parts and the combined staff.
386 @lilypond[quote,verbatim]
387 instrumentOne = \relative c' {
395 instrumentTwo = \relative g' {
404 \new Staff \instrumentOne
405 \new Staff \instrumentTwo
406 \new Staff \partcombine \instrumentOne \instrumentTwo
410 The notes in the third measure appear only once, although they were
411 specified in both parts. Stem, slur, and tie directions are set
412 automatically, depending whether there is a solo or unison. When
413 needed in polyphony situations, the first part (with context called
414 @code{one}) always gets up stems, while the second (called @code{two})
415 always gets down stems. In solo situations, the parts get marked with
416 @q{Solo} and @q{Solo II}, respectively. The unisono (@notation{a due})
417 parts are marked by default with the text @qq{a2}.
419 Both arguments to @code{\partcombine} will be interpreted as
420 @code{Voice} contexts. If using relative octaves,
421 @code{\relative} should be specified for both music expressions,
426 \relative @dots{} @var{musicexpr1}
427 \relative @dots{} @var{musicexpr2}
431 A @code{\relative} section that is outside of @code{\partcombine}
432 has no effect on the pitches of @var{musicexpr1} and
437 Parts may be merged without printing text:
439 @lilypond[quote,verbatim]
441 \set Staff.printPartCombineTexts = ##f
443 \relative g' { g a( b) r }
444 \relative g' { g r4 r f }
448 The printed text may be changed:
450 @lilypond[quote,verbatim]
452 \set Score.soloText = #"girl"
453 \set Score.soloIIText = #"boy"
454 \set Score.aDueText = #"together"
456 \relative g' { g4 g r r a2 g }
457 \relative g' { r4 r a( b) a2 g }
472 @rlsr{Simultaneous notes}.
476 @rinternals{PartCombineMusic},
481 When @code{printPartCombineTexts} is set, if the two voices play
482 the same notes on and off, the part combiner may typeset @code{a2}
483 more than once in a measure.
485 @code{\partcombine} cannot be inside @code{\times}.
487 @code{\partcombine} cannot be inside @code{\relative}.
489 Internally, the @code{\partcombine} interprets both arguments as
490 @code{Voice}s named @code{one} and @code{two}, and then decides
491 when the parts can be combined. Consequently, if the arguments
492 switch to differently named @rinternals{Voice} contexts, the
493 events in those will be ignored.
495 @c IIRC in users list someone pointed out more issues. FV
497 @node Writing music in parallel
498 @subsubsection Writing music in parallel
500 @cindex Writing music in parallel
501 @cindex Interleaved music
502 @funindex parallelMusic
504 Music for multiple parts can be interleaved in input code. The
505 function @code{\parallelMusic} accepts a list with the names of a
506 number of variables to be created, and a musical expression. The
507 content of alternate measures from the expression become the value of
508 the respective variables, so you can use them afterwards to print the
511 @warning{Bar checks @code{|} must be used, and the measures must
512 be of the same length.}
514 @lilypond[quote,verbatim]
515 \parallelMusic #'(voiceA voiceB) {
517 r8 g'16[ c''] e''[ g' c'' e''] r8 g'16[ c''] e''[ g' c'' e''] |
521 r8 a'16[ d''] f''[ a' d'' f''] r8 a'16[ d''] f''[ a' d'' f''] |
530 Relative mode may be used. Note that the @code{\relative} command
531 is not used inside @code{\parallelMusic} itself. The notes are
532 relative to the preceding note in the voice, not to the previous
533 note in the input -- in other words, relative notes for
534 @code{voiceA} ignore the notes in @code{voiceB}.
536 @lilypond[quote,verbatim]
537 \parallelMusic #'(voiceA voiceB) {
539 r8 g16 c e g, c e r8 g,16 c e g, c e |
543 r8 a,16 d f a, d f r8 a,16 d f a, d f |
547 \new Staff \relative c'' \voiceA
548 \new Staff \relative c' \voiceB
552 This works quite well for piano music. This example maps four
553 consecutive measures to four variables:
555 @lilypond[quote,verbatim]
561 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
565 c16 d e fis d e fis g |
571 e16 fis g a fis g a b |
582 \relative c'' \voiceA \\
589 \relative c \voiceC \\
600 @rlearning{Organizing pieces with variables}
603 @rlsr{Simultaneous notes}.