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 a 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}.
80 @node Simultaneous expressions
81 @unnumberedsubsubsec Simultaneous expressions
83 One or more music expressions enclosed in double angle brackets are
84 taken to be simultaneous. If the first expression begins with a
85 single note or if the whole simultaneous expression appears
86 explicitly within a single voice, the whole expression is placed on
87 a single staff; otherwise the elements of the simultaneous
88 expression are placed on separate staves.
90 The following examples show simultaneous expressions on one staff:
92 @lilypond[quote,verbatim,relative=2]
93 \new Voice { % explicit single voice
94 << {a4 b g2} {d4 g c,2} >>
98 @lilypond[quote,verbatim,relative=2]
100 a << {a4 b g} {d4 g c,} >>
103 This can be useful if the simultaneous sections have identical
104 rhythms, but attempts to attach notes with different durations
105 to the same stem will cause errors.
107 The following example shows how simultaneous expressions can
108 generate multiple staves implicitly:
110 @lilypond[quote,verbatim,relative=2]
111 % no single first note
112 << {a4 b g2} {d4 g2 c,4} >>
115 Here different rhythms cause no problems.
119 @unnumberedsubsubsec Clusters
124 @funindex \makeClusters
125 @funindex makeClusters
127 A cluster indicates a continuous range of pitches to be played.
128 They can be denoted as the envelope of a set of notes. They are
129 entered by applying the function @code{\makeClusters} to a sequence
132 @lilypond[quote,relative=2,verbatim]
133 \makeClusters { <g b>2 <c g'> }
136 Ordinary notes and clusters can be put together in the same staff,
137 even simultaneously. In such a case no attempt is made to
138 automatically avoid collisions between ordinary notes and clusters.
146 @rlsr{Simultaneous notes}.
149 @rinternals{ClusterSpanner},
150 @rinternals{ClusterSpannerBeacon},
151 @rinternals{Cluster_spanner_engraver}.
155 Clusters look good only if they span at least two chords; otherwise
156 they appear too narrow.
158 Clusters do not have a stem and cannot indicate durations by
159 themselves, but the length of the printed cluster is determined by
160 the durations of the defining chords. Separate clusters need a
161 separating rest between them.
163 Clusters do not produce MIDI output.
165 @node Multiple voices
166 @subsection Multiple voices
168 This section discusses simultaneous notes in multiple voices or
172 * Single-staff polyphony::
174 * Collision resolution::
175 * Automatic part combining::
176 * Writing music in parallel::
180 @node Single-staff polyphony
181 @unnumberedsubsubsec Single-staff polyphony
183 @cindex single-staff polyphony
184 @cindex polyphony, single-staff
186 @cindex lyrics assigned to one voice
190 @funindex \voiceOne ... \voiceFour
195 @strong{@i{Explicitly instantiating voices}}
197 The basic structure needed to achieve multiple independent
198 voices in a single staff is illustrated in the following example:
200 @lilypond[quote,relative=3,verbatim]
203 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
205 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
209 Here, voices are instantiated explicitly and are given names. The
210 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
211 so that first and third voices get stems up, second and fourth
212 voices get stems down, third and fourth voice note heads are
213 horizontally shifted, and rests in the respective voices are
214 automatically moved to avoid collisions. The @code{\oneVoice}
215 command returns all the voice settings to the neutral default
218 @strong{@i{Temporary polyphonic passages}}
220 A temporary polyphonic passage can be created with the following
224 << @{ \voiceOne ... @}
225 \new Voice @{ \voiceTwo ... @}
229 Here, the first expression within a temporary polyphonic passage is
230 placed into the @code{Voice} context which was in use immediately
231 before the polyphonic passage, and that same @code{Voice} context
232 continues after the temporary section. Other expressions within
233 the angle brackets are assigned to distinct temporary voices.
234 This allows lyrics to be assigned to one continuing voice before,
235 during and after a polyphonic section:
237 @lilypond[quote, verbatim, relative=2]
239 \new Voice = "melody" {
254 \new Lyrics \lyricsto "melody" {
260 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
261 required to define the settings of each voice.
263 @strong{@i{The double backslash construct}}
265 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
266 more) expressions are separated by double backslashes, behaves
267 differently to the similar construct without the double backslashes:
268 @emph{all} the expressions within this contruct are assigned
269 to new @code{Voice} contexts. These new @code{Voice} contexts
270 are created implicitly and are given the fixed names @code{"1"},
273 The first example could be typeset as follows:
275 @lilypond[quote,relative=3,verbatim]
277 { r8 r16 g e8. f16 g8[ c,] f e16 d }
279 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
283 This syntax can be used where it does not matter that temporary
284 voices are created and then discarded. These implicitly created
285 voices are given the settings equivalent to the effect of the
286 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
287 which they appear in the code.
289 In the following example, the intermediate voice has stems up,
290 therefore we enter it in the third place, so it becomes voice
291 three, which has the stems up as desired. Spacer rests are
292 used to avoid printing doubled rests.
294 @lilypond[quote,relative=3,verbatim]
296 { r8 g g g g f16 ees f8 d }
298 { ees,8 r ees r d r d r }
300 { d'8 s c s bes s a s }
304 In all but the simplest works it is advisable to create explicit
305 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
306 @rlearning{Explicitly instantiating voices}.
308 @strong{@i{Identical rhythms}}
310 In the special case that we want to typeset parallel pieces of music
311 that have the same rhythm, we can combine them into a single
312 @code{Voice} context, thus forming chords. To achieve this, enclose
313 them in a simple simultaneous music construct within an explicit voice:
315 @lilypond[quote,relative=2,verbatim]
317 { e4 f8 d e16 f g8 d4 }
318 { c4 d8 b c16 d e8 b4 }
322 This method leads to strange beamings and warnings if the pieces of
323 music do not have the same rhythm.
336 @rlearning{Voices contain music},
337 @rlearning{Explicitly instantiating voices}.
340 @ref{Percussion staves},
341 @ref{Invisible rests}.
344 @rlsr{Simultaneous notes}.
348 @unnumberedsubsubsec Voice styles
351 @cindex styles, voice
352 @cindex coloring voices
353 @funindex \voiceOneStyle
354 @funindex \voiceTwoStyle
355 @funindex \voiceThreeStyle
356 @funindex \voiceFourStyle
357 @funindex \voiceNeutralStyle
359 Voices may be given distinct colors and shapes, allowing them to be
362 @lilypond[quote,relative=2,verbatim]
364 { \voiceOneStyle d4 c2 b4 }
366 { \voiceTwoStyle e,2 e }
368 { \voiceThreeStyle b2. c4 }
370 { \voiceFourStyle g'2 g }
374 The @code{\voiceNeutralstyle} command is used to revert to the
375 standard presentation.
380 @code{\voiceOneStyle},
382 @code{\voiceTwoStyle},
383 @code{\voiceThreeStyle},
384 @code{\voiceFourStyle},
385 @code{\voiceNeutralStyle}.
390 @rlearning{I'm hearing Voices},
391 @rlearning{Other sources of information}.
394 @rlsr{Simultaneous notes}.
397 @node Collision resolution
398 @unnumberedsubsubsec Collision resolution
400 @cindex merging notes
401 @cindex note collisions
404 @cindex multiple voices
405 @cindex voices, multiple
406 @cindex polyphonic music
407 @cindex shifting voices
408 @cindex voices, multiple
409 @cindex shift rest, automatic
418 @funindex \mergeDifferentlyDottedOn
419 @funindex mergeDifferentlyDottedOn
420 @funindex \mergeDifferentlyDottedOff
421 @funindex mergeDifferentlyDottedOff
422 @funindex \mergeDifferentlyHeadedOn
423 @funindex mergeDifferentlyHeadedOn
424 @funindex \mergeDifferentlyHeadedOff
425 @funindex mergeDifferentlyHeadedOff
427 The note heads of notes in different voices with the same pitch,
428 same note head and opposite stem direction are automatically
429 merged, but notes with different note heads or the same stem
430 direction are not. Rests opposite a stem in a different voice
431 are shifted vertically.
433 @lilypond[quote,verbatim,relative=2]
449 Notes with different note heads may be merged, with the
450 exception of half-note heads and quarter-note heads:
452 @lilypond[quote,verbatim,relative=2]
455 \mergeDifferentlyHeadedOn
469 Note heads with different dots may be merged:
471 @lilypond[quote,relative=2,verbatim]
474 \mergeDifferentlyHeadedOn
475 \mergeDifferentlyDottedOn
490 The half note and eighth note at the start of the second measure
491 are incorrectly merged because @code{\mergeDifferentlyHeadedOn}
492 cannot successfully complete the merge when three or more notes
493 line up in the same column, and in this case a warning is given.
494 To allow the merge to work properly a @code{\shift} must be applied
495 to the note that should not be merged. Here, @code{\shiftOn} is
496 applied to move the top @notation{g} out of the column, and
497 @code{\mergeDifferentlyHeadedOn} then works properly.
499 @lilypond[quote,relative=2,verbatim]
502 \mergeDifferentlyHeadedOn
503 \mergeDifferentlyDottedOn
519 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
520 commands specify the degree to which chords of the current voice
521 should be shifted. The outer voices (normally: voices one and
522 two) have @code{\shiftOff}, while the inner voices (three and
523 four) have @code{\shiftOn}. @code{\shiftOnn} and
524 @code{\shiftOnnn} define further shift levels.
526 Notes are only merged if they have opposing stem directions (e.g. in
527 @code{Voice} 1 and 2).
532 @code{\mergeDifferentlyDottedOn},
533 @code{\mergeDifferentlyDottedOff},
534 @code{\mergeDifferentlyHeadedOn},
535 @code{\mergeDifferentlyHeadedOff}.
544 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
545 {additional-voices-to-avoid-collisions.ly}
547 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
548 {forcing-horizontal-shift-of-notes.ly}
556 @rlearning{Multiple notes at once},
557 @rlearning{Voices contain music},
558 @rlearning{Collisions of objects}.
561 @rlsr{Simultaneous notes}.
564 @rinternals{NoteColumn},
565 @rinternals{NoteCollision},
566 @rinternals{RestCollision}.
570 When using @code{\mergeDifferentlyHeadedOn} with an upstem eighth
571 or a shorter note, and a downstem half note, the eighth note stem
572 gets a slightly wrong offset because of the different width of the
573 half note head symbol.
576 @c TODO investigate! Sometimes it works, sometimes not. --FV
577 The requirements for successfully merging different note heads that
578 are at the same time differently dotted are not clear.
581 There is no support for chords where the same note occurs with
582 different accidentals in the same chord. In this case, it is
583 recommended to use enharmonic transcription, or to use special
584 cluster notation (see @ref{Clusters}).
587 @node Automatic part combining
588 @unnumberedsubsubsec Automatic part combining
590 @cindex automatic part combining
591 @cindex part combiner
592 @cindex combining parts
595 @funindex \partcombine
596 @funindex partcombine
598 Automatic part combining is used to merge two parts of music onto
599 a staff. It is aimed at typesetting orchestral scores. When the
600 two parts are identical for a period of time, only one is shown.
601 In places where the two parts differ, they are typeset as separate
602 voices, and stem directions are set automatically. Also, solo and
603 @notation{a due} parts are identified and marked by default.
605 The syntax for part combining is:
608 \partcombine @var{musicexpr1} @var{musicexpr2}
611 The following example demonstrates the basic functionality of the
612 part combiner: putting parts on one staff and setting stem
613 directions and polyphony. The same variables are used for the
614 independent parts and the combined staff.
616 @lilypond[quote,verbatim]
617 instrumentOne = \relative c' {
625 instrumentTwo = \relative g' {
634 \new Staff \instrumentOne
635 \new Staff \instrumentTwo
636 \new Staff \partcombine \instrumentOne \instrumentTwo
640 The notes in the third measure appear only once, although they were
641 specified in both parts. Stem, slur, and tie directions are set
642 automatically, depending whether there is a solo or unison. When
643 needed in polyphony situations, the first part (with context called
644 @code{one}) always gets up stems, while the second (called @code{two})
645 always gets down stems. In solo situations, the first and second
646 parts get marked with @q{Solo} and @q{Solo II}, respectively. The
647 unisono (@notation{a due}) parts are marked by default with the text
650 Both arguments to @code{\partcombine} will be interpreted as
651 @code{Voice} contexts. If using relative octaves,
652 @code{\relative} should be specified for both music expressions,
657 \relative @dots{} @var{musicexpr1}
658 \relative @dots{} @var{musicexpr2}
662 A @code{\relative} section that is outside of @code{\partcombine}
663 has no effect on the pitches of @var{musicexpr1} and
668 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
669 {combining-two-parts-on-the-same-staff.ly}
671 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
672 {changing-partcombine-texts.ly}
684 @rlsr{Simultaneous notes}.
687 @rinternals{PartCombineMusic},
692 @code{\partcombine} can only accept two voices.
694 When @code{printPartCombineTexts} is set, if the two voices play
695 the same notes on and off, the part combiner may typeset @code{a2}
696 more than once in a measure.
698 @code{\partcombine} cannot be inside @code{\times}.
700 @code{\partcombine} cannot be inside @code{\relative}.
702 Internally, the @code{\partcombine} interprets both arguments as
703 @code{Voice}s and decides when the parts can be combined. When they have
704 different durations they cannot be combined and are given the names
705 @code{one} and @code{two}. Consequently, if the arguments switch to
706 differently named @rinternals{Voice} contexts, the events in those will
707 be ignored. Likewise, partcombining isn't designed to work with lyrics;
708 when one of the voices is explicitly named in order to attach lyrics to
709 it, the partcombining stops working.
711 @code{\partcombine} only observes onset times of notes. It cannot
712 determine whether a previously started note is playing or not, leading
716 @node Writing music in parallel
717 @unnumberedsubsubsec Writing music in parallel
719 @cindex writing music in parallel
720 @cindex interleaved music
721 @cindex parallel music
722 @funindex \parallelMusic
723 @funindex parallelMusic
725 Music for multiple parts can be interleaved in input code. The
726 function @code{\parallelMusic} accepts a list with the names of a
727 number of variables to be created, and a musical expression. The
728 content of alternate measures from the expression become the value
729 of the respective variables, so you can use them afterwards to
732 @warning{Bar checks @code{|} must be used, and the measures must
733 be of the same length.}
735 @lilypond[quote,verbatim]
736 \parallelMusic #'(voiceA voiceB voiceC) {
738 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
739 r16 e'8.~ e'4 r16 e'8.~ e'4 |
743 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
744 r16 d'8.~ d'4 r16 d'8.~ d'4 |
749 \new Staff << \voiceA \\ \voiceB >>
750 \new Staff { \clef bass \voiceC }
754 Relative mode may be used. Note that the @code{\relative} command
755 is not used inside @code{\parallelMusic} itself. The notes are
756 relative to the preceding note in the voice, not to the previous
757 note in the input -- in other words, relative notes for
758 @code{voiceA} ignore the notes in @code{voiceB}.
760 @lilypond[quote,verbatim]
761 \parallelMusic #'(voiceA voiceB voiceC) {
763 r8 g16 c e g, c e r8 g,16 c e g, c e |
764 r16 e8.~ e4 r16 e8.~ e4 |
768 r8 a,16 d f a, d f r8 a,16 d f a, d f |
769 r16 d8.~ d4 r16 d8.~ d4 |
774 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
775 \new Staff \relative c' { \clef bass \voiceC }
779 This works quite well for piano music. This example maps four
780 consecutive measures to four variables:
782 @lilypond[quote,verbatim]
788 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
792 c16 d e fis d e fis g |
798 e16 fis g a fis g a b |
809 \relative c'' \voiceA
829 @rlearning{Organizing pieces with variables}.
832 @rlsr{Simultaneous notes}.