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
51 A chord is formed by enclosing a set of pitches between @code{<}
52 and @code{>}. A chord may be followed by a duration just like simple
55 @lilypond[verbatim,quote,relative=2]
56 <a c e>1 <a c e>2 <f a c e>4 <a c>8. <g c e>16
59 Chords may also be followed by articulations, again just like simple
62 @lilypond[verbatim,quote,relative=2]
63 <a c e>1\fermata <a c e>2-> <f a c e>4\prall <a c>8.^| <g c e>16-.
66 The notes within the chord themselves can also be followed by articulation
69 @lilypond[verbatim,quote,relative=2]
70 <a c\prall e>1 <a-> c-^ e>2 <f-. a c-. e-.>4 <a-+ c-->8. <g\fermata c e\turn>16
73 However some notation, such as dynamics, hairpins and slurs must be
74 attached to the chord, rather than notes within the chord, otherwise
77 @lilypond[verbatim,quote,relative=2]
78 <a\f c( e>1 <a c) e>\f <a\< c e>( <a\! c e>) <a c e>\< <a c e> <a c e>\!
81 @cindex relative pitch, chords
82 @cindex chords, relative pitch
84 Relative mode can be used for pitches in chords. The first note of
85 each chord is always relative to the first note of the chord that
86 came before it, or in the case where no preceding chord exists, the
87 pitch of the last note that came before the chord. All remaining notes
88 in the chord are relative to the note that came before it
89 @emph{within the same chord}.
91 @lilypond[verbatim,quote,relative=2]
92 <a c e>1 <f a c> <a c e> <f' a c> <b, e b,>
95 For more information about chords, see @ref{Chord notation}.
102 @rlearning{Combining notes into chords}.
105 @ref{Chord notation},
106 @ref{Articulations and ornamentations},
107 @ref{Relative octave entry}.
110 @rlsr{Simultaneous notes}.
113 @node Chord repetition
114 @unnumberedsubsubsec Chord repetition
116 In order to save typing, a shortcut can be used to repeat the preceding
117 chord. The chord repetition symbol is @code{q}:
119 @lilypond[verbatim,quote,relative=2]
120 <a c e>1 q <f a c>2 q
123 As with regular chords, the chord repetition symbol can be used with
124 durations, articulations, markups, slurs, beams, etc. as only the
125 pitches of the previous chord are duplicated.
127 @lilypond[verbatim,quote,relative=2]
128 <a c e>1\p^"text" q2\<( q8)[-| q8.]\! q16-1-2-3 q8\prall
131 The chord repetition symbol always remembers the last instance of
132 a chord so it is possible to repeat the most recent chord even if
133 other non-chorded notes or rests have been added since.
135 @lilypond[verbatim,quote,relative=2]
139 However, the chord repetition symbol does not retain any dynamics,
140 articulation or ornamentation within, or attached to the previous chord.
142 @lilypond[verbatim,quote,relative=2]
143 <a-. c\prall e>1\sfz c4 q2 r8 q8
148 @ref{Chord notation},
149 @ref{Articulations and ornamentations}.
152 @file{ly/@/chord@/-repetition@/-init@/.ly}.
155 @node Simultaneous expressions
156 @unnumberedsubsubsec Simultaneous expressions
158 One or more music expressions enclosed in double angle brackets are
159 taken to be simultaneous. If the first expression begins with a
160 single note or if the whole simultaneous expression appears
161 explicitly within a single voice, the whole expression is placed on
162 a single staff; otherwise the elements of the simultaneous
163 expression are placed on separate staves.
165 The following examples show simultaneous expressions on one staff:
167 @lilypond[quote,verbatim,relative=2]
168 \new Voice { % explicit single voice
169 << { a4 b g2 } { d4 g c,2 } >>
173 @lilypond[quote,verbatim,relative=2]
175 a << { a4 b g } { d4 g c, } >>
178 This can be useful if the simultaneous sections have identical
179 rhythms, but attempts to attach notes with different durations
180 to the same stem will cause errors.
182 The following example shows how simultaneous expressions can
183 generate multiple staves implicitly:
185 @lilypond[quote,verbatim,relative=2]
186 % no single first note
187 << { a4 b g2 } { d4 g2 c,4 } >>
190 Here different rhythms cause no problems.
194 @unnumberedsubsubsec Clusters
199 @funindex \makeClusters
200 @funindex makeClusters
202 A cluster indicates a continuous range of pitches to be played.
203 They can be denoted as the envelope of a set of notes. They are
204 entered by applying the function @code{\makeClusters} to a sequence
207 @lilypond[quote,relative=2,verbatim]
208 \makeClusters { <g b>2 <c g'> }
211 Ordinary notes and clusters can be put together in the same staff,
212 even simultaneously. In such a case no attempt is made to
213 automatically avoid collisions between ordinary notes and clusters.
221 @rlsr{Simultaneous notes}.
224 @rinternals{ClusterSpanner},
225 @rinternals{ClusterSpannerBeacon},
226 @rinternals{Cluster_spanner_engraver}.
231 Clusters look good only if they span at least two chords; otherwise
232 they appear too narrow.
234 Clusters do not have a stem and cannot indicate durations by
235 themselves, but the length of the printed cluster is determined by
236 the durations of the defining chords. Separate clusters need a
237 separating rest between them.
239 Clusters do not produce MIDI output.
241 @node Multiple voices
242 @subsection Multiple voices
244 This section discusses simultaneous notes in multiple voices or
248 * Single-staff polyphony::
250 * Collision resolution::
251 * Automatic part combining::
252 * Writing music in parallel::
256 @node Single-staff polyphony
257 @unnumberedsubsubsec Single-staff polyphony
259 @cindex single-staff polyphony
260 @cindex polyphony, single-staff
262 @cindex lyrics assigned to one voice
266 @funindex \voiceOne ... \voiceFour
271 @strong{@i{Explicitly instantiating voices}}
273 The basic structure needed to achieve multiple independent
274 voices in a single staff is illustrated in the following example:
276 @lilypond[quote,relative=3,verbatim]
279 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
281 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
286 Here, voices are instantiated explicitly and are given names. The
287 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
288 so that first and third voices get stems up, second and fourth
289 voices get stems down, third and fourth voice note heads are
290 horizontally shifted, and rests in the respective voices are
291 automatically moved to avoid collisions. The @code{\oneVoice}
292 command returns all the voice settings to the neutral default
295 @strong{@i{Temporary polyphonic passages}}
297 A temporary polyphonic passage can be created with the following
301 << @{ \voiceOne ... @}
302 \new Voice @{ \voiceTwo ... @}
307 Here, the first expression within a temporary polyphonic passage is
308 placed into the @code{Voice} context which was in use immediately
309 before the polyphonic passage, and that same @code{Voice} context
310 continues after the temporary section. Other expressions within
311 the angle brackets are assigned to distinct temporary voices.
312 This allows lyrics to be assigned to one continuing voice before,
313 during and after a polyphonic section:
315 @lilypond[quote, verbatim, relative=2]
317 \new Voice = "melody" {
332 \new Lyrics \lyricsto "melody" {
339 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
340 required to define the settings of each voice.
342 @strong{@i{The double backslash construct}}
344 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
345 more) expressions are separated by double backslashes, behaves
346 differently to the similar construct without the double backslashes:
347 @emph{all} the expressions within this construct are assigned
348 to new @code{Voice} contexts. These new @code{Voice} contexts
349 are created implicitly and are given the fixed names @code{"1"},
352 The first example could be typeset as follows:
354 @lilypond[quote,relative=3,verbatim]
356 { r8 r16 g e8. f16 g8[ c,] f e16 d }
358 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
362 This syntax can be used where it does not matter that temporary
363 voices are created and then discarded. These implicitly created
364 voices are given the settings equivalent to the effect of the
365 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
366 which they appear in the code.
368 In the following example, the intermediate voice has stems up,
369 therefore we enter it in the third place, so it becomes voice
370 three, which has the stems up as desired. Spacer rests are
371 used to avoid printing doubled rests.
373 @lilypond[quote,relative=3,verbatim]
375 { r8 g g g g f16 ees f8 d }
377 { ees,8 r ees r d r d r }
379 { d'8 s c s bes s a s }
383 In all but the simplest works it is advisable to create explicit
384 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
385 @rlearning{Explicitly instantiating voices}.
387 @strong{@i{Voice order}}
389 When entering multiple voices in the input file, use the following
395 Voice 3: second highest
396 Voice 4: second lowest
397 Voice 5: third highest
398 Voice 6: third lowest
402 Though this may seem counterintuitive, it simplifies the automatic
403 layout process. Note that the odd-numbered voices are given
404 upstems, and the even-numbered voices are given downstems:
406 @lilypond[quote,verbatim]
409 { f''2 } % 1: highest
413 { d''2 } % 3: second-highest
415 { e'2 } % 4: second-lowest
417 { b'2 } % 5: third-highest
419 { g'2 } % 6: third-lowest
423 @strong{@i{Identical rhythms}}
425 In the special case that we want to typeset parallel pieces of music
426 that have the same rhythm, we can combine them into a single
427 @code{Voice} context, thus forming chords. To achieve this, enclose
428 them in a simple simultaneous music construct within an explicit voice:
430 @lilypond[quote,relative=2,verbatim]
432 { e4 f8 d e16 f g8 d4 }
433 { c4 d8 b c16 d e8 b4 }
437 This method leads to strange beamings and warnings if the pieces of
438 music do not have the same rhythm.
452 @rlearning{Voices contain music},
453 @rlearning{Explicitly instantiating voices}.
456 @ref{Percussion staves},
457 @ref{Invisible rests},
461 @rlsr{Simultaneous notes}.
465 @unnumberedsubsubsec Voice styles
468 @cindex styles, voice
469 @cindex coloring voices
470 @funindex \voiceOneStyle
471 @funindex \voiceTwoStyle
472 @funindex \voiceThreeStyle
473 @funindex \voiceFourStyle
474 @funindex \voiceNeutralStyle
476 Voices may be given distinct colors and shapes, allowing them to be
479 @lilypond[quote,relative=2,verbatim]
481 { \voiceOneStyle d4 c2 b4 }
483 { \voiceTwoStyle e,2 e }
485 { \voiceThreeStyle b2. c4 }
487 { \voiceFourStyle g'2 g }
491 The @code{\voiceNeutralStyle} command is used to revert to the
492 standard presentation.
496 @code{\voiceOneStyle},
497 @code{\voiceTwoStyle},
498 @code{\voiceThreeStyle},
499 @code{\voiceFourStyle},
500 @code{\voiceNeutralStyle}.
506 @rlearning{I'm hearing Voices},
507 @rlearning{Other sources of information}.
510 @rlsr{Simultaneous notes}.
513 @node Collision resolution
514 @unnumberedsubsubsec Collision resolution
516 @cindex merging notes
517 @cindex note collisions
520 @cindex multiple voices
521 @cindex voices, multiple
522 @cindex polyphonic music
523 @cindex shifting voices
524 @cindex voices, multiple
525 @cindex shift rest, automatic
534 @funindex \mergeDifferentlyDottedOn
535 @funindex mergeDifferentlyDottedOn
536 @funindex \mergeDifferentlyDottedOff
537 @funindex mergeDifferentlyDottedOff
538 @funindex \mergeDifferentlyHeadedOn
539 @funindex mergeDifferentlyHeadedOn
540 @funindex \mergeDifferentlyHeadedOff
541 @funindex mergeDifferentlyHeadedOff
543 The note heads of notes in different voices with the same pitch,
544 same note head and opposite stem direction are automatically
545 merged, but notes with different note heads or the same stem
546 direction are not. Rests opposite a stem in a different voice
547 are shifted vertically. The following example shows three
548 different circumstances, on beats 1 and 3 in bar 1 and beat 1
549 in bar 2, where the automatic merging fails.
551 @lilypond[quote,verbatim,relative=2]
567 Notes with different note heads may be merged, with the
568 exception of half-note heads and quarter-note heads, as shown
569 below. Here the note heads on beat 1 of bar 1 are now merged:
571 @lilypond[quote,verbatim,relative=2]
574 \mergeDifferentlyHeadedOn
588 Note heads with different dots as shown in beat 3 of bar 1 may be
591 @lilypond[quote,relative=2,verbatim]
594 \mergeDifferentlyHeadedOn
595 \mergeDifferentlyDottedOn
610 The half note and eighth note at the start of the second measure
611 are incorrectly merged because the automatic merge cannot
612 successfully complete the merge when three or more notes line up in
613 the same note column, and in this case the merged note head is
614 incorrect. To allow the merge to select the correct note head
615 a @code{\shift} must be applied to the note that should not be
616 merged. Here, @code{\shiftOn} is applied to move the top
617 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
620 @lilypond[quote,relative=2,verbatim]
623 \mergeDifferentlyHeadedOn
624 \mergeDifferentlyDottedOn
639 The @code{\shiftOn} command allows (but does not force) the notes
640 in a voice to be shifted. When @code{\shiftOn} is applied to a
641 voice, a note or chord in that voice is shifted only if its stem
642 would otherwise collide with a stem from another voice, and only
643 if the colliding stems point in the same direction. The
644 @code{\shiftOff} command prevents this type of shifting from
647 By default, the outer voices (normally voices one and two) have
648 @code{\shiftOff} specified, while the inner voices (three and
649 above) have @code{\shiftOn} specified. When a shift is applied,
650 voices with upstems (odd-numbered voices) are shifted to the
651 right, and voices with downstems (even-numbered voices) are
654 Here is an example to help you visualize how an abbreviated
655 polyphonic expression would be expanded internally.
657 @warning{Note that with three or more voices, the vertical order
658 of voices in your input file should not be the same as the
659 vertical order of voices on the staff!}
661 @lilypond[quote,verbatim]
662 \new Staff \relative c'' {
669 { d'2 } % 3: upper middle
671 { b2 } % 4: lower middle
673 %% internal expansion of the above
675 \new Voice = "1" { \voiceOne \shiftOff f'2 }
676 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
677 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
678 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
683 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
684 provide further shift levels which may be specified temporarily to
685 resolve collisions in complex situations -- see
686 @rlearning{Real music example}.
688 Notes are only merged if they have opposing stem directions (as
689 they have, for example, in voices one and two by default or when
690 the stems are explicitly set in opposite directions).
694 @code{\mergeDifferentlyDottedOn},
695 @code{\mergeDifferentlyDottedOff},
696 @code{\mergeDifferentlyHeadedOn},
697 @code{\mergeDifferentlyHeadedOff}.
708 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
709 {additional-voices-to-avoid-collisions.ly}
711 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
712 {forcing-horizontal-shift-of-notes.ly}
720 @rlearning{Multiple notes at once},
721 @rlearning{Voices contain music},
722 @rlearning{Real music example}.
725 @rlsr{Simultaneous notes}.
728 @rinternals{NoteColumn},
729 @rinternals{NoteCollision},
730 @rinternals{RestCollision}.
736 @c TODO investigate! Sometimes it works, sometimes not. --FV
737 The requirements for successfully merging different note heads that
738 are at the same time differently dotted are not clear.
741 There is no support for chords where the same note occurs with
742 different accidentals in the same chord. In this case, it is
743 recommended to use enharmonic transcription, or to use special
744 cluster notation (see @ref{Clusters}).
747 @node Automatic part combining
748 @unnumberedsubsubsec Automatic part combining
750 @cindex automatic part combining
751 @cindex part combiner
752 @cindex combining parts
755 @funindex \partcombine
756 @funindex partcombine
758 Automatic part combining is used to merge two parts of music onto
759 a staff. It is aimed at typesetting orchestral scores. When the
760 two parts are identical for a period of time, only one is shown.
761 In places where the two parts differ, they are typeset as separate
762 voices, and stem directions are set automatically. Also, solo and
763 @notation{a due} parts are identified and marked by default.
765 The syntax for part combining is:
768 \partcombine @var{musicexpr1} @var{musicexpr2}
771 The following example demonstrates the basic functionality of the
772 part combiner: putting parts on one staff and setting stem
773 directions and polyphony. The same variables are used for the
774 independent parts and the combined staff.
776 @lilypond[quote,verbatim]
777 instrumentOne = \relative c' {
785 instrumentTwo = \relative g' {
794 \new Staff \instrumentOne
795 \new Staff \instrumentTwo
796 \new Staff \partcombine \instrumentOne \instrumentTwo
800 The notes in the third measure appear only once, although they were
801 specified in both parts. Stem, slur, and tie directions are set
802 automatically, depending whether there is a solo or unison. When
803 needed in polyphony situations, the first part (with context called
804 @code{one}) always gets up stems, while the second (called @code{two})
805 always gets down stems. In solo situations, the first and second
806 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
807 unisono (@notation{a due}) parts are marked by default with the text
810 Both arguments to @code{\partcombine} will be interpreted as
811 @code{Voice} contexts. If using relative octaves,
812 @code{\relative} should be specified for both music expressions,
817 \relative @dots{} @var{musicexpr1}
818 \relative @dots{} @var{musicexpr2}
822 A @code{\relative} section that is outside of @code{\partcombine}
823 has no effect on the pitches of @code{@var{musicexpr1}} and
824 @code{@var{musicexpr2}}.
828 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
829 {combining-two-parts-on-the-same-staff.ly}
831 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
832 {changing-partcombine-texts.ly}
844 @rlsr{Simultaneous notes}.
847 @rinternals{PartCombineMusic},
853 @code{\partcombine} can only accept two voices.
855 When @code{printPartCombineTexts} is set, if the two voices play
856 the same notes on and off, the part combiner may typeset @code{a2}
857 more than once in a measure.
859 @code{\partcombine} cannot be inside @code{\times}.
861 @code{\partcombine} cannot be inside @code{\relative}.
863 Internally, the @code{\partcombine} interprets both arguments as
864 @code{Voice}s and decides when the parts can be combined. When they have
865 different durations they cannot be combined and are given the names
866 @code{one} and @code{two}. Consequently, if the arguments switch to
867 differently named @rinternals{Voice} contexts, the events in those will
868 be ignored. Likewise, partcombining isn't designed to work with lyrics;
869 when one of the voices is explicitly named in order to attach lyrics to
870 it, the partcombining stops working.
872 @code{\partcombine} only observes onset times of notes. It cannot
873 determine whether a previously started note is playing or not, leading
877 @node Writing music in parallel
878 @unnumberedsubsubsec Writing music in parallel
880 @cindex writing music in parallel
881 @cindex interleaved music
882 @cindex parallel music
883 @funindex \parallelMusic
884 @funindex parallelMusic
886 Music for multiple parts can be interleaved in input code. The
887 function @code{\parallelMusic} accepts a list with the names of a
888 number of variables to be created, and a musical expression. The
889 content of alternate measures from the expression become the value
890 of the respective variables, so you can use them afterwards to
893 @warning{Bar checks @code{|} must be used, and the measures must
894 be of the same length.}
896 @lilypond[quote,verbatim]
897 \parallelMusic #'(voiceA voiceB voiceC) {
899 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
900 r16 e'8.~ e'4 r16 e'8.~ e'4 |
904 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
905 r16 d'8.~ d'4 r16 d'8.~ d'4 |
910 \new Staff << \voiceA \\ \voiceB >>
911 \new Staff { \clef bass \voiceC }
915 Relative mode may be used. Note that the @code{\relative} command
916 is not used inside @code{\parallelMusic} itself. The notes are
917 relative to the preceding note in the voice, not to the previous
918 note in the input -- in other words, relative notes for
919 @code{voiceA} ignore the notes in @code{voiceB}.
921 @lilypond[quote,verbatim]
922 \parallelMusic #'(voiceA voiceB voiceC) {
924 r8 g16 c e g, c e r8 g,16 c e g, c e |
925 r16 e8.~ e4 r16 e8.~ e4 |
929 r8 a,16 d f a, d f r8 a,16 d f a, d f |
930 r16 d8.~ d4 r16 d8.~ d4 |
935 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
936 \new Staff \relative c' { \clef bass \voiceC }
940 This works quite well for piano music. This example maps four
941 consecutive measures to four variables:
943 @lilypond[quote,verbatim]
949 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
953 c16 d e fis d e fis g |
959 e16 fis g a fis g a b |
970 \relative c'' \voiceA
990 @rlearning{Organizing pieces with variables}.
993 @rlsr{Simultaneous notes}.