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.
463 @lilypond[quote,verbatim,relative=2]
479 Notes with different note heads may be merged, with the
480 exception of half-note heads and quarter-note heads:
482 @lilypond[quote,verbatim,relative=2]
485 \mergeDifferentlyHeadedOn
499 Note heads with different dots may be merged:
501 @lilypond[quote,relative=2,verbatim]
504 \mergeDifferentlyHeadedOn
505 \mergeDifferentlyDottedOn
520 The half note and eighth note at the start of the second measure
521 are incorrectly merged because @code{\mergeDifferentlyHeadedOn}
522 cannot successfully complete the merge when three or more notes
523 line up in the same column, and in this case a warning is given.
524 To allow the merge to work properly a @code{\shift} must be applied
525 to the note that should not be merged. Here, @code{\shiftOn} is
526 applied to move the top @notation{g} out of the column, and
527 @code{\mergeDifferentlyHeadedOn} then works properly.
529 @lilypond[quote,relative=2,verbatim]
532 \mergeDifferentlyHeadedOn
533 \mergeDifferentlyDottedOn
549 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
550 commands specify the degree to which chords of the current voice
551 should be shifted. The outer voices (normally: voices one and
552 two) have @code{\shiftOff}, while the inner voices (three and
553 four) have @code{\shiftOn}. @code{\shiftOnn} and
554 @code{\shiftOnnn} define further shift levels.
556 Notes are only merged if they have opposing stem directions (e.g. in
557 @code{Voice} 1 and 2).
561 @code{\mergeDifferentlyDottedOn},
562 @code{\mergeDifferentlyDottedOff},
563 @code{\mergeDifferentlyHeadedOn},
564 @code{\mergeDifferentlyHeadedOff}.
575 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
576 {additional-voices-to-avoid-collisions.ly}
578 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
579 {forcing-horizontal-shift-of-notes.ly}
587 @rlearning{Multiple notes at once},
588 @rlearning{Voices contain music},
589 @rlearning{Collisions of objects}.
592 @rlsr{Simultaneous notes}.
595 @rinternals{NoteColumn},
596 @rinternals{NoteCollision},
597 @rinternals{RestCollision}.
603 @c TODO investigate! Sometimes it works, sometimes not. --FV
604 The requirements for successfully merging different note heads that
605 are at the same time differently dotted are not clear.
608 There is no support for chords where the same note occurs with
609 different accidentals in the same chord. In this case, it is
610 recommended to use enharmonic transcription, or to use special
611 cluster notation (see @ref{Clusters}).
614 @node Automatic part combining
615 @unnumberedsubsubsec Automatic part combining
617 @cindex automatic part combining
618 @cindex part combiner
619 @cindex combining parts
622 @funindex \partcombine
623 @funindex partcombine
625 Automatic part combining is used to merge two parts of music onto
626 a staff. It is aimed at typesetting orchestral scores. When the
627 two parts are identical for a period of time, only one is shown.
628 In places where the two parts differ, they are typeset as separate
629 voices, and stem directions are set automatically. Also, solo and
630 @notation{a due} parts are identified and marked by default.
632 The syntax for part combining is:
635 \partcombine @var{musicexpr1} @var{musicexpr2}
638 The following example demonstrates the basic functionality of the
639 part combiner: putting parts on one staff and setting stem
640 directions and polyphony. The same variables are used for the
641 independent parts and the combined staff.
643 @lilypond[quote,verbatim]
644 instrumentOne = \relative c' {
652 instrumentTwo = \relative g' {
661 \new Staff \instrumentOne
662 \new Staff \instrumentTwo
663 \new Staff \partcombine \instrumentOne \instrumentTwo
667 The notes in the third measure appear only once, although they were
668 specified in both parts. Stem, slur, and tie directions are set
669 automatically, depending whether there is a solo or unison. When
670 needed in polyphony situations, the first part (with context called
671 @code{one}) always gets up stems, while the second (called @code{two})
672 always gets down stems. In solo situations, the first and second
673 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
674 unisono (@notation{a due}) parts are marked by default with the text
677 Both arguments to @code{\partcombine} will be interpreted as
678 @code{Voice} contexts. If using relative octaves,
679 @code{\relative} should be specified for both music expressions,
684 \relative @dots{} @var{musicexpr1}
685 \relative @dots{} @var{musicexpr2}
689 A @code{\relative} section that is outside of @code{\partcombine}
690 has no effect on the pitches of @var{musicexpr1} and
695 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
696 {combining-two-parts-on-the-same-staff.ly}
698 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
699 {changing-partcombine-texts.ly}
711 @rlsr{Simultaneous notes}.
714 @rinternals{PartCombineMusic},
720 @code{\partcombine} can only accept two voices.
722 When @code{printPartCombineTexts} is set, if the two voices play
723 the same notes on and off, the part combiner may typeset @code{a2}
724 more than once in a measure.
726 @code{\partcombine} cannot be inside @code{\times}.
728 @code{\partcombine} cannot be inside @code{\relative}.
730 Internally, the @code{\partcombine} interprets both arguments as
731 @code{Voice}s and decides when the parts can be combined. When they have
732 different durations they cannot be combined and are given the names
733 @code{one} and @code{two}. Consequently, if the arguments switch to
734 differently named @rinternals{Voice} contexts, the events in those will
735 be ignored. Likewise, partcombining isn't designed to work with lyrics;
736 when one of the voices is explicitly named in order to attach lyrics to
737 it, the partcombining stops working.
739 @code{\partcombine} only observes onset times of notes. It cannot
740 determine whether a previously started note is playing or not, leading
744 @node Writing music in parallel
745 @unnumberedsubsubsec Writing music in parallel
747 @cindex writing music in parallel
748 @cindex interleaved music
749 @cindex parallel music
750 @funindex \parallelMusic
751 @funindex parallelMusic
753 Music for multiple parts can be interleaved in input code. The
754 function @code{\parallelMusic} accepts a list with the names of a
755 number of variables to be created, and a musical expression. The
756 content of alternate measures from the expression become the value
757 of the respective variables, so you can use them afterwards to
760 @warning{Bar checks @code{|} must be used, and the measures must
761 be of the same length.}
763 @lilypond[quote,verbatim]
764 \parallelMusic #'(voiceA voiceB voiceC) {
766 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
767 r16 e'8.~ e'4 r16 e'8.~ e'4 |
771 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
772 r16 d'8.~ d'4 r16 d'8.~ d'4 |
777 \new Staff << \voiceA \\ \voiceB >>
778 \new Staff { \clef bass \voiceC }
782 Relative mode may be used. Note that the @code{\relative} command
783 is not used inside @code{\parallelMusic} itself. The notes are
784 relative to the preceding note in the voice, not to the previous
785 note in the input -- in other words, relative notes for
786 @code{voiceA} ignore the notes in @code{voiceB}.
788 @lilypond[quote,verbatim]
789 \parallelMusic #'(voiceA voiceB voiceC) {
791 r8 g16 c e g, c e r8 g,16 c e g, c e |
792 r16 e8.~ e4 r16 e8.~ e4 |
796 r8 a,16 d f a, d f r8 a,16 d f a, d f |
797 r16 d8.~ d4 r16 d8.~ d4 |
802 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
803 \new Staff \relative c' { \clef bass \voiceC }
807 This works quite well for piano music. This example maps four
808 consecutive measures to four variables:
810 @lilypond[quote,verbatim]
816 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
820 c16 d e fis d e fis g |
826 e16 fis g a fis g a b |
837 \relative c'' \voiceA
857 @rlearning{Organizing pieces with variables}.
860 @rlsr{Simultaneous notes}.