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 octave of each
57 pitch is chosen using the preceding pitch as a reference except in the
58 case of the first pitch in a chord: the reference for the first pitch is
59 the @emph{first} pitch of the preceding 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
130 Clusters do not produce MIDI output.
132 @node Multiple voices
133 @subsection Multiple voices
135 This section discusses simultaneous notes in multiple voices or
139 * Single-staff polyphony::
141 * Collision resolution::
142 * Automatic part combining::
143 * Writing music in parallel::
147 @node Single-staff polyphony
148 @unnumberedsubsubsec Single-staff polyphony
150 @cindex single-staff polyphony
151 @cindex polyphony, single-staff
153 @cindex lyrics assigned to one voice
156 @funindex \voiceOne ... \voiceFour
161 The basic structure of code needed to achieve multiple, independent
162 voices in a single staff is illustrated in the following example:
164 @lilypond[quote,relative=3,verbatim]
167 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
169 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
173 Here, voices are instantiated explicitly and are given a name. The
174 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices so
175 that first and third voices get stems up, second and fourth voices get
176 stems down, third and fourth voice note heads are horizontally
177 shifted, and rests in the respective voices are automatically moved to
178 avoid collisions. Using the @code{\oneVoice} command, all the voice
179 settings are put back to the neutral directions typical of a
180 single-voice passage.
182 We can make a voice to be in the same @code{Voice} context before
183 and after a temporary polyphonic passage. For example, the following
184 construct keeps a voice alive throughout the polyphonic section. Said
185 voice is the first one inside of the two-voice section, and the extra
186 voice is the second one.
189 << @{ \voiceOne ... @} \new Voice @{ \voiceTwo ... @} >> \oneVoice
192 Using the name given when created, this allows lyrics to be assigned
193 to one consistent voice.
195 @lilypond[quote, verbatim, relative=2]
197 \new Voice = "melody" {
212 \new Lyrics \lyricsto "melody" {
218 Here, the @code{\voiceOne} and @code{\voiceTwo} commands help to make clear what
219 settings does each voice receive.
221 The @code{<<@{...@} \\ @{...@}>>} construction, where the two (or
222 more) voices are separated by double backslashes, can be used as a
223 simplified method to print multiple voices in a single staff. Our
224 first example could be typeset as follows:
226 @lilypond[quote,relative=3,verbatim]
228 { r8 r16 g e8. f16 g8[ c,] f e16 d }
230 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
234 This syntax is simpler and can be used where it does not matter that
235 temporary voices are created and then discarded. These implicitly
236 created voices are given the settings equivalent to the effect of the
237 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in which
238 they appear in the code. In the following example, the intermediate
239 voice has stems up, therefore we enter it in the third place, so it
240 becomes voice three which has the stems up as desired.
242 @lilypond[quote,relative=3,verbatim]
244 { r8 g g g g f16 es f8 d }
246 { es,8 r es r d r d r }
248 { d'8 s c s bes s a s }
253 Spacer rests are often used to avoid having too many rests, as seen in the
256 In all but simplest works it is advisable to create explicit
257 @code{Voice} contexts using the @code{\new} and @code{\context}
258 commands as it is explained in @rlearning{Contexts and engravers} and
259 @rlearning{Explicitly instantiating voices}.
261 In the special case that we want to typeset parallel pieces of music
262 that have the same rhythm, we can combine them into a single
263 @code{Voice} context, thus forming chords. To achieve this, enclose
264 them in a simple simultaneous music construction and make it to be an
267 @lilypond[quote,relative=2,verbatim]
269 { e4 f8 d e16 f g8 d4 }
270 { c4 d8 b c16 d e8 b4 }
274 This method leads to strange beamings and warnings if the pieces of
275 music do not have the same rhythm.
288 @rlearning{Voices contain music},
289 @rlearning{Explicitly instantiating voices}.
292 @ref{Percussion staves},
293 @ref{Invisible rests}.
296 @rlsr{Simultaneous notes}.
300 @unnumberedsubsubsec Voice styles
303 @cindex styles, voice
304 @cindex coloring voices
305 @funindex \voiceOneStyle
306 @funindex \voiceTwoStyle
307 @funindex \voiceThreeStyle
308 @funindex \voiceFourStyle
309 @funindex \voiceNeutralStyle
311 Voices may be given distinct colors and shapes, allowing them to be
314 @lilypond[quote,relative=2,verbatim]
316 { \voiceOneStyle d4 c2 b4 }
318 { \voiceTwoStyle e,2 e }
320 { \voiceThreeStyle b2. c4 }
322 { \voiceFourStyle g'2 g }
326 To revert the standard presentation, the @code{\voiceNeutralstyle}
332 @code{\voiceOneStyle},
334 @code{\voiceTwoStyle},
335 @code{\voiceThreeStyle},
336 @code{\voiceFourStyle},
337 @code{\voiceNeutralStyle}.
342 @rlearning{I'm hearing Voices},
343 @rlearning{Other sources of information}.
346 @rlsr{Simultaneous notes}.
349 @node Collision resolution
350 @unnumberedsubsubsec Collision resolution
352 @cindex merging notes
353 @cindex note collisions
356 @cindex multiple voices
357 @cindex voices, multiple
358 @cindex polyphonic music
359 @cindex shifting voices
360 @cindex voices, multiple
361 @cindex shift rest, automatic
370 @funindex \mergeDifferentlyDottedOn
371 @funindex mergeDifferentlyDottedOn
372 @funindex \mergeDifferentlyDottedOff
373 @funindex mergeDifferentlyDottedOff
374 @funindex \mergeDifferentlyHeadedOn
375 @funindex mergeDifferentlyHeadedOn
376 @funindex \mergeDifferentlyHeadedOff
377 @funindex mergeDifferentlyHeadedOff
379 Note heads with equal durations are automatically merged, while
380 note heads with unequal durations are not merged. Rests opposite
381 a stem are shifted vertically.
383 @lilypond[quote,verbatim,relative=2]
399 Note heads with different note heads may be merged, with the
400 exception of half-note heads and quarter-note heads:
402 @lilypond[quote,verbatim,relative=2]
405 \mergeDifferentlyHeadedOn
419 Note heads with different dots may be merged:
421 @lilypond[quote,relative=2,verbatim]
424 \mergeDifferentlyHeadedOn
425 \mergeDifferentlyDottedOn
440 The collision on the second measure happens because
441 @code{\mergeDifferentlyHeadedOn} cannot successfully complete the
442 merge when three or more notes line up in the same column -- in
443 fact, you will obtain a warning for this reason. To allow the
444 merge to work properly, apply a @code{\shift} to the note that
445 should not be merged. Here, @code{\shiftOn} is applied to move
446 the top @code{g} out of the column, and
447 @code{\mergeDifferentlyHeadedOn} works properly.
449 @lilypond[quote,relative=2,verbatim]
452 \mergeDifferentlyHeadedOn
453 \mergeDifferentlyDottedOn
469 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
470 commands specify the degree to which chords of the current voice
471 should be shifted. The outer voices (normally: voices one and
472 two) have @code{\shiftOff}, while the inner voices (three and
473 four) have @code{\shiftOn}. @code{\shiftOnn} and
474 @code{\shiftOnnn} define further shift levels.
476 Notes are only merged if they have opposing stem directions (e.g. in
477 @code{Voice} 1 and 2).
482 @code{\mergeDifferentlyDottedOn},
483 @code{\mergeDifferentlyDottedOff},
484 @code{\mergeDifferentlyHeadedOn},
485 @code{\mergeDifferentlyHeadedOff}.
494 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
495 {additional-voices-to-avoid-collisions.ly}
497 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
498 {forcing-horizontal-shift-of-notes.ly}
506 @rlearning{Multiple notes at once},
507 @rlearning{Voices contain music},
508 @rlearning{Collisions of objects}.
511 @rlsr{Simultaneous notes}.
514 @rinternals{NoteColumn},
515 @rinternals{NoteCollision},
516 @rinternals{RestCollision}.
520 When using @code{\mergeDifferentlyHeadedOn} with an upstem eighth
521 or a shorter note, and a downstem half note, the eighth note stem
522 gets a slightly wrong offset because of the different width of the
523 half note head symbol.
525 @c investigate! Sometimes it works, sometimes not. --FV
526 The requirements for successfully merging different note heads that
527 are at the same time differently dotted are not clear.
529 There is no support for chords where the same note occurs with
530 different accidentals in the same chord. In this case, it is
531 recommended to use enharmonic transcription, or to use special
532 cluster notation (see @ref{Clusters}).
535 @node Automatic part combining
536 @unnumberedsubsubsec Automatic part combining
538 @cindex automatic part combining
539 @cindex part combiner
540 @cindex combining parts
543 @funindex \partcombine
544 @funindex partcombine
546 Automatic part combining is used to merge two parts of music onto
547 a staff. It is aimed at typesetting orchestral scores. When the
548 two parts are identical for a period of time, only one is shown.
549 In places where the two parts differ, they are typeset as separate
550 voices, and stem directions are set automatically. Also, solo and
551 @notation{a due} parts are identified and marked by default.
553 The syntax for part combining is:
556 \partcombine @var{musicexpr1} @var{musicexpr2}
559 The following example demonstrates the basic functionality of the
560 part combiner: putting parts on one staff and setting stem
561 directions and polyphony. The same variables are used for the
562 independent parts and the combined staff.
564 @lilypond[quote,verbatim]
565 instrumentOne = \relative c' {
573 instrumentTwo = \relative g' {
582 \new Staff \instrumentOne
583 \new Staff \instrumentTwo
584 \new Staff \partcombine \instrumentOne \instrumentTwo
588 The notes in the third measure appear only once, although they were
589 specified in both parts. Stem, slur, and tie directions are set
590 automatically, depending whether there is a solo or unison. When
591 needed in polyphony situations, the first part (with context called
592 @code{one}) always gets up stems, while the second (called @code{two})
593 always gets down stems. In solo situations, the first and second
594 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
595 unisono (@notation{a due}) parts are marked by default with the text
598 Both arguments to @code{\partcombine} will be interpreted as
599 @code{Voice} contexts. If using relative octaves,
600 @code{\relative} should be specified for both music expressions,
605 \relative @dots{} @var{musicexpr1}
606 \relative @dots{} @var{musicexpr2}
610 A @code{\relative} section that is outside of @code{\partcombine}
611 has no effect on the pitches of @var{musicexpr1} and
616 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
617 {combining-two-parts-on-the-same-staff.ly}
619 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
620 {changing-partcombine-texts.ly}
632 @rlsr{Simultaneous notes}.
635 @rinternals{PartCombineMusic},
640 @code{\partcombine} can only accept two voices.
642 When @code{printPartCombineTexts} is set, if the two voices play
643 the same notes on and off, the part combiner may typeset @code{a2}
644 more than once in a measure.
646 @code{\partcombine} cannot be inside @code{\times}.
648 @code{\partcombine} cannot be inside @code{\relative}.
650 Internally, the @code{\partcombine} interprets both arguments as
651 @code{Voice}s and decides when the parts can be combined. When they have
652 different durations they cannot be combined and are given the names
653 @code{one} and @code{two}. Consequently, if the arguments switch to
654 differently named @rinternals{Voice} contexts, the events in those will
655 be ignored. Likewise, partcombining isn't designed to work with lyrics;
656 when one of the voices is explicitly named in order to attach lyrics to
657 it, the partcombining stops working.
659 @code{\partcombine} only observes onset times of notes. It cannot
660 determine whether a previously started note is playing or not, leading
664 @node Writing music in parallel
665 @unnumberedsubsubsec Writing music in parallel
667 @cindex writing music in parallel
668 @cindex interleaved music
669 @cindex parallel music
670 @funindex \parallelMusic
671 @funindex parallelMusic
673 Music for multiple parts can be interleaved in input code. The
674 function @code{\parallelMusic} accepts a list with the names of a
675 number of variables to be created, and a musical expression. The
676 content of alternate measures from the expression become the value
677 of the respective variables, so you can use them afterwards to
680 @warning{Bar checks @code{|} must be used, and the measures must
681 be of the same length.}
683 @lilypond[quote,verbatim]
684 \parallelMusic #'(voiceA voiceB voiceC) {
686 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
687 r16 e'8.~ e'4 r16 e'8.~ e'4 |
691 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
692 r16 d'8.~ d'4 r16 d'8.~ d'4 |
697 \new Staff << \voiceA \\ \voiceB >>
698 \new Staff { \clef bass \voiceC }
702 Relative mode may be used. Note that the @code{\relative} command
703 is not used inside @code{\parallelMusic} itself. The notes are
704 relative to the preceding note in the voice, not to the previous
705 note in the input -- in other words, relative notes for
706 @code{voiceA} ignore the notes in @code{voiceB}.
708 @lilypond[quote,verbatim]
709 \parallelMusic #'(voiceA voiceB voiceC) {
711 r8 g16 c e g, c e r8 g,16 c e g, c e |
712 r16 e8.~ e4 r16 e8.~ e4 |
716 r8 a,16 d f a, d f r8 a,16 d f a, d f |
717 r16 d8.~ d4 r16 d8.~ d4 |
722 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
723 \new Staff \relative c' { \clef bass \voiceC }
727 This works quite well for piano music. This example maps four
728 consecutive measures to four variables:
730 @lilypond[quote,verbatim]
736 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
740 c16 d e fis d e fis g |
746 e16 fis g a fis g a b |
757 \relative c'' \voiceA
777 @rlearning{Organizing pieces with variables}.
780 @rlsr{Simultaneous notes}.