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.
34 * Simultaneous expressions::
40 @unnumberedsubsubsec Chorded notes
43 @cindex brackets, angle
44 @cindex angle brackets
45 @cindex relative pitch in chords
51 A chord is formed by enclosing a set of pitches between @code{<}
52 and @code{>}. A chord may be followed by a duration and/or a set
53 of articulations, just like simple notes:
55 @lilypond[verbatim,quote,relative=1]
56 <c e g>2 <c f a>4-> <e g c>-.
59 Relative mode can be used for pitches in chords. The octave of each
60 pitch is chosen using the preceding pitch as a reference except in
61 the case of the first pitch in a chord: the reference for the first
62 pitch is the @emph{first} pitch of the preceding chord.
64 For more information about chords, see @ref{Chord notation}.
72 @rlearning{Combining notes into chords}.
78 @rlsr{Simultaneous notes}.
81 @node Simultaneous expressions
82 @unnumberedsubsubsec Simultaneous expressions
84 One or more music expressions enclosed in double angle brackets are
85 taken to be simultaneous. If the first expression begins with a
86 single note or if the whole simultaneous expression appears
87 explicitly within a single voice, the whole expression is placed on
88 a single staff; otherwise the elements of the simultaneous
89 expression are placed on separate staves.
91 The following examples show simultaneous expressions on one staff:
93 @lilypond[quote,verbatim,relative=2]
94 \new Voice { % explicit single voice
95 << {a4 b g2} {d4 g c,2} >>
99 @lilypond[quote,verbatim,relative=2]
101 a << {a4 b g} {d4 g c,} >>
104 This can be useful if the simultaneous sections have identical
105 rhythms, but attempts to attach notes with different durations
106 to the same stem will cause errors.
108 The following example shows how simultaneous expressions can
109 generate multiple staves implicitly:
111 @lilypond[quote,verbatim,relative=2]
112 % no single first note
113 << {a4 b g2} {d4 g2 c,4} >>
116 Here different rhythms cause no problems.
120 @unnumberedsubsubsec Clusters
125 @funindex \makeClusters
126 @funindex makeClusters
128 A cluster indicates a continuous range of pitches to be played.
129 They can be denoted as the envelope of a set of notes. They are
130 entered by applying the function @code{\makeClusters} to a sequence
133 @lilypond[quote,relative=2,verbatim]
134 \makeClusters { <g b>2 <c g'> }
137 Ordinary notes and clusters can be put together in the same staff,
138 even simultaneously. In such a case no attempt is made to
139 automatically avoid collisions between ordinary notes and clusters.
147 @rlsr{Simultaneous notes}.
150 @rinternals{ClusterSpanner},
151 @rinternals{ClusterSpannerBeacon},
152 @rinternals{Cluster_spanner_engraver}.
157 Clusters look good only if they span at least two chords; otherwise
158 they appear too narrow.
160 Clusters do not have a stem and cannot indicate durations by
161 themselves, but the length of the printed cluster is determined by
162 the durations of the defining chords. Separate clusters need a
163 separating rest between them.
165 Clusters do not produce MIDI output.
167 @node Multiple voices
168 @subsection Multiple voices
170 This section discusses simultaneous notes in multiple voices or
174 * Single-staff polyphony::
176 * Collision resolution::
177 * Automatic part combining::
178 * Writing music in parallel::
182 @node Single-staff polyphony
183 @unnumberedsubsubsec Single-staff polyphony
185 @cindex single-staff polyphony
186 @cindex polyphony, single-staff
188 @cindex lyrics assigned to one voice
192 @funindex \voiceOne ... \voiceFour
197 @strong{@i{Explicitly instantiating voices}}
199 The basic structure needed to achieve multiple independent
200 voices in a single staff is illustrated in the following example:
202 @lilypond[quote,relative=3,verbatim]
205 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
207 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
211 Here, voices are instantiated explicitly and are given names. The
212 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
213 so that first and third voices get stems up, second and fourth
214 voices get stems down, third and fourth voice note heads are
215 horizontally shifted, and rests in the respective voices are
216 automatically moved to avoid collisions. The @code{\oneVoice}
217 command returns all the voice settings to the neutral default
220 @strong{@i{Temporary polyphonic passages}}
222 A temporary polyphonic passage can be created with the following
226 << @{ \voiceOne ... @}
227 \new Voice @{ \voiceTwo ... @}
231 Here, the first expression within a temporary polyphonic passage is
232 placed into the @code{Voice} context which was in use immediately
233 before the polyphonic passage, and that same @code{Voice} context
234 continues after the temporary section. Other expressions within
235 the angle brackets are assigned to distinct temporary voices.
236 This allows lyrics to be assigned to one continuing voice before,
237 during and after a polyphonic section:
239 @lilypond[quote, verbatim, relative=2]
241 \new Voice = "melody" {
256 \new Lyrics \lyricsto "melody" {
262 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
263 required to define the settings of each voice.
265 @strong{@i{The double backslash construct}}
267 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
268 more) expressions are separated by double backslashes, behaves
269 differently to the similar construct without the double backslashes:
270 @emph{all} the expressions within this contruct are assigned
271 to new @code{Voice} contexts. These new @code{Voice} contexts
272 are created implicitly and are given the fixed names @code{"1"},
275 The first example could be typeset as follows:
277 @lilypond[quote,relative=3,verbatim]
279 { r8 r16 g e8. f16 g8[ c,] f e16 d }
281 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
285 This syntax can be used where it does not matter that temporary
286 voices are created and then discarded. These implicitly created
287 voices are given the settings equivalent to the effect of the
288 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
289 which they appear in the code.
291 In the following example, the intermediate voice has stems up,
292 therefore we enter it in the third place, so it becomes voice
293 three, which has the stems up as desired. Spacer rests are
294 used to avoid printing doubled rests.
296 @lilypond[quote,relative=3,verbatim]
298 { r8 g g g g f16 ees f8 d }
300 { ees,8 r ees r d r d r }
302 { d'8 s c s bes s a s }
306 In all but the simplest works it is advisable to create explicit
307 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
308 @rlearning{Explicitly instantiating voices}.
310 @strong{@i{Identical rhythms}}
312 In the special case that we want to typeset parallel pieces of music
313 that have the same rhythm, we can combine them into a single
314 @code{Voice} context, thus forming chords. To achieve this, enclose
315 them in a simple simultaneous music construct within an explicit voice:
317 @lilypond[quote,relative=2,verbatim]
319 { e4 f8 d e16 f g8 d4 }
320 { c4 d8 b c16 d e8 b4 }
324 This method leads to strange beamings and warnings if the pieces of
325 music do not have the same rhythm.
339 @rlearning{Voices contain music},
340 @rlearning{Explicitly instantiating voices}.
343 @ref{Percussion staves},
344 @ref{Invisible rests}.
347 @rlsr{Simultaneous notes}.
351 @unnumberedsubsubsec Voice styles
354 @cindex styles, voice
355 @cindex coloring voices
356 @funindex \voiceOneStyle
357 @funindex \voiceTwoStyle
358 @funindex \voiceThreeStyle
359 @funindex \voiceFourStyle
360 @funindex \voiceNeutralStyle
362 Voices may be given distinct colors and shapes, allowing them to be
365 @lilypond[quote,relative=2,verbatim]
367 { \voiceOneStyle d4 c2 b4 }
369 { \voiceTwoStyle e,2 e }
371 { \voiceThreeStyle b2. c4 }
373 { \voiceFourStyle g'2 g }
377 The @code{\voiceNeutralstyle} command is used to revert to the
378 standard presentation.
382 @code{\voiceOneStyle},
383 @code{\voiceTwoStyle},
384 @code{\voiceThreeStyle},
385 @code{\voiceFourStyle},
386 @code{\voiceNeutralStyle}.
392 @rlearning{I'm hearing Voices},
393 @rlearning{Other sources of information}.
396 @rlsr{Simultaneous notes}.
399 @node Collision resolution
400 @unnumberedsubsubsec Collision resolution
402 @cindex merging notes
403 @cindex note collisions
406 @cindex multiple voices
407 @cindex voices, multiple
408 @cindex polyphonic music
409 @cindex shifting voices
410 @cindex voices, multiple
411 @cindex shift rest, automatic
420 @funindex \mergeDifferentlyDottedOn
421 @funindex mergeDifferentlyDottedOn
422 @funindex \mergeDifferentlyDottedOff
423 @funindex mergeDifferentlyDottedOff
424 @funindex \mergeDifferentlyHeadedOn
425 @funindex mergeDifferentlyHeadedOn
426 @funindex \mergeDifferentlyHeadedOff
427 @funindex mergeDifferentlyHeadedOff
429 The note heads of notes in different voices with the same pitch,
430 same note head and opposite stem direction are automatically
431 merged, but notes with different note heads or the same stem
432 direction are not. Rests opposite a stem in a different voice
433 are shifted vertically.
435 @lilypond[quote,verbatim,relative=2]
451 Notes with different note heads may be merged, with the
452 exception of half-note heads and quarter-note heads:
454 @lilypond[quote,verbatim,relative=2]
457 \mergeDifferentlyHeadedOn
471 Note heads with different dots may be merged:
473 @lilypond[quote,relative=2,verbatim]
476 \mergeDifferentlyHeadedOn
477 \mergeDifferentlyDottedOn
492 The half note and eighth note at the start of the second measure
493 are incorrectly merged because @code{\mergeDifferentlyHeadedOn}
494 cannot successfully complete the merge when three or more notes
495 line up in the same column, and in this case a warning is given.
496 To allow the merge to work properly a @code{\shift} must be applied
497 to the note that should not be merged. Here, @code{\shiftOn} is
498 applied to move the top @notation{g} out of the column, and
499 @code{\mergeDifferentlyHeadedOn} then works properly.
501 @lilypond[quote,relative=2,verbatim]
504 \mergeDifferentlyHeadedOn
505 \mergeDifferentlyDottedOn
521 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
522 commands specify the degree to which chords of the current voice
523 should be shifted. The outer voices (normally: voices one and
524 two) have @code{\shiftOff}, while the inner voices (three and
525 four) have @code{\shiftOn}. @code{\shiftOnn} and
526 @code{\shiftOnnn} define further shift levels.
528 Notes are only merged if they have opposing stem directions (e.g. in
529 @code{Voice} 1 and 2).
533 @code{\mergeDifferentlyDottedOn},
534 @code{\mergeDifferentlyDottedOff},
535 @code{\mergeDifferentlyHeadedOn},
536 @code{\mergeDifferentlyHeadedOff}.
547 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
548 {additional-voices-to-avoid-collisions.ly}
550 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
551 {forcing-horizontal-shift-of-notes.ly}
559 @rlearning{Multiple notes at once},
560 @rlearning{Voices contain music},
561 @rlearning{Collisions of objects}.
564 @rlsr{Simultaneous notes}.
567 @rinternals{NoteColumn},
568 @rinternals{NoteCollision},
569 @rinternals{RestCollision}.
574 When using @code{\mergeDifferentlyHeadedOn} with an upstem eighth
575 or a shorter note, and a downstem half note, the eighth note stem
576 gets a slightly wrong offset because of the different width of the
577 half note head symbol.
580 @c TODO investigate! Sometimes it works, sometimes not. --FV
581 The requirements for successfully merging different note heads that
582 are at the same time differently dotted are not clear.
585 There is no support for chords where the same note occurs with
586 different accidentals in the same chord. In this case, it is
587 recommended to use enharmonic transcription, or to use special
588 cluster notation (see @ref{Clusters}).
591 @node Automatic part combining
592 @unnumberedsubsubsec Automatic part combining
594 @cindex automatic part combining
595 @cindex part combiner
596 @cindex combining parts
599 @funindex \partcombine
600 @funindex partcombine
602 Automatic part combining is used to merge two parts of music onto
603 a staff. It is aimed at typesetting orchestral scores. When the
604 two parts are identical for a period of time, only one is shown.
605 In places where the two parts differ, they are typeset as separate
606 voices, and stem directions are set automatically. Also, solo and
607 @notation{a due} parts are identified and marked by default.
609 The syntax for part combining is:
612 \partcombine @var{musicexpr1} @var{musicexpr2}
615 The following example demonstrates the basic functionality of the
616 part combiner: putting parts on one staff and setting stem
617 directions and polyphony. The same variables are used for the
618 independent parts and the combined staff.
620 @lilypond[quote,verbatim]
621 instrumentOne = \relative c' {
629 instrumentTwo = \relative g' {
638 \new Staff \instrumentOne
639 \new Staff \instrumentTwo
640 \new Staff \partcombine \instrumentOne \instrumentTwo
644 The notes in the third measure appear only once, although they were
645 specified in both parts. Stem, slur, and tie directions are set
646 automatically, depending whether there is a solo or unison. When
647 needed in polyphony situations, the first part (with context called
648 @code{one}) always gets up stems, while the second (called @code{two})
649 always gets down stems. In solo situations, the first and second
650 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
651 unisono (@notation{a due}) parts are marked by default with the text
654 Both arguments to @code{\partcombine} will be interpreted as
655 @code{Voice} contexts. If using relative octaves,
656 @code{\relative} should be specified for both music expressions,
661 \relative @dots{} @var{musicexpr1}
662 \relative @dots{} @var{musicexpr2}
666 A @code{\relative} section that is outside of @code{\partcombine}
667 has no effect on the pitches of @var{musicexpr1} and
672 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
673 {combining-two-parts-on-the-same-staff.ly}
675 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
676 {changing-partcombine-texts.ly}
688 @rlsr{Simultaneous notes}.
691 @rinternals{PartCombineMusic},
697 @code{\partcombine} can only accept two voices.
699 When @code{printPartCombineTexts} is set, if the two voices play
700 the same notes on and off, the part combiner may typeset @code{a2}
701 more than once in a measure.
703 @code{\partcombine} cannot be inside @code{\times}.
705 @code{\partcombine} cannot be inside @code{\relative}.
707 Internally, the @code{\partcombine} interprets both arguments as
708 @code{Voice}s and decides when the parts can be combined. When they have
709 different durations they cannot be combined and are given the names
710 @code{one} and @code{two}. Consequently, if the arguments switch to
711 differently named @rinternals{Voice} contexts, the events in those will
712 be ignored. Likewise, partcombining isn't designed to work with lyrics;
713 when one of the voices is explicitly named in order to attach lyrics to
714 it, the partcombining stops working.
716 @code{\partcombine} only observes onset times of notes. It cannot
717 determine whether a previously started note is playing or not, leading
721 @node Writing music in parallel
722 @unnumberedsubsubsec Writing music in parallel
724 @cindex writing music in parallel
725 @cindex interleaved music
726 @cindex parallel music
727 @funindex \parallelMusic
728 @funindex parallelMusic
730 Music for multiple parts can be interleaved in input code. The
731 function @code{\parallelMusic} accepts a list with the names of a
732 number of variables to be created, and a musical expression. The
733 content of alternate measures from the expression become the value
734 of the respective variables, so you can use them afterwards to
737 @warning{Bar checks @code{|} must be used, and the measures must
738 be of the same length.}
740 @lilypond[quote,verbatim]
741 \parallelMusic #'(voiceA voiceB voiceC) {
743 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
744 r16 e'8.~ e'4 r16 e'8.~ e'4 |
748 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
749 r16 d'8.~ d'4 r16 d'8.~ d'4 |
754 \new Staff << \voiceA \\ \voiceB >>
755 \new Staff { \clef bass \voiceC }
759 Relative mode may be used. Note that the @code{\relative} command
760 is not used inside @code{\parallelMusic} itself. The notes are
761 relative to the preceding note in the voice, not to the previous
762 note in the input -- in other words, relative notes for
763 @code{voiceA} ignore the notes in @code{voiceB}.
765 @lilypond[quote,verbatim]
766 \parallelMusic #'(voiceA voiceB voiceC) {
768 r8 g16 c e g, c e r8 g,16 c e g, c e |
769 r16 e8.~ e4 r16 e8.~ e4 |
773 r8 a,16 d f a, d f r8 a,16 d f a, d f |
774 r16 d8.~ d4 r16 d8.~ d4 |
779 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
780 \new Staff \relative c' { \clef bass \voiceC }
784 This works quite well for piano music. This example maps four
785 consecutive measures to four variables:
787 @lilypond[quote,verbatim]
793 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
797 c16 d e fis d e fis g |
803 e16 fis g a fis g a b |
814 \relative c'' \voiceA
834 @rlearning{Organizing pieces with variables}.
837 @rlsr{Simultaneous notes}.