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. For details, see the Contributors'
7 Guide, node Updating translation committishes..
13 @node Simultaneous notes
14 @section Simultaneous notes
16 @lilypondfile[quote]{simultaneous-headword.ly}
18 Polyphony in music refers to having more than one voice occurring
19 in a piece of music. Polyphony in LilyPond refers to having more
20 than one voice on the same staff.
29 @subsection Single voice
31 This section discusses simultaneous notes inside the same voice.
36 * Simultaneous expressions::
42 @unnumberedsubsubsec Chorded notes
45 @cindex brackets, angle
46 @cindex angle brackets
47 @cindex relative pitch in chords
53 A chord is formed by enclosing a set of pitches between @code{<}
54 and @code{>}. A chord may be followed by a duration and/or a set
55 of articulations, just like simple notes:
57 @lilypond[verbatim,quote,relative=1]
58 <c e g>2 <c f a>4-> <e g c>-.
61 Relative mode can be used for pitches in chords. The octave of each
62 pitch is chosen using the preceding pitch as a reference except in
63 the case of the first pitch in a chord: the reference for the first
64 pitch is the @emph{first} pitch of the preceding chord.
66 For more information about chords, see @ref{Chord notation}.
73 @rlearning{Combining notes into chords}.
79 @rlsr{Simultaneous notes}.
82 @node Chord repetition
83 @unnumberedsubsubsec Chord repetition
85 In order to save typing, a shortcut can be used to repeat the preceding
86 chord. The chord repetition symbol is @code{q}:
88 @lilypond[verbatim,quote,relative=1]
92 As with regular chords, the chord repetition symbol can be used with
93 durations, articulations, markups, slurs, beams, etc. as only the
94 pitches of the previous chord are duplicated.
96 @lilypond[verbatim,quote,relative=1]
97 <c e g>4\p q^"text"( q8)[-| q8.] q16-1-2-3
100 The chord repetition symbol always remembers the last instance of
101 a chord so it is possible to repeat the most recent chord even if
102 other non-chorded notes or rests have been added since.
104 @lilypond[verbatim,quote,relative=1]
110 @file{ly/@/chord-repetition-init@/.ly}.
113 @node Simultaneous expressions
114 @unnumberedsubsubsec Simultaneous expressions
116 One or more music expressions enclosed in double angle brackets are
117 taken to be simultaneous. If the first expression begins with a
118 single note or if the whole simultaneous expression appears
119 explicitly within a single voice, the whole expression is placed on
120 a single staff; otherwise the elements of the simultaneous
121 expression are placed on separate staves.
123 The following examples show simultaneous expressions on one staff:
125 @lilypond[quote,verbatim,relative=2]
126 \new Voice { % explicit single voice
127 << { a4 b g2 } { d4 g c,2 } >>
131 @lilypond[quote,verbatim,relative=2]
133 a << { a4 b g } { d4 g c, } >>
136 This can be useful if the simultaneous sections have identical
137 rhythms, but attempts to attach notes with different durations
138 to the same stem will cause errors.
140 The following example shows how simultaneous expressions can
141 generate multiple staves implicitly:
143 @lilypond[quote,verbatim,relative=2]
144 % no single first note
145 << { a4 b g2 } { d4 g2 c,4 } >>
148 Here different rhythms cause no problems.
152 @unnumberedsubsubsec Clusters
157 @funindex \makeClusters
158 @funindex makeClusters
160 A cluster indicates a continuous range of pitches to be played.
161 They can be denoted as the envelope of a set of notes. They are
162 entered by applying the function @code{\makeClusters} to a sequence
165 @lilypond[quote,relative=2,verbatim]
166 \makeClusters { <g b>2 <c g'> }
169 Ordinary notes and clusters can be put together in the same staff,
170 even simultaneously. In such a case no attempt is made to
171 automatically avoid collisions between ordinary notes and clusters.
179 @rlsr{Simultaneous notes}.
182 @rinternals{ClusterSpanner},
183 @rinternals{ClusterSpannerBeacon},
184 @rinternals{Cluster_spanner_engraver}.
189 Clusters look good only if they span at least two chords; otherwise
190 they appear too narrow.
192 Clusters do not have a stem and cannot indicate durations by
193 themselves, but the length of the printed cluster is determined by
194 the durations of the defining chords. Separate clusters need a
195 separating rest between them.
197 Clusters do not produce MIDI output.
199 @node Multiple voices
200 @subsection Multiple voices
202 This section discusses simultaneous notes in multiple voices or
206 * Single-staff polyphony::
208 * Collision resolution::
209 * Automatic part combining::
210 * Writing music in parallel::
214 @node Single-staff polyphony
215 @unnumberedsubsubsec Single-staff polyphony
217 @cindex single-staff polyphony
218 @cindex polyphony, single-staff
220 @cindex lyrics assigned to one voice
224 @funindex \voiceOne ... \voiceFour
229 @strong{@i{Explicitly instantiating voices}}
231 The basic structure needed to achieve multiple independent
232 voices in a single staff is illustrated in the following example:
234 @lilypond[quote,relative=3,verbatim]
237 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
239 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
244 Here, voices are instantiated explicitly and are given names. The
245 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
246 so that first and third voices get stems up, second and fourth
247 voices get stems down, third and fourth voice note heads are
248 horizontally shifted, and rests in the respective voices are
249 automatically moved to avoid collisions. The @code{\oneVoice}
250 command returns all the voice settings to the neutral default
253 @strong{@i{Temporary polyphonic passages}}
255 A temporary polyphonic passage can be created with the following
259 << @{ \voiceOne ... @}
260 \new Voice @{ \voiceTwo ... @}
265 Here, the first expression within a temporary polyphonic passage is
266 placed into the @code{Voice} context which was in use immediately
267 before the polyphonic passage, and that same @code{Voice} context
268 continues after the temporary section. Other expressions within
269 the angle brackets are assigned to distinct temporary voices.
270 This allows lyrics to be assigned to one continuing voice before,
271 during and after a polyphonic section:
273 @lilypond[quote, verbatim, relative=2]
275 \new Voice = "melody" {
290 \new Lyrics \lyricsto "melody" {
297 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
298 required to define the settings of each voice.
300 @strong{@i{The double backslash construct}}
302 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
303 more) expressions are separated by double backslashes, behaves
304 differently to the similar construct without the double backslashes:
305 @emph{all} the expressions within this contruct are assigned
306 to new @code{Voice} contexts. These new @code{Voice} contexts
307 are created implicitly and are given the fixed names @code{"1"},
310 The first example could be typeset as follows:
312 @lilypond[quote,relative=3,verbatim]
314 { r8 r16 g e8. f16 g8[ c,] f e16 d }
316 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
320 This syntax can be used where it does not matter that temporary
321 voices are created and then discarded. These implicitly created
322 voices are given the settings equivalent to the effect of the
323 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
324 which they appear in the code.
326 In the following example, the intermediate voice has stems up,
327 therefore we enter it in the third place, so it becomes voice
328 three, which has the stems up as desired. Spacer rests are
329 used to avoid printing doubled rests.
331 @lilypond[quote,relative=3,verbatim]
333 { r8 g g g g f16 ees f8 d }
335 { ees,8 r ees r d r d r }
337 { d'8 s c s bes s a s }
341 In all but the simplest works it is advisable to create explicit
342 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
343 @rlearning{Explicitly instantiating voices}.
345 @strong{@i{Identical rhythms}}
347 In the special case that we want to typeset parallel pieces of music
348 that have the same rhythm, we can combine them into a single
349 @code{Voice} context, thus forming chords. To achieve this, enclose
350 them in a simple simultaneous music construct within an explicit voice:
352 @lilypond[quote,relative=2,verbatim]
354 { e4 f8 d e16 f g8 d4 }
355 { c4 d8 b c16 d e8 b4 }
359 This method leads to strange beamings and warnings if the pieces of
360 music do not have the same rhythm.
374 @rlearning{Voices contain music},
375 @rlearning{Explicitly instantiating voices}.
378 @ref{Percussion staves},
379 @ref{Invisible rests},
383 @rlsr{Simultaneous notes}.
387 @unnumberedsubsubsec Voice styles
390 @cindex styles, voice
391 @cindex coloring voices
392 @funindex \voiceOneStyle
393 @funindex \voiceTwoStyle
394 @funindex \voiceThreeStyle
395 @funindex \voiceFourStyle
396 @funindex \voiceNeutralStyle
398 Voices may be given distinct colors and shapes, allowing them to be
401 @lilypond[quote,relative=2,verbatim]
403 { \voiceOneStyle d4 c2 b4 }
405 { \voiceTwoStyle e,2 e }
407 { \voiceThreeStyle b2. c4 }
409 { \voiceFourStyle g'2 g }
413 The @code{\voiceNeutralStyle} command is used to revert to the
414 standard presentation.
418 @code{\voiceOneStyle},
419 @code{\voiceTwoStyle},
420 @code{\voiceThreeStyle},
421 @code{\voiceFourStyle},
422 @code{\voiceNeutralStyle}.
428 @rlearning{I'm hearing Voices},
429 @rlearning{Other sources of information}.
432 @rlsr{Simultaneous notes}.
435 @node Collision resolution
436 @unnumberedsubsubsec Collision resolution
438 @cindex merging notes
439 @cindex note collisions
442 @cindex multiple voices
443 @cindex voices, multiple
444 @cindex polyphonic music
445 @cindex shifting voices
446 @cindex voices, multiple
447 @cindex shift rest, automatic
456 @funindex \mergeDifferentlyDottedOn
457 @funindex mergeDifferentlyDottedOn
458 @funindex \mergeDifferentlyDottedOff
459 @funindex mergeDifferentlyDottedOff
460 @funindex \mergeDifferentlyHeadedOn
461 @funindex mergeDifferentlyHeadedOn
462 @funindex \mergeDifferentlyHeadedOff
463 @funindex mergeDifferentlyHeadedOff
465 The note heads of notes in different voices with the same pitch,
466 same note head and opposite stem direction are automatically
467 merged, but notes with different note heads or the same stem
468 direction are not. Rests opposite a stem in a different voice
469 are shifted vertically. The following example shows three
470 different circumstances, on beats 1 and 3 in bar 1 and beat 1
471 in bar 2, where the automatic merging fails.
473 @lilypond[quote,verbatim,relative=2]
489 Notes with different note heads may be merged, with the
490 exception of half-note heads and quarter-note heads, as shown
491 below. Here the note heads on beat 1 of bar 1 are now merged:
493 @lilypond[quote,verbatim,relative=2]
496 \mergeDifferentlyHeadedOn
510 Note heads with different dots as shown in beat 3 of bar 1 may be
513 @lilypond[quote,relative=2,verbatim]
516 \mergeDifferentlyHeadedOn
517 \mergeDifferentlyDottedOn
532 The half note and eighth note at the start of the second measure
533 are incorrectly merged because the automatic merge cannot
534 successfully complete the merge when three or more notes line up in
535 the same note column, and in this case the merged note head is
536 incorrect. To allow the merge to select the correct note head
537 a @code{\shift} must be applied to the note that should not be
538 merged. Here, @code{\shiftOn} is applied to move the top
539 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
542 @lilypond[quote,relative=2,verbatim]
545 \mergeDifferentlyHeadedOn
546 \mergeDifferentlyDottedOn
562 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
563 commands specify the degree to which chords of the current voice
564 should be shifted. The outer voices (normally: voices one and
565 two) have @code{\shiftOff}, while the inner voices (three and
566 four) have @code{\shiftOn}. @code{\shiftOnn} and
567 @code{\shiftOnnn} define further shift levels.
569 Notes are only merged if they have opposing stem directions (as
570 they have, for example, in voices one and two by default or when
571 the stems are explicitly set in opposite directions).
575 @code{\mergeDifferentlyDottedOn},
576 @code{\mergeDifferentlyDottedOff},
577 @code{\mergeDifferentlyHeadedOn},
578 @code{\mergeDifferentlyHeadedOff}.
589 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
590 {additional-voices-to-avoid-collisions.ly}
592 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
593 {forcing-horizontal-shift-of-notes.ly}
601 @rlearning{Multiple notes at once},
602 @rlearning{Voices contain music},
603 @rlearning{Real music example}.
606 @rlsr{Simultaneous notes}.
609 @rinternals{NoteColumn},
610 @rinternals{NoteCollision},
611 @rinternals{RestCollision}.
617 @c TODO investigate! Sometimes it works, sometimes not. --FV
618 The requirements for successfully merging different note heads that
619 are at the same time differently dotted are not clear.
622 There is no support for chords where the same note occurs with
623 different accidentals in the same chord. In this case, it is
624 recommended to use enharmonic transcription, or to use special
625 cluster notation (see @ref{Clusters}).
628 @node Automatic part combining
629 @unnumberedsubsubsec Automatic part combining
631 @cindex automatic part combining
632 @cindex part combiner
633 @cindex combining parts
636 @funindex \partcombine
637 @funindex partcombine
639 Automatic part combining is used to merge two parts of music onto
640 a staff. It is aimed at typesetting orchestral scores. When the
641 two parts are identical for a period of time, only one is shown.
642 In places where the two parts differ, they are typeset as separate
643 voices, and stem directions are set automatically. Also, solo and
644 @notation{a due} parts are identified and marked by default.
646 The syntax for part combining is:
649 \partcombine @var{musicexpr1} @var{musicexpr2}
652 The following example demonstrates the basic functionality of the
653 part combiner: putting parts on one staff and setting stem
654 directions and polyphony. The same variables are used for the
655 independent parts and the combined staff.
657 @lilypond[quote,verbatim]
658 instrumentOne = \relative c' {
666 instrumentTwo = \relative g' {
675 \new Staff \instrumentOne
676 \new Staff \instrumentTwo
677 \new Staff \partcombine \instrumentOne \instrumentTwo
681 The notes in the third measure appear only once, although they were
682 specified in both parts. Stem, slur, and tie directions are set
683 automatically, depending whether there is a solo or unison. When
684 needed in polyphony situations, the first part (with context called
685 @code{one}) always gets up stems, while the second (called @code{two})
686 always gets down stems. In solo situations, the first and second
687 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
688 unisono (@notation{a due}) parts are marked by default with the text
691 Both arguments to @code{\partcombine} will be interpreted as
692 @code{Voice} contexts. If using relative octaves,
693 @code{\relative} should be specified for both music expressions,
698 \relative @dots{} @var{musicexpr1}
699 \relative @dots{} @var{musicexpr2}
703 A @code{\relative} section that is outside of @code{\partcombine}
704 has no effect on the pitches of @var{musicexpr1} and
709 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
710 {combining-two-parts-on-the-same-staff.ly}
712 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
713 {changing-partcombine-texts.ly}
725 @rlsr{Simultaneous notes}.
728 @rinternals{PartCombineMusic},
734 @code{\partcombine} can only accept two voices.
736 When @code{printPartCombineTexts} is set, if the two voices play
737 the same notes on and off, the part combiner may typeset @code{a2}
738 more than once in a measure.
740 @code{\partcombine} cannot be inside @code{\times}.
742 @code{\partcombine} cannot be inside @code{\relative}.
744 Internally, the @code{\partcombine} interprets both arguments as
745 @code{Voice}s and decides when the parts can be combined. When they have
746 different durations they cannot be combined and are given the names
747 @code{one} and @code{two}. Consequently, if the arguments switch to
748 differently named @rinternals{Voice} contexts, the events in those will
749 be ignored. Likewise, partcombining isn't designed to work with lyrics;
750 when one of the voices is explicitly named in order to attach lyrics to
751 it, the partcombining stops working.
753 @code{\partcombine} only observes onset times of notes. It cannot
754 determine whether a previously started note is playing or not, leading
758 @node Writing music in parallel
759 @unnumberedsubsubsec Writing music in parallel
761 @cindex writing music in parallel
762 @cindex interleaved music
763 @cindex parallel music
764 @funindex \parallelMusic
765 @funindex parallelMusic
767 Music for multiple parts can be interleaved in input code. The
768 function @code{\parallelMusic} accepts a list with the names of a
769 number of variables to be created, and a musical expression. The
770 content of alternate measures from the expression become the value
771 of the respective variables, so you can use them afterwards to
774 @warning{Bar checks @code{|} must be used, and the measures must
775 be of the same length.}
777 @lilypond[quote,verbatim]
778 \parallelMusic #'(voiceA voiceB voiceC) {
780 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
781 r16 e'8.~ e'4 r16 e'8.~ e'4 |
785 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
786 r16 d'8.~ d'4 r16 d'8.~ d'4 |
791 \new Staff << \voiceA \\ \voiceB >>
792 \new Staff { \clef bass \voiceC }
796 Relative mode may be used. Note that the @code{\relative} command
797 is not used inside @code{\parallelMusic} itself. The notes are
798 relative to the preceding note in the voice, not to the previous
799 note in the input -- in other words, relative notes for
800 @code{voiceA} ignore the notes in @code{voiceB}.
802 @lilypond[quote,verbatim]
803 \parallelMusic #'(voiceA voiceB voiceC) {
805 r8 g16 c e g, c e r8 g,16 c e g, c e |
806 r16 e8.~ e4 r16 e8.~ e4 |
810 r8 a,16 d f a, d f r8 a,16 d f a, d f |
811 r16 d8.~ d4 r16 d8.~ d4 |
816 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
817 \new Staff \relative c' { \clef bass \voiceC }
821 This works quite well for piano music. This example maps four
822 consecutive measures to four variables:
824 @lilypond[quote,verbatim]
830 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
834 c16 d e fis d e fis g |
840 e16 fis g a fis g a b |
851 \relative c'' \voiceA
871 @rlearning{Organizing pieces with variables}.
874 @rlsr{Simultaneous notes}.