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.
12 @node Simultaneous notes
13 @section Simultaneous notes
15 @lilypondfile[quote]{simultaneous-headword.ly}
17 Polyphony in music refers to having more than one voice occurring
18 in a piece of music. Polyphony in LilyPond refers to having more
19 than one voice on the same staff.
28 @subsection Single voice
30 This section discusses simultaneous notes inside the same voice.
39 @unnumberedsubsubsec Chorded notes
42 @cindex brackets, angle
47 A chord is formed by a enclosing a set of pitches between @code{<} and
48 @code{>}. A chord may be followed by a duration and/or a set of
49 articulations, just like simple notes:
51 @lilypond[verbatim,quote,relative=1]
52 <c e g>2 <c f a>4-> <e g c>-.
55 Relative mode can be used for pitches in chords; the preceding pitch
56 into the same chord is still used as a reference for relative pitches,
57 but when a chord is completed, the reference pitch for relative mode
58 is the first note of this chord --not the last note of the chord.
60 For more information about chords, see @ref{Chord notation}.
68 @rlearning{Combining notes into chords}.
74 @rlsr{Simultaneous notes}.
79 For some reason, music expressions like @code{<< @{ g8 e8 @} a4 >>}
80 that should automatically turn into chords, appear split in two
81 staves. To avoid this, use explicit chords instead as in
87 @unnumberedsubsubsec Clusters
90 @funindex \makeClusters
92 A cluster indicates a continuous range of pitches to be played. They
93 can be denoted as the envelope of a set of notes. They are entered by
94 applying the function @code{\makeClusters} to a sequence of chords,
97 @lilypond[quote,relative=2,verbatim]
98 \makeClusters { <g b>2 <c g'> }
101 Ordinary notes and clusters can be put together in the same staff,
102 even simultaneously. In such a case no attempt is made to
103 automatically avoid collisions between ordinary notes and clusters.
111 @rlsr{Simultaneous notes}.
114 @rinternals{ClusterSpanner},
115 @rinternals{ClusterSpannerBeacon},
116 @rinternals{Cluster_spanner_engraver}.
120 Clusters look good only if they span at least two chords; otherwise
121 they appear too narrow.
123 Clusters do not have a stem and cannot indicate durations by
124 themselves. Separate clusters would need a separating rest between
128 @node Multiple voices
129 @subsection Multiple voices
131 This section discusses simultaneous notes in multiple voices or
135 * Single-staff polyphony::
137 * Collision resolution::
138 * Automatic part combining::
139 * Writing music in parallel::
143 @node Single-staff polyphony
144 @unnumberedsubsubsec Single-staff polyphony
146 The basic structure of code needed to achieve multiple, independent
147 voices in a single staff is illustrated in the following example:
149 @lilypond[quote,relative=3,verbatim]
152 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
154 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
158 Here, voices are instantiated explicitly and are given a name. The
159 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices so
160 that first and third voices get stems up, second and fourth voices get
161 stems down, third and fourth voice note heads are horizontally
162 shifted, and rests in the respective voices are automatically moved to
163 avoid collisions. Using the @code{\oneVoice} command, all the voice
164 settings are put back to the neutral directions typical of a
165 single-voice passage.
167 We can make a voice to be into the same @code{Voice} context before
168 and after a temporary polyphonic passage. For example, the following
169 construct keeps a voice alive throughout the polyphonic section. Said
170 voice is the first one inside of the two-voice section, and the extra
171 voice is the second one.
174 << @{ \voiceOne ... @} \new Voice @{ \voiceTwo ... @} >> \oneVoice
177 Using the name given when created, this allows lyrics to be assigned
178 to one consistent voice.
180 @lilypond[quote, verbatim, relative=2]
182 \new Voice = "melody" {
197 \new Lyrics \lyricsto "melody" {
203 Here, the \voiceOne and \voiceTwo commands help to make clear what
204 settings does each voice receive.
206 The @code{<<@{...@} \\ @{...@}>>} construction, where the two (or
207 more) voices are separated by double backslashes, can be used as a
208 simplified method to print multiple voices in a single staff. Our
209 first example could be typeset as follows:
211 @lilypond[quote,relative=3,verbatim]
213 { r8 r16 g e8. f16 g8[ c,] f e16 d }
215 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
219 This syntax is simpler and can be used where it does not matter that
220 temporary voices are created and then discarded. These implicitly
221 created voices are given the settings equivalent to the effect of the
222 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in which
223 they appear in the code. In the following example, the intermediate
224 voice has stems up, therefore we enter it in the third place, so it
225 becomes voice three which has the stems up as desired.
227 @lilypond[quote,relative=3,verbatim]
229 { r8 g g g g f16 es f8 d }
231 { es,8 r es r d r d r }
233 { d'8 s c s bes s a s }
237 Spacing rests are often used to avoid too many rests, as seen in the
240 In all but simplest works it is advisable to create explicit
241 @code{Voice} contexts using the @code{\new} and @code{\context}
242 commands as it is explained in @rlearning{Contexts and engravers} and
243 @rlearning{Explicitly instantiating voices}.
245 In the special case that we want to typeset parallel pieces of music
246 that have the same rhythm, we can combine them into a single
247 @code{Voice} context, thus forming chords. To achieve this, enclose
248 them in a simple simultaneous music construction and make it to be an
251 @lilypond[quote,relative=2,verbatim]
253 { e4 f8 d e16 f g8 d4 }
254 { c4 d8 b c16 d e8 b4 }
258 This method leads to strange beamings and warnings if the pieces of
259 music do not have the same rhythm.
267 @funindex \voiceThree
277 @rlearning{Voices contain music},
278 @rlearning{Explicitly instantiating voices}.
281 @ref{Percussion staves}.
284 @rlsr{Simultaneous notes}.
288 @unnumberedsubsubsec Voice styles
291 @cindex styles, voice
292 @cindex coloring voices
294 Voices may be given distinct colors and shapes, allowing them to be
297 @lilypond[quote,relative=2,verbatim]
299 { \voiceOneStyle d4 c2 b4 }
301 { \voiceTwoStyle e,2 e }
303 { \voiceThreeStyle b2. c4 }
305 { \voiceFourStyle g'2 g }
309 To revert the standard presentation, the @code{\voiceNeutralstyle}
314 @funindex \voiceOneStyle
315 @code{\voiceOneStyle},
316 @funindex \voiceTwoStyle
317 @code{\voiceTwoStyle},
318 @funindex \voiceThreeStyle
319 @code{\voiceThreeStyle},
320 @funindex \voiceFourStyle
321 @code{\voiceFourStyle},
322 @funindex \voiceNeutralStyle
323 @code{\voiceNeutralStyle}.
328 @rlearning{I'm hearing Voices},
329 @rlearning{Other sources of information}.
332 @rlsr{Simultaneous notes}.
335 @node Collision resolution
336 @unnumberedsubsubsec Collision resolution
338 @cindex merging notes
339 @cindex note collisions
345 @cindex shift rest, automatic
347 Note heads with equal durations are automatically merged, while
348 note heads with unequal durations are not merged. Rests opposite
349 a stem are shifted vertically.
351 @lilypond[quote,verbatim,relative=2]
367 Note heads with different note heads may be merged, with the
368 exception of half-note heads and quarter-note heads:
370 @lilypond[quote,verbatim,relative=2]
373 \mergeDifferentlyHeadedOn
387 Note heads with different dots may be merged:
389 @lilypond[quote,relative=2,verbatim]
392 \mergeDifferentlyHeadedOn
393 \mergeDifferentlyDottedOn
409 The collision on the second measure happens because
410 @code{merge-differently-headed} cannot successfully complete the
411 merge when three or more notes line up in the same column -- in
412 fact, you will obtain a warning for this reason. To allow the
413 merge to work properly, apply a @code{\shift} to the note that
414 should not be merged. Here, @code{\shiftOn} is applied to move
415 the top @code{g} out of the column, and
416 @code{merge-differently-headed} works properly.
418 @lilypond[quote,relative=2,verbatim]
421 \mergeDifferentlyHeadedOn
422 \mergeDifferentlyDottedOn
438 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
439 commands specify the degree to which chords of the current voice
440 should be shifted. The outer voices (normally: voices one and
441 two) have @code{\shiftOff}, while the inner voices (three and
442 four) have @code{\shiftOn}. @code{\shiftOnn} and
443 @code{\shiftOnnn} define further shift levels.
445 Notes are only merged if they have opposing stem directions (i.e., in
446 @code{Voice} 1 and 2).
448 @cindex multiple voices
449 @cindex polyphonic music
450 @cindex shifting voices
454 @funindex \mergeDifferentlyDottedOn
455 @code{\mergeDifferentlyDottedOn},
456 @funindex \mergeDifferentlyDottedOff
457 @code{\mergeDifferentlyDottedOff},
458 @funindex \mergeDifferentlyHeadedOn
459 @code{\mergeDifferentlyHeadedOn},
460 @funindex \mergeDifferentlyHeadedOff
461 @code{\mergeDifferentlyHeadedOff}.
474 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
475 {additional-voices-to-avoid-collisions.ly}
477 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
478 {forcing-horizontal-shift-of-notes.ly}
486 @rlearning{Multiple notes at once},
487 @rlearning{Voices contain music},
488 @rlearning{Collisions of objects}.
491 @rlsr{Simultaneous notes}.
494 @rinternals{NoteColumn},
495 @rinternals{NoteCollision},
496 @rinternals{RestCollision}.
500 When using @code{merge-differently-headed} with an upstem eighth
501 or a shorter note, and a downstem half note, the eighth note stem
502 gets a slightly wrong offset because of the different width of the
503 half note head symbol.
505 @c investigate! Sometimes it works, sometimes not. --FV
506 The requirements for successfully merging different note heads that
507 are at the same time differently dotted are not clear.
509 There is no support for chords where the same note occurs with
510 different accidentals in the same chord. In this case, it is
511 recommended to use enharmonic transcription, or to use special
512 cluster notation (see @ref{Clusters}).
515 @node Automatic part combining
516 @unnumberedsubsubsec Automatic part combining
518 @cindex automatic part combining
519 @cindex part combiner
520 @cindex combining parts
521 @funindex \partcombine
523 Automatic part combining is used to merge two parts of music onto
524 a staff. It is aimed at typesetting orchestral scores. When the
525 two parts are identical for a period of time, only one is shown.
526 In places where the two parts differ, they are typeset as separate
527 voices, and stem directions are set automatically. Also, solo and
528 @notation{a due} parts are identified and marked by default.
530 The syntax for part combining is:
533 \partcombine @var{musicexpr1} @var{musicexpr2}
536 The following example demonstrates the basic functionality of the
537 part combiner: putting parts on one staff and setting stem
538 directions and polyphony. The same variables are used for the
539 independent parts and the combined staff.
541 @lilypond[quote,verbatim]
542 instrumentOne = \relative c' {
550 instrumentTwo = \relative g' {
559 \new Staff \instrumentOne
560 \new Staff \instrumentTwo
561 \new Staff \partcombine \instrumentOne \instrumentTwo
565 The notes in the third measure appear only once, although they
566 were specified in both parts. Stem, slur, and tie directions are
567 set automatically, depending whether there is a solo or unison.
568 When needed in polyphony situations, the first part (with context
569 called @code{one}) always gets up stems, while the second (called
570 @code{two}) always gets down stems. In solo situations, the parts
571 get marked with @q{Solo} and @q{Solo II}, respectively. The
572 unisono (@notation{a due}) parts are marked by default with the
575 Both arguments to @code{\partcombine} will be interpreted as
576 @code{Voice} contexts. If using relative octaves,
577 @code{\relative} should be specified for both music expressions,
582 \relative @dots{} @var{musicexpr1}
583 \relative @dots{} @var{musicexpr2}
587 A @code{\relative} section that is outside of @code{\partcombine}
588 has no effect on the pitches of @var{musicexpr1} and
593 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
594 {combining-two-parts-on-the-same-staff.ly}
596 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
597 {changing-partcombine-texts.ly}
609 @rlsr{Simultaneous notes}.
612 @rinternals{PartCombineMusic},
617 When @code{printPartCombineTexts} is set, if the two voices play
618 the same notes on and off, the part combiner may typeset @code{a2}
619 more than once in a measure.
621 @code{\partcombine} cannot be inside @code{\times}.
623 @code{\partcombine} cannot be inside @code{\relative}.
625 Internally, the @code{\partcombine} interprets both arguments as
626 @code{Voice}s named @code{one} and @code{two}, and then decides
627 when the parts can be combined. Consequently, if the arguments
628 switch to differently named @rinternals{Voice} contexts, the
629 events in those will be ignored.
631 @c IIRC in users list someone pointed out more issues. TODO: lookup FV
634 @node Writing music in parallel
635 @unnumberedsubsubsec Writing music in parallel
637 @cindex Writing music in parallel
638 @cindex Interleaved music
639 @funindex parallelMusic
641 Music for multiple parts can be interleaved in input code. The
642 function @code{\parallelMusic} accepts a list with the names of a
643 number of variables to be created, and a musical expression. The
644 content of alternate measures from the expression become the value
645 of the respective variables, so you can use them afterwards to
648 @warning{Bar checks @code{|} must be used, and the measures must
649 be of the same length.}
651 @lilypond[quote,verbatim]
652 \parallelMusic #'(voiceA voiceB voiceC) {
654 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
655 r16 e'8.~ e'4 r16 e'8.~ e'4 |
659 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
660 r16 d'8.~ d'4 r16 d'8.~ d'4 |
665 \new Staff << \voiceA \\ \voiceB >>
666 \new Staff { \clef bass \voiceC }
670 Relative mode may be used. Note that the @code{\relative} command
671 is not used inside @code{\parallelMusic} itself. The notes are
672 relative to the preceding note in the voice, not to the previous
673 note in the input -- in other words, relative notes for
674 @code{voiceA} ignore the notes in @code{voiceB}.
676 @lilypond[quote,verbatim]
677 \parallelMusic #'(voiceA voiceB voiceC) {
679 r8 g16 c e g, c e r8 g,16 c e g, c e |
680 r16 e8.~ e4 r16 e8.~ e4 |
684 r8 a,16 d f a, d f r8 a,16 d f a, d f |
685 r16 d8.~ d4 r16 d8.~ d4 |
690 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
691 \new Staff \relative c' { \clef bass \voiceC }
695 This works quite well for piano music. This example maps four
696 consecutive measures to four variables:
698 @lilypond[quote,verbatim]
704 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
708 c16 d e fis d e fis g |
714 e16 fis g a fis g a b |
725 \relative c'' \voiceA
745 @rlearning{Organizing pieces with variables}.
748 @rlsr{Simultaneous notes}.