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-|
100 Note chords (entered using angle brackets) only are memorized in order
101 to be repeated by @code{q}: it is possible to repeat a chord even if for
102 instance a simple note (without angle brackets) or a rest have been
105 @lilypond[verbatim,quote,relative=1]
111 @file{ly/@/chord-repetition-init@/.ly}.
114 @node Simultaneous expressions
115 @unnumberedsubsubsec Simultaneous expressions
117 One or more music expressions enclosed in double angle brackets are
118 taken to be simultaneous. If the first expression begins with a
119 single note or if the whole simultaneous expression appears
120 explicitly within a single voice, the whole expression is placed on
121 a single staff; otherwise the elements of the simultaneous
122 expression are placed on separate staves.
124 The following examples show simultaneous expressions on one staff:
126 @lilypond[quote,verbatim,relative=2]
127 \new Voice { % explicit single voice
128 << { a4 b g2 } { d4 g c,2 } >>
132 @lilypond[quote,verbatim,relative=2]
134 a << { a4 b g } { d4 g c, } >>
137 This can be useful if the simultaneous sections have identical
138 rhythms, but attempts to attach notes with different durations
139 to the same stem will cause errors.
141 The following example shows how simultaneous expressions can
142 generate multiple staves implicitly:
144 @lilypond[quote,verbatim,relative=2]
145 % no single first note
146 << { a4 b g2 } { d4 g2 c,4 } >>
149 Here different rhythms cause no problems.
153 @unnumberedsubsubsec Clusters
158 @funindex \makeClusters
159 @funindex makeClusters
161 A cluster indicates a continuous range of pitches to be played.
162 They can be denoted as the envelope of a set of notes. They are
163 entered by applying the function @code{\makeClusters} to a sequence
166 @lilypond[quote,relative=2,verbatim]
167 \makeClusters { <g b>2 <c g'> }
170 Ordinary notes and clusters can be put together in the same staff,
171 even simultaneously. In such a case no attempt is made to
172 automatically avoid collisions between ordinary notes and clusters.
180 @rlsr{Simultaneous notes}.
183 @rinternals{ClusterSpanner},
184 @rinternals{ClusterSpannerBeacon},
185 @rinternals{Cluster_spanner_engraver}.
190 Clusters look good only if they span at least two chords; otherwise
191 they appear too narrow.
193 Clusters do not have a stem and cannot indicate durations by
194 themselves, but the length of the printed cluster is determined by
195 the durations of the defining chords. Separate clusters need a
196 separating rest between them.
198 Clusters do not produce MIDI output.
200 @node Multiple voices
201 @subsection Multiple voices
203 This section discusses simultaneous notes in multiple voices or
207 * Single-staff polyphony::
209 * Collision resolution::
210 * Automatic part combining::
211 * Writing music in parallel::
215 @node Single-staff polyphony
216 @unnumberedsubsubsec Single-staff polyphony
218 @cindex single-staff polyphony
219 @cindex polyphony, single-staff
221 @cindex lyrics assigned to one voice
225 @funindex \voiceOne ... \voiceFour
230 @strong{@i{Explicitly instantiating voices}}
232 The basic structure needed to achieve multiple independent
233 voices in a single staff is illustrated in the following example:
235 @lilypond[quote,relative=3,verbatim]
238 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
240 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
245 Here, voices are instantiated explicitly and are given names. The
246 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
247 so that first and third voices get stems up, second and fourth
248 voices get stems down, third and fourth voice note heads are
249 horizontally shifted, and rests in the respective voices are
250 automatically moved to avoid collisions. The @code{\oneVoice}
251 command returns all the voice settings to the neutral default
254 @strong{@i{Temporary polyphonic passages}}
256 A temporary polyphonic passage can be created with the following
260 << @{ \voiceOne ... @}
261 \new Voice @{ \voiceTwo ... @}
266 Here, the first expression within a temporary polyphonic passage is
267 placed into the @code{Voice} context which was in use immediately
268 before the polyphonic passage, and that same @code{Voice} context
269 continues after the temporary section. Other expressions within
270 the angle brackets are assigned to distinct temporary voices.
271 This allows lyrics to be assigned to one continuing voice before,
272 during and after a polyphonic section:
274 @lilypond[quote, verbatim, relative=2]
276 \new Voice = "melody" {
291 \new Lyrics \lyricsto "melody" {
298 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
299 required to define the settings of each voice.
301 @strong{@i{The double backslash construct}}
303 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
304 more) expressions are separated by double backslashes, behaves
305 differently to the similar construct without the double backslashes:
306 @emph{all} the expressions within this contruct are assigned
307 to new @code{Voice} contexts. These new @code{Voice} contexts
308 are created implicitly and are given the fixed names @code{"1"},
311 The first example could be typeset as follows:
313 @lilypond[quote,relative=3,verbatim]
315 { r8 r16 g e8. f16 g8[ c,] f e16 d }
317 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
321 This syntax can be used where it does not matter that temporary
322 voices are created and then discarded. These implicitly created
323 voices are given the settings equivalent to the effect of the
324 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
325 which they appear in the code.
327 In the following example, the intermediate voice has stems up,
328 therefore we enter it in the third place, so it becomes voice
329 three, which has the stems up as desired. Spacer rests are
330 used to avoid printing doubled rests.
332 @lilypond[quote,relative=3,verbatim]
334 { r8 g g g g f16 ees f8 d }
336 { ees,8 r ees r d r d r }
338 { d'8 s c s bes s a s }
342 In all but the simplest works it is advisable to create explicit
343 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
344 @rlearning{Explicitly instantiating voices}.
346 @strong{@i{Identical rhythms}}
348 In the special case that we want to typeset parallel pieces of music
349 that have the same rhythm, we can combine them into a single
350 @code{Voice} context, thus forming chords. To achieve this, enclose
351 them in a simple simultaneous music construct within an explicit voice:
353 @lilypond[quote,relative=2,verbatim]
355 { e4 f8 d e16 f g8 d4 }
356 { c4 d8 b c16 d e8 b4 }
360 This method leads to strange beamings and warnings if the pieces of
361 music do not have the same rhythm.
375 @rlearning{Voices contain music},
376 @rlearning{Explicitly instantiating voices}.
379 @ref{Percussion staves},
380 @ref{Invisible rests},
384 @rlsr{Simultaneous notes}.
388 @unnumberedsubsubsec Voice styles
391 @cindex styles, voice
392 @cindex coloring voices
393 @funindex \voiceOneStyle
394 @funindex \voiceTwoStyle
395 @funindex \voiceThreeStyle
396 @funindex \voiceFourStyle
397 @funindex \voiceNeutralStyle
399 Voices may be given distinct colors and shapes, allowing them to be
402 @lilypond[quote,relative=2,verbatim]
404 { \voiceOneStyle d4 c2 b4 }
406 { \voiceTwoStyle e,2 e }
408 { \voiceThreeStyle b2. c4 }
410 { \voiceFourStyle g'2 g }
414 The @code{\voiceNeutralStyle} command is used to revert to the
415 standard presentation.
419 @code{\voiceOneStyle},
420 @code{\voiceTwoStyle},
421 @code{\voiceThreeStyle},
422 @code{\voiceFourStyle},
423 @code{\voiceNeutralStyle}.
429 @rlearning{I'm hearing Voices},
430 @rlearning{Other sources of information}.
433 @rlsr{Simultaneous notes}.
436 @node Collision resolution
437 @unnumberedsubsubsec Collision resolution
439 @cindex merging notes
440 @cindex note collisions
443 @cindex multiple voices
444 @cindex voices, multiple
445 @cindex polyphonic music
446 @cindex shifting voices
447 @cindex voices, multiple
448 @cindex shift rest, automatic
457 @funindex \mergeDifferentlyDottedOn
458 @funindex mergeDifferentlyDottedOn
459 @funindex \mergeDifferentlyDottedOff
460 @funindex mergeDifferentlyDottedOff
461 @funindex \mergeDifferentlyHeadedOn
462 @funindex mergeDifferentlyHeadedOn
463 @funindex \mergeDifferentlyHeadedOff
464 @funindex mergeDifferentlyHeadedOff
466 The note heads of notes in different voices with the same pitch,
467 same note head and opposite stem direction are automatically
468 merged, but notes with different note heads or the same stem
469 direction are not. Rests opposite a stem in a different voice
470 are shifted vertically. The following example shows three
471 different circumstances, on beats 1 and 3 in bar 1 and beat 1
472 in bar 2, where the automatic merging fails.
474 @lilypond[quote,verbatim,relative=2]
490 Notes with different note heads may be merged, with the
491 exception of half-note heads and quarter-note heads, as shown
492 below. Here the note heads on beat 1 of bar 1 are now merged:
494 @lilypond[quote,verbatim,relative=2]
497 \mergeDifferentlyHeadedOn
511 Note heads with different dots as shown in beat 2 of bar 1 may be
514 @lilypond[quote,relative=2,verbatim]
517 \mergeDifferentlyHeadedOn
518 \mergeDifferentlyDottedOn
533 The half note and eighth note at the start of the second measure
534 are incorrectly merged because the automatic merge cannot
535 successfully complete the merge when three or more notes line up in
536 the same note column, and in this case the merged note head is
537 incorrect. To allow the merge to select the correct note head
538 a @code{\shift} must be applied to the note that should not be
539 merged. Here, @code{\shiftOn} is applied to move the top
540 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
543 @lilypond[quote,relative=2,verbatim]
546 \mergeDifferentlyHeadedOn
547 \mergeDifferentlyDottedOn
563 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
564 commands specify the degree to which chords of the current voice
565 should be shifted. The outer voices (normally: voices one and
566 two) have @code{\shiftOff}, while the inner voices (three and
567 four) have @code{\shiftOn}. @code{\shiftOnn} and
568 @code{\shiftOnnn} define further shift levels.
570 Notes are only merged if they have opposing stem directions (as
571 they have, for example, in voices one and two by default or when
572 the stems are explicitly set in opposite directions).
576 @code{\mergeDifferentlyDottedOn},
577 @code{\mergeDifferentlyDottedOff},
578 @code{\mergeDifferentlyHeadedOn},
579 @code{\mergeDifferentlyHeadedOff}.
590 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
591 {additional-voices-to-avoid-collisions.ly}
593 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
594 {forcing-horizontal-shift-of-notes.ly}
602 @rlearning{Multiple notes at once},
603 @rlearning{Voices contain music},
604 @rlearning{Real music example}.
607 @rlsr{Simultaneous notes}.
610 @rinternals{NoteColumn},
611 @rinternals{NoteCollision},
612 @rinternals{RestCollision}.
618 @c TODO investigate! Sometimes it works, sometimes not. --FV
619 The requirements for successfully merging different note heads that
620 are at the same time differently dotted are not clear.
623 There is no support for chords where the same note occurs with
624 different accidentals in the same chord. In this case, it is
625 recommended to use enharmonic transcription, or to use special
626 cluster notation (see @ref{Clusters}).
629 @node Automatic part combining
630 @unnumberedsubsubsec Automatic part combining
632 @cindex automatic part combining
633 @cindex part combiner
634 @cindex combining parts
637 @funindex \partcombine
638 @funindex partcombine
640 Automatic part combining is used to merge two parts of music onto
641 a staff. It is aimed at typesetting orchestral scores. When the
642 two parts are identical for a period of time, only one is shown.
643 In places where the two parts differ, they are typeset as separate
644 voices, and stem directions are set automatically. Also, solo and
645 @notation{a due} parts are identified and marked by default.
647 The syntax for part combining is:
650 \partcombine @var{musicexpr1} @var{musicexpr2}
653 The following example demonstrates the basic functionality of the
654 part combiner: putting parts on one staff and setting stem
655 directions and polyphony. The same variables are used for the
656 independent parts and the combined staff.
658 @lilypond[quote,verbatim]
659 instrumentOne = \relative c' {
667 instrumentTwo = \relative g' {
676 \new Staff \instrumentOne
677 \new Staff \instrumentTwo
678 \new Staff \partcombine \instrumentOne \instrumentTwo
682 The notes in the third measure appear only once, although they were
683 specified in both parts. Stem, slur, and tie directions are set
684 automatically, depending whether there is a solo or unison. When
685 needed in polyphony situations, the first part (with context called
686 @code{one}) always gets up stems, while the second (called @code{two})
687 always gets down stems. In solo situations, the first and second
688 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
689 unisono (@notation{a due}) parts are marked by default with the text
692 Both arguments to @code{\partcombine} will be interpreted as
693 @code{Voice} contexts. If using relative octaves,
694 @code{\relative} should be specified for both music expressions,
699 \relative @dots{} @var{musicexpr1}
700 \relative @dots{} @var{musicexpr2}
704 A @code{\relative} section that is outside of @code{\partcombine}
705 has no effect on the pitches of @var{musicexpr1} and
710 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
711 {combining-two-parts-on-the-same-staff.ly}
713 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
714 {changing-partcombine-texts.ly}
726 @rlsr{Simultaneous notes}.
729 @rinternals{PartCombineMusic},
735 @code{\partcombine} can only accept two voices.
737 When @code{printPartCombineTexts} is set, if the two voices play
738 the same notes on and off, the part combiner may typeset @code{a2}
739 more than once in a measure.
741 @code{\partcombine} cannot be inside @code{\times}.
743 @code{\partcombine} cannot be inside @code{\relative}.
745 Internally, the @code{\partcombine} interprets both arguments as
746 @code{Voice}s and decides when the parts can be combined. When they have
747 different durations they cannot be combined and are given the names
748 @code{one} and @code{two}. Consequently, if the arguments switch to
749 differently named @rinternals{Voice} contexts, the events in those will
750 be ignored. Likewise, partcombining isn't designed to work with lyrics;
751 when one of the voices is explicitly named in order to attach lyrics to
752 it, the partcombining stops working.
754 @code{\partcombine} only observes onset times of notes. It cannot
755 determine whether a previously started note is playing or not, leading
759 @node Writing music in parallel
760 @unnumberedsubsubsec Writing music in parallel
762 @cindex writing music in parallel
763 @cindex interleaved music
764 @cindex parallel music
765 @funindex \parallelMusic
766 @funindex parallelMusic
768 Music for multiple parts can be interleaved in input code. The
769 function @code{\parallelMusic} accepts a list with the names of a
770 number of variables to be created, and a musical expression. The
771 content of alternate measures from the expression become the value
772 of the respective variables, so you can use them afterwards to
775 @warning{Bar checks @code{|} must be used, and the measures must
776 be of the same length.}
778 @lilypond[quote,verbatim]
779 \parallelMusic #'(voiceA voiceB voiceC) {
781 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
782 r16 e'8.~ e'4 r16 e'8.~ e'4 |
786 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
787 r16 d'8.~ d'4 r16 d'8.~ d'4 |
792 \new Staff << \voiceA \\ \voiceB >>
793 \new Staff { \clef bass \voiceC }
797 Relative mode may be used. Note that the @code{\relative} command
798 is not used inside @code{\parallelMusic} itself. The notes are
799 relative to the preceding note in the voice, not to the previous
800 note in the input -- in other words, relative notes for
801 @code{voiceA} ignore the notes in @code{voiceB}.
803 @lilypond[quote,verbatim]
804 \parallelMusic #'(voiceA voiceB voiceC) {
806 r8 g16 c e g, c e r8 g,16 c e g, c e |
807 r16 e8.~ e4 r16 e8.~ e4 |
811 r8 a,16 d f a, d f r8 a,16 d f a, d f |
812 r16 d8.~ d4 r16 d8.~ d4 |
817 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
818 \new Staff \relative c' { \clef bass \voiceC }
822 This works quite well for piano music. This example maps four
823 consecutive measures to four variables:
825 @lilypond[quote,verbatim]
831 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
835 c16 d e fis d e fis g |
841 e16 fis g a fis g a b |
852 \relative c'' \voiceA
872 @rlearning{Organizing pieces with variables}.
875 @rlsr{Simultaneous notes}.