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
43 @cindex relative pitch in chords
48 A chord is formed by a enclosing a set of pitches between @code{<} and
49 @code{>}. A chord may be followed by a duration and/or a set of
50 articulations, just like simple notes:
52 @lilypond[verbatim,quote,relative=1]
53 <c e g>2 <c f a>4-> <e g c>-.
56 Relative mode can be used for pitches in chords; the preceding pitch
57 into the same chord is still used as a reference for relative pitches,
58 but when a chord is completed, the reference pitch for relative mode
59 is the first note of this chord --not the last note of the chord.
61 For more information about chords, see @ref{Chord notation}.
69 @rlearning{Combining notes into chords}.
75 @rlsr{Simultaneous notes}.
80 For some reason, music expressions like @code{<< @{ g8 e8 @} a4 >>}
81 that should automatically turn into chords, appear split in two
82 staves. To avoid this, use explicit chords instead as in
88 @unnumberedsubsubsec Clusters
92 @funindex \makeClusters
93 @funindex makeClusters
95 A cluster indicates a continuous range of pitches to be played. They
96 can be denoted as the envelope of a set of notes. They are entered by
97 applying the function @code{\makeClusters} to a sequence of chords,
100 @lilypond[quote,relative=2,verbatim]
101 \makeClusters { <g b>2 <c g'> }
104 Ordinary notes and clusters can be put together in the same staff,
105 even simultaneously. In such a case no attempt is made to
106 automatically avoid collisions between ordinary notes and clusters.
114 @rlsr{Simultaneous notes}.
117 @rinternals{ClusterSpanner},
118 @rinternals{ClusterSpannerBeacon},
119 @rinternals{Cluster_spanner_engraver}.
123 Clusters look good only if they span at least two chords; otherwise
124 they appear too narrow.
126 Clusters do not have a stem and cannot indicate durations by
127 themselves. Separate clusters would need a separating rest between
131 @node Multiple voices
132 @subsection Multiple voices
134 This section discusses simultaneous notes in multiple voices or
138 * Single-staff polyphony::
140 * Collision resolution::
141 * Automatic part combining::
142 * Writing music in parallel::
146 @node Single-staff polyphony
147 @unnumberedsubsubsec Single-staff polyphony
149 @cindex single-staff polyphony
150 @cindex polyphony, single-staff
152 @cindex lyrics assigned to one voice
155 @funindex \voiceOne ... \voiceFour
160 The basic structure of code needed to achieve multiple, independent
161 voices in a single staff is illustrated in the following example:
163 @lilypond[quote,relative=3,verbatim]
166 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
168 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
172 Here, voices are instantiated explicitly and are given a name. The
173 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices so
174 that first and third voices get stems up, second and fourth voices get
175 stems down, third and fourth voice note heads are horizontally
176 shifted, and rests in the respective voices are automatically moved to
177 avoid collisions. Using the @code{\oneVoice} command, all the voice
178 settings are put back to the neutral directions typical of a
179 single-voice passage.
181 We can make a voice to be in the same @code{Voice} context before
182 and after a temporary polyphonic passage. For example, the following
183 construct keeps a voice alive throughout the polyphonic section. Said
184 voice is the first one inside of the two-voice section, and the extra
185 voice is the second one.
188 << @{ \voiceOne ... @} \new Voice @{ \voiceTwo ... @} >> \oneVoice
191 Using the name given when created, this allows lyrics to be assigned
192 to one consistent voice.
194 @lilypond[quote, verbatim, relative=2]
196 \new Voice = "melody" {
211 \new Lyrics \lyricsto "melody" {
217 Here, the @code{\voiceOne} and @code{\voiceTwo} commands help to make clear what
218 settings does each voice receive.
220 The @code{<<@{...@} \\ @{...@}>>} construction, where the two (or
221 more) voices are separated by double backslashes, can be used as a
222 simplified method to print multiple voices in a single staff. Our
223 first example could be typeset as follows:
225 @lilypond[quote,relative=3,verbatim]
227 { r8 r16 g e8. f16 g8[ c,] f e16 d }
229 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
233 This syntax is simpler and can be used where it does not matter that
234 temporary voices are created and then discarded. These implicitly
235 created voices are given the settings equivalent to the effect of the
236 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in which
237 they appear in the code. In the following example, the intermediate
238 voice has stems up, therefore we enter it in the third place, so it
239 becomes voice three which has the stems up as desired.
241 @lilypond[quote,relative=3,verbatim]
243 { r8 g g g g f16 es f8 d }
245 { es,8 r es r d r d r }
247 { d'8 s c s bes s a s }
251 Spacer rests are often used to avoid too many rests, as seen in the
254 In all but simplest works it is advisable to create explicit
255 @code{Voice} contexts using the @code{\new} and @code{\context}
256 commands as it is explained in @rlearning{Contexts and engravers} and
257 @rlearning{Explicitly instantiating voices}.
259 In the special case that we want to typeset parallel pieces of music
260 that have the same rhythm, we can combine them into a single
261 @code{Voice} context, thus forming chords. To achieve this, enclose
262 them in a simple simultaneous music construction and make it to be an
265 @lilypond[quote,relative=2,verbatim]
267 { e4 f8 d e16 f g8 d4 }
268 { c4 d8 b c16 d e8 b4 }
272 This method leads to strange beamings and warnings if the pieces of
273 music do not have the same rhythm.
286 @rlearning{Voices contain music},
287 @rlearning{Explicitly instantiating voices}.
290 @ref{Percussion staves},
291 @ref{Invisible rests}.
294 @rlsr{Simultaneous notes}.
298 @unnumberedsubsubsec Voice styles
301 @cindex styles, voice
302 @cindex coloring voices
303 @funindex \voiceOneStyle
304 @funindex \voiceTwoStyle
305 @funindex \voiceThreeStyle
306 @funindex \voiceFourStyle
307 @funindex \voiceNeutralStyle
309 Voices may be given distinct colors and shapes, allowing them to be
312 @lilypond[quote,relative=2,verbatim]
314 { \voiceOneStyle d4 c2 b4 }
316 { \voiceTwoStyle e,2 e }
318 { \voiceThreeStyle b2. c4 }
320 { \voiceFourStyle g'2 g }
324 To revert the standard presentation, the @code{\voiceNeutralstyle}
330 @code{\voiceOneStyle},
332 @code{\voiceTwoStyle},
333 @code{\voiceThreeStyle},
334 @code{\voiceFourStyle},
335 @code{\voiceNeutralStyle}.
340 @rlearning{I'm hearing Voices},
341 @rlearning{Other sources of information}.
344 @rlsr{Simultaneous notes}.
347 @node Collision resolution
348 @unnumberedsubsubsec Collision resolution
350 @cindex merging notes
351 @cindex note collisions
354 @cindex multiple voices
355 @cindex voices, multiple
356 @cindex polyphonic music
357 @cindex shifting voices
358 @cindex voices, multiple
359 @cindex shift rest, automatic
368 @funindex \mergeDifferentlyDottedOn
369 @funindex mergeDifferentlyDottedOn
370 @funindex \mergeDifferentlyDottedOff
371 @funindex mergeDifferentlyDottedOff
372 @funindex \mergeDifferentlyHeadedOn
373 @funindex mergeDifferentlyHeadedOn
374 @funindex \mergeDifferentlyHeadedOff
375 @funindex mergeDifferentlyHeadedOff
377 Note heads with equal durations are automatically merged, while
378 note heads with unequal durations are not merged. Rests opposite
379 a stem are shifted vertically.
381 @lilypond[quote,verbatim,relative=2]
397 Note heads with different note heads may be merged, with the
398 exception of half-note heads and quarter-note heads:
400 @lilypond[quote,verbatim,relative=2]
403 \mergeDifferentlyHeadedOn
417 Note heads with different dots may be merged:
419 @lilypond[quote,relative=2,verbatim]
422 \mergeDifferentlyHeadedOn
423 \mergeDifferentlyDottedOn
438 The collision on the second measure happens because
439 @code{\mergeDifferentlyHeadedOn} cannot successfully complete the
440 merge when three or more notes line up in the same column -- in
441 fact, you will obtain a warning for this reason. To allow the
442 merge to work properly, apply a @code{\shift} to the note that
443 should not be merged. Here, @code{\shiftOn} is applied to move
444 the top @code{g} out of the column, and
445 @code{\mergeDifferentlyHeadedOn} works properly.
447 @lilypond[quote,relative=2,verbatim]
450 \mergeDifferentlyHeadedOn
451 \mergeDifferentlyDottedOn
467 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
468 commands specify the degree to which chords of the current voice
469 should be shifted. The outer voices (normally: voices one and
470 two) have @code{\shiftOff}, while the inner voices (three and
471 four) have @code{\shiftOn}. @code{\shiftOnn} and
472 @code{\shiftOnnn} define further shift levels.
474 Notes are only merged if they have opposing stem directions (i.e., in
475 @code{Voice} 1 and 2).
480 @code{\mergeDifferentlyDottedOn},
481 @code{\mergeDifferentlyDottedOff},
482 @code{\mergeDifferentlyHeadedOn},
483 @code{\mergeDifferentlyHeadedOff}.
492 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
493 {additional-voices-to-avoid-collisions.ly}
495 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
496 {forcing-horizontal-shift-of-notes.ly}
504 @rlearning{Multiple notes at once},
505 @rlearning{Voices contain music},
506 @rlearning{Collisions of objects}.
509 @rlsr{Simultaneous notes}.
512 @rinternals{NoteColumn},
513 @rinternals{NoteCollision},
514 @rinternals{RestCollision}.
518 When using @code{\mergeDifferentlyHeadedOn} with an upstem eighth
519 or a shorter note, and a downstem half note, the eighth note stem
520 gets a slightly wrong offset because of the different width of the
521 half note head symbol.
523 @c investigate! Sometimes it works, sometimes not. --FV
524 The requirements for successfully merging different note heads that
525 are at the same time differently dotted are not clear.
527 There is no support for chords where the same note occurs with
528 different accidentals in the same chord. In this case, it is
529 recommended to use enharmonic transcription, or to use special
530 cluster notation (see @ref{Clusters}).
533 @node Automatic part combining
534 @unnumberedsubsubsec Automatic part combining
536 @cindex automatic part combining
537 @cindex part combiner
538 @cindex combining parts
541 @funindex \partcombine
542 @funindex partcombine
544 Automatic part combining is used to merge two parts of music onto
545 a staff. It is aimed at typesetting orchestral scores. When the
546 two parts are identical for a period of time, only one is shown.
547 In places where the two parts differ, they are typeset as separate
548 voices, and stem directions are set automatically. Also, solo and
549 @notation{a due} parts are identified and marked by default.
551 The syntax for part combining is:
554 \partcombine @var{musicexpr1} @var{musicexpr2}
557 The following example demonstrates the basic functionality of the
558 part combiner: putting parts on one staff and setting stem
559 directions and polyphony. The same variables are used for the
560 independent parts and the combined staff.
562 @lilypond[quote,verbatim]
563 instrumentOne = \relative c' {
571 instrumentTwo = \relative g' {
580 \new Staff \instrumentOne
581 \new Staff \instrumentTwo
582 \new Staff \partcombine \instrumentOne \instrumentTwo
586 The notes in the third measure appear only once, although they were
587 specified in both parts. Stem, slur, and tie directions are set
588 automatically, depending whether there is a solo or unison. When
589 needed in polyphony situations, the first part (with context called
590 @code{one}) always gets up stems, while the second (called @code{two})
591 always gets down stems. In solo situations, the first and second
592 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
593 unisono (@notation{a due}) parts are marked by default with the text
596 Both arguments to @code{\partcombine} will be interpreted as
597 @code{Voice} contexts. If using relative octaves,
598 @code{\relative} should be specified for both music expressions,
603 \relative @dots{} @var{musicexpr1}
604 \relative @dots{} @var{musicexpr2}
608 A @code{\relative} section that is outside of @code{\partcombine}
609 has no effect on the pitches of @var{musicexpr1} and
614 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
615 {combining-two-parts-on-the-same-staff.ly}
617 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
618 {changing-partcombine-texts.ly}
630 @rlsr{Simultaneous notes}.
633 @rinternals{PartCombineMusic},
638 When @code{printPartCombineTexts} is set, if the two voices play
639 the same notes on and off, the part combiner may typeset @code{a2}
640 more than once in a measure.
642 @code{\partcombine} cannot be inside @code{\times}.
644 @code{\partcombine} cannot be inside @code{\relative}.
646 Internally, the @code{\partcombine} interprets both arguments as
647 @code{Voice}s named @code{one} and @code{two}, and then decides
648 when the parts can be combined. Consequently, if the arguments
649 switch to differently named @rinternals{Voice} contexts, the
650 events in those will be ignored.
652 @c IIRC in users list someone pointed out more issues. TODO: lookup FV
655 @node Writing music in parallel
656 @unnumberedsubsubsec Writing music in parallel
658 @cindex writing music in parallel
659 @cindex interleaved music
660 @cindex parallel music
661 @funindex \parallelMusic
662 @funindex parallelMusic
664 Music for multiple parts can be interleaved in input code. The
665 function @code{\parallelMusic} accepts a list with the names of a
666 number of variables to be created, and a musical expression. The
667 content of alternate measures from the expression become the value
668 of the respective variables, so you can use them afterwards to
671 @warning{Bar checks @code{|} must be used, and the measures must
672 be of the same length.}
674 @lilypond[quote,verbatim]
675 \parallelMusic #'(voiceA voiceB voiceC) {
677 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
678 r16 e'8.~ e'4 r16 e'8.~ e'4 |
682 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
683 r16 d'8.~ d'4 r16 d'8.~ d'4 |
688 \new Staff << \voiceA \\ \voiceB >>
689 \new Staff { \clef bass \voiceC }
693 Relative mode may be used. Note that the @code{\relative} command
694 is not used inside @code{\parallelMusic} itself. The notes are
695 relative to the preceding note in the voice, not to the previous
696 note in the input -- in other words, relative notes for
697 @code{voiceA} ignore the notes in @code{voiceB}.
699 @lilypond[quote,verbatim]
700 \parallelMusic #'(voiceA voiceB voiceC) {
702 r8 g16 c e g, c e r8 g,16 c e g, c e |
703 r16 e8.~ e4 r16 e8.~ e4 |
707 r8 a,16 d f a, d f r8 a,16 d f a, d f |
708 r16 d8.~ d4 r16 d8.~ d4 |
713 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
714 \new Staff \relative c' { \clef bass \voiceC }
718 This works quite well for piano music. This example maps four
719 consecutive measures to four variables:
721 @lilypond[quote,verbatim]
727 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
731 c16 d e fis d e fis g |
737 e16 fis g a fis g a b |
748 \relative c'' \voiceA
768 @rlearning{Organizing pieces with variables}.
771 @rlsr{Simultaneous notes}.