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.
35 * Simultaneous expressions::
41 @unnumberedsubsubsec Chorded notes
44 @cindex brackets, angle
45 @cindex angle brackets
46 @cindex relative pitch in chords
52 A chord is formed by enclosing a set of pitches between @code{<}
53 and @code{>}. A chord may be followed by a duration and/or a set
54 of articulations, just like simple notes:
56 @lilypond[verbatim,quote,relative=1]
57 <c e g>2 <c f a>4-> <e g c>-.
60 Relative mode can be used for pitches in chords. The octave of each
61 pitch is chosen using the preceding pitch as a reference except in
62 the case of the first pitch in a chord: the reference for the first
63 pitch is the @emph{first} pitch of the preceding chord.
65 For more information about chords, see @ref{Chord notation}.
72 @rlearning{Combining notes into chords}.
78 @rlsr{Simultaneous notes}.
81 @node Chord repetition
82 @unnumberedsubsubsec Chord repetition
84 In order to save typing, a shortcut can be used to repeat the preceding
85 chord. The chord repetition symbol is @code{q}:
87 @lilypond[verbatim,quote,relative=1]
91 As in the case of regular chords, the chord repetition symbol can be
92 followed by a duration and articulations. Only the pitches of the
93 previous chord are duplicated; articulations, dynamics, etc, are not
96 @lilypond[verbatim,quote,relative=1]
97 <c e g>8\p q q4-| q8.^"text" q16 q4-|
102 @file{ly/@/chord-repetition-init@/.ly}.
105 @node Simultaneous expressions
106 @unnumberedsubsubsec Simultaneous expressions
108 One or more music expressions enclosed in double angle brackets are
109 taken to be simultaneous. If the first expression begins with a
110 single note or if the whole simultaneous expression appears
111 explicitly within a single voice, the whole expression is placed on
112 a single staff; otherwise the elements of the simultaneous
113 expression are placed on separate staves.
115 The following examples show simultaneous expressions on one staff:
117 @lilypond[quote,verbatim,relative=2]
118 \new Voice { % explicit single voice
119 << { a4 b g2 } { d4 g c,2 } >>
123 @lilypond[quote,verbatim,relative=2]
125 a << { a4 b g } { d4 g c, } >>
128 This can be useful if the simultaneous sections have identical
129 rhythms, but attempts to attach notes with different durations
130 to the same stem will cause errors.
132 The following example shows how simultaneous expressions can
133 generate multiple staves implicitly:
135 @lilypond[quote,verbatim,relative=2]
136 % no single first note
137 << { a4 b g2 } { d4 g2 c,4 } >>
140 Here different rhythms cause no problems.
144 @unnumberedsubsubsec Clusters
149 @funindex \makeClusters
150 @funindex makeClusters
152 A cluster indicates a continuous range of pitches to be played.
153 They can be denoted as the envelope of a set of notes. They are
154 entered by applying the function @code{\makeClusters} to a sequence
157 @lilypond[quote,relative=2,verbatim]
158 \makeClusters { <g b>2 <c g'> }
161 Ordinary notes and clusters can be put together in the same staff,
162 even simultaneously. In such a case no attempt is made to
163 automatically avoid collisions between ordinary notes and clusters.
171 @rlsr{Simultaneous notes}.
174 @rinternals{ClusterSpanner},
175 @rinternals{ClusterSpannerBeacon},
176 @rinternals{Cluster_spanner_engraver}.
181 Clusters look good only if they span at least two chords; otherwise
182 they appear too narrow.
184 Clusters do not have a stem and cannot indicate durations by
185 themselves, but the length of the printed cluster is determined by
186 the durations of the defining chords. Separate clusters need a
187 separating rest between them.
189 Clusters do not produce MIDI output.
191 @node Multiple voices
192 @subsection Multiple voices
194 This section discusses simultaneous notes in multiple voices or
198 * Single-staff polyphony::
200 * Collision resolution::
201 * Automatic part combining::
202 * Writing music in parallel::
206 @node Single-staff polyphony
207 @unnumberedsubsubsec Single-staff polyphony
209 @cindex single-staff polyphony
210 @cindex polyphony, single-staff
212 @cindex lyrics assigned to one voice
216 @funindex \voiceOne ... \voiceFour
221 @strong{@i{Explicitly instantiating voices}}
223 The basic structure needed to achieve multiple independent
224 voices in a single staff is illustrated in the following example:
226 @lilypond[quote,relative=3,verbatim]
229 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
231 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
236 Here, voices are instantiated explicitly and are given names. The
237 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
238 so that first and third voices get stems up, second and fourth
239 voices get stems down, third and fourth voice note heads are
240 horizontally shifted, and rests in the respective voices are
241 automatically moved to avoid collisions. The @code{\oneVoice}
242 command returns all the voice settings to the neutral default
245 @strong{@i{Temporary polyphonic passages}}
247 A temporary polyphonic passage can be created with the following
251 << @{ \voiceOne ... @}
252 \new Voice @{ \voiceTwo ... @}
257 Here, the first expression within a temporary polyphonic passage is
258 placed into the @code{Voice} context which was in use immediately
259 before the polyphonic passage, and that same @code{Voice} context
260 continues after the temporary section. Other expressions within
261 the angle brackets are assigned to distinct temporary voices.
262 This allows lyrics to be assigned to one continuing voice before,
263 during and after a polyphonic section:
265 @lilypond[quote, verbatim, relative=2]
267 \new Voice = "melody" {
282 \new Lyrics \lyricsto "melody" {
289 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
290 required to define the settings of each voice.
292 @strong{@i{The double backslash construct}}
294 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
295 more) expressions are separated by double backslashes, behaves
296 differently to the similar construct without the double backslashes:
297 @emph{all} the expressions within this contruct are assigned
298 to new @code{Voice} contexts. These new @code{Voice} contexts
299 are created implicitly and are given the fixed names @code{"1"},
302 The first example could be typeset as follows:
304 @lilypond[quote,relative=3,verbatim]
306 { r8 r16 g e8. f16 g8[ c,] f e16 d }
308 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
312 This syntax can be used where it does not matter that temporary
313 voices are created and then discarded. These implicitly created
314 voices are given the settings equivalent to the effect of the
315 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
316 which they appear in the code.
318 In the following example, the intermediate voice has stems up,
319 therefore we enter it in the third place, so it becomes voice
320 three, which has the stems up as desired. Spacer rests are
321 used to avoid printing doubled rests.
323 @lilypond[quote,relative=3,verbatim]
325 { r8 g g g g f16 ees f8 d }
327 { ees,8 r ees r d r d r }
329 { d'8 s c s bes s a s }
333 In all but the simplest works it is advisable to create explicit
334 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
335 @rlearning{Explicitly instantiating voices}.
337 @strong{@i{Identical rhythms}}
339 In the special case that we want to typeset parallel pieces of music
340 that have the same rhythm, we can combine them into a single
341 @code{Voice} context, thus forming chords. To achieve this, enclose
342 them in a simple simultaneous music construct within an explicit voice:
344 @lilypond[quote,relative=2,verbatim]
346 { e4 f8 d e16 f g8 d4 }
347 { c4 d8 b c16 d e8 b4 }
351 This method leads to strange beamings and warnings if the pieces of
352 music do not have the same rhythm.
366 @rlearning{Voices contain music},
367 @rlearning{Explicitly instantiating voices}.
370 @ref{Percussion staves},
371 @ref{Invisible rests},
375 @rlsr{Simultaneous notes}.
379 @unnumberedsubsubsec Voice styles
382 @cindex styles, voice
383 @cindex coloring voices
384 @funindex \voiceOneStyle
385 @funindex \voiceTwoStyle
386 @funindex \voiceThreeStyle
387 @funindex \voiceFourStyle
388 @funindex \voiceNeutralStyle
390 Voices may be given distinct colors and shapes, allowing them to be
393 @lilypond[quote,relative=2,verbatim]
395 { \voiceOneStyle d4 c2 b4 }
397 { \voiceTwoStyle e,2 e }
399 { \voiceThreeStyle b2. c4 }
401 { \voiceFourStyle g'2 g }
405 The @code{\voiceNeutralstyle} command is used to revert to the
406 standard presentation.
410 @code{\voiceOneStyle},
411 @code{\voiceTwoStyle},
412 @code{\voiceThreeStyle},
413 @code{\voiceFourStyle},
414 @code{\voiceNeutralStyle}.
420 @rlearning{I'm hearing Voices},
421 @rlearning{Other sources of information}.
424 @rlsr{Simultaneous notes}.
427 @node Collision resolution
428 @unnumberedsubsubsec Collision resolution
430 @cindex merging notes
431 @cindex note collisions
434 @cindex multiple voices
435 @cindex voices, multiple
436 @cindex polyphonic music
437 @cindex shifting voices
438 @cindex voices, multiple
439 @cindex shift rest, automatic
448 @funindex \mergeDifferentlyDottedOn
449 @funindex mergeDifferentlyDottedOn
450 @funindex \mergeDifferentlyDottedOff
451 @funindex mergeDifferentlyDottedOff
452 @funindex \mergeDifferentlyHeadedOn
453 @funindex mergeDifferentlyHeadedOn
454 @funindex \mergeDifferentlyHeadedOff
455 @funindex mergeDifferentlyHeadedOff
457 The note heads of notes in different voices with the same pitch,
458 same note head and opposite stem direction are automatically
459 merged, but notes with different note heads or the same stem
460 direction are not. Rests opposite a stem in a different voice
461 are shifted vertically. The following example shows three
462 different circumstances, on beats 1 and 3 in bar 1 and beat 1
463 in bar 2, where the automatic merging fails.
465 @lilypond[quote,verbatim,relative=2]
481 Notes with different note heads may be merged, with the
482 exception of half-note heads and quarter-note heads, as shown
483 below. Here the note heads on beat 1 of bar 1 are now merged:
485 @lilypond[quote,verbatim,relative=2]
488 \mergeDifferentlyHeadedOn
502 Note heads with different dots as shown in beat 2 of bar 1 may be
505 @lilypond[quote,relative=2,verbatim]
508 \mergeDifferentlyHeadedOn
509 \mergeDifferentlyDottedOn
524 The half note and eighth note at the start of the second measure
525 are incorrectly merged because the automatic merge cannot
526 successfully complete the merge when three or more notes line up in
527 the same note column, and in this case the merged note head is
528 incorrect. To allow the merge to select the correct note head
529 a @code{\shift} must be applied to the note that should not be
530 merged. Here, @code{\shiftOn} is applied to move the top
531 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
534 @lilypond[quote,relative=2,verbatim]
537 \mergeDifferentlyHeadedOn
538 \mergeDifferentlyDottedOn
554 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
555 commands specify the degree to which chords of the current voice
556 should be shifted. The outer voices (normally: voices one and
557 two) have @code{\shiftOff}, while the inner voices (three and
558 four) have @code{\shiftOn}. @code{\shiftOnn} and
559 @code{\shiftOnnn} define further shift levels.
561 Notes are only merged if they have opposing stem directions (as
562 they have, for example, in voices one and two by default or when
563 the stems are explicitly set in opposite directions).
567 @code{\mergeDifferentlyDottedOn},
568 @code{\mergeDifferentlyDottedOff},
569 @code{\mergeDifferentlyHeadedOn},
570 @code{\mergeDifferentlyHeadedOff}.
581 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
582 {additional-voices-to-avoid-collisions.ly}
584 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
585 {forcing-horizontal-shift-of-notes.ly}
593 @rlearning{Multiple notes at once},
594 @rlearning{Voices contain music},
595 @rlearning{Real music example}.
598 @rlsr{Simultaneous notes}.
601 @rinternals{NoteColumn},
602 @rinternals{NoteCollision},
603 @rinternals{RestCollision}.
609 @c TODO investigate! Sometimes it works, sometimes not. --FV
610 The requirements for successfully merging different note heads that
611 are at the same time differently dotted are not clear.
614 There is no support for chords where the same note occurs with
615 different accidentals in the same chord. In this case, it is
616 recommended to use enharmonic transcription, or to use special
617 cluster notation (see @ref{Clusters}).
620 @node Automatic part combining
621 @unnumberedsubsubsec Automatic part combining
623 @cindex automatic part combining
624 @cindex part combiner
625 @cindex combining parts
628 @funindex \partcombine
629 @funindex partcombine
631 Automatic part combining is used to merge two parts of music onto
632 a staff. It is aimed at typesetting orchestral scores. When the
633 two parts are identical for a period of time, only one is shown.
634 In places where the two parts differ, they are typeset as separate
635 voices, and stem directions are set automatically. Also, solo and
636 @notation{a due} parts are identified and marked by default.
638 The syntax for part combining is:
641 \partcombine @var{musicexpr1} @var{musicexpr2}
644 The following example demonstrates the basic functionality of the
645 part combiner: putting parts on one staff and setting stem
646 directions and polyphony. The same variables are used for the
647 independent parts and the combined staff.
649 @lilypond[quote,verbatim]
650 instrumentOne = \relative c' {
658 instrumentTwo = \relative g' {
667 \new Staff \instrumentOne
668 \new Staff \instrumentTwo
669 \new Staff \partcombine \instrumentOne \instrumentTwo
673 The notes in the third measure appear only once, although they were
674 specified in both parts. Stem, slur, and tie directions are set
675 automatically, depending whether there is a solo or unison. When
676 needed in polyphony situations, the first part (with context called
677 @code{one}) always gets up stems, while the second (called @code{two})
678 always gets down stems. In solo situations, the first and second
679 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
680 unisono (@notation{a due}) parts are marked by default with the text
683 Both arguments to @code{\partcombine} will be interpreted as
684 @code{Voice} contexts. If using relative octaves,
685 @code{\relative} should be specified for both music expressions,
690 \relative @dots{} @var{musicexpr1}
691 \relative @dots{} @var{musicexpr2}
695 A @code{\relative} section that is outside of @code{\partcombine}
696 has no effect on the pitches of @var{musicexpr1} and
701 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
702 {combining-two-parts-on-the-same-staff.ly}
704 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
705 {changing-partcombine-texts.ly}
717 @rlsr{Simultaneous notes}.
720 @rinternals{PartCombineMusic},
726 @code{\partcombine} can only accept two voices.
728 When @code{printPartCombineTexts} is set, if the two voices play
729 the same notes on and off, the part combiner may typeset @code{a2}
730 more than once in a measure.
732 @code{\partcombine} cannot be inside @code{\times}.
734 @code{\partcombine} cannot be inside @code{\relative}.
736 Internally, the @code{\partcombine} interprets both arguments as
737 @code{Voice}s and decides when the parts can be combined. When they have
738 different durations they cannot be combined and are given the names
739 @code{one} and @code{two}. Consequently, if the arguments switch to
740 differently named @rinternals{Voice} contexts, the events in those will
741 be ignored. Likewise, partcombining isn't designed to work with lyrics;
742 when one of the voices is explicitly named in order to attach lyrics to
743 it, the partcombining stops working.
745 @code{\partcombine} only observes onset times of notes. It cannot
746 determine whether a previously started note is playing or not, leading
750 @node Writing music in parallel
751 @unnumberedsubsubsec Writing music in parallel
753 @cindex writing music in parallel
754 @cindex interleaved music
755 @cindex parallel music
756 @funindex \parallelMusic
757 @funindex parallelMusic
759 Music for multiple parts can be interleaved in input code. The
760 function @code{\parallelMusic} accepts a list with the names of a
761 number of variables to be created, and a musical expression. The
762 content of alternate measures from the expression become the value
763 of the respective variables, so you can use them afterwards to
766 @warning{Bar checks @code{|} must be used, and the measures must
767 be of the same length.}
769 @lilypond[quote,verbatim]
770 \parallelMusic #'(voiceA voiceB voiceC) {
772 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
773 r16 e'8.~ e'4 r16 e'8.~ e'4 |
777 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
778 r16 d'8.~ d'4 r16 d'8.~ d'4 |
783 \new Staff << \voiceA \\ \voiceB >>
784 \new Staff { \clef bass \voiceC }
788 Relative mode may be used. Note that the @code{\relative} command
789 is not used inside @code{\parallelMusic} itself. The notes are
790 relative to the preceding note in the voice, not to the previous
791 note in the input -- in other words, relative notes for
792 @code{voiceA} ignore the notes in @code{voiceB}.
794 @lilypond[quote,verbatim]
795 \parallelMusic #'(voiceA voiceB voiceC) {
797 r8 g16 c e g, c e r8 g,16 c e g, c e |
798 r16 e8.~ e4 r16 e8.~ e4 |
802 r8 a,16 d f a, d f r8 a,16 d f a, d f |
803 r16 d8.~ d4 r16 d8.~ d4 |
808 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
809 \new Staff \relative c' { \clef bass \voiceC }
813 This works quite well for piano music. This example maps four
814 consecutive measures to four variables:
816 @lilypond[quote,verbatim]
822 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
826 c16 d e fis d e fis g |
832 e16 fis g a fis g a b |
843 \relative c'' \voiceA
863 @rlearning{Organizing pieces with variables}.
866 @rlsr{Simultaneous notes}.