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. For details, see the Contributors'
7 Guide, node Updating translation committishes..
13 @node Simultaneous notes
14 @section Simultaneous notes
16 @lilypondfile[quote]{simultaneous-headword.ly}
18 Polyphony in music refers to having more than one voice occurring
19 in a piece of music. Polyphony in LilyPond refers to having more
20 than one voice on the same staff.
29 @subsection Single voice
31 This section discusses simultaneous notes inside the same voice.
36 * Simultaneous expressions::
42 @unnumberedsubsubsec Chorded notes
45 @cindex brackets, angle
51 A chord is formed by enclosing a set of pitches between @code{<}
52 and @code{>}. A chord may be followed by a duration just like simple
55 @lilypond[verbatim,quote,relative=2]
56 <a c e>1 <a c e>2 <f a c e>4 <a c>8. <g c e>16
59 Chords may also be followed by articulations, again just like simple
62 @lilypond[verbatim,quote,relative=2]
63 <a c e>1\fermata <a c e>2-> <f a c e>4\prall <a c>8.^| <g c e>16-.
66 The notes within the chord themselves can also be followed by articulation
69 @lilypond[verbatim,quote,relative=2]
70 <a c\prall e>1 <a-> c-^ e>2 <f-. a c-. e-.>4 <a-+ c-->8. <g\fermata c e\turn>16
73 However some notation, such as dynamics, hairpins and slurs must be
74 attached to the chord, rather than notes within the chord, otherwise
77 @lilypond[verbatim,quote,relative=2]
78 <a\f c( e>1 <a c) e>\f <a\< c e>( <a\! c e>) <a c e>\< <a c e> <a c e>\!
81 @cindex relative pitch, chords
82 @cindex chords, relative pitch
84 Relative mode can be used for pitches in chords. The first note of
85 each chord is always relative to the first note of the chord that
86 came before it, or in the case where no preceding chord exists, the
87 pitch of the last note that came before the chord. All remaining notes
88 in the chord are relative to the note that came before it
89 @emph{within the same chord}.
91 @lilypond[verbatim,quote,relative=2]
92 <a c e>1 <f a c> <a c e> <f' a c> <b, e b,>
95 For more information about chords, see @ref{Chord notation}.
102 @rlearning{Combining notes into chords}.
105 @ref{Chord notation},
106 @ref{Articulations and ornamentations},
107 @ref{Relative octave entry},
108 @ref{Multiple voices}.
111 @rlsr{Simultaneous notes}.
114 Chords containing more than two pitches within a staff space,
115 such as @samp{<e f! fis!>}, create overlapping noteheads.
116 Depending on the situation, better representations might involve
121 temporary use of @ref{Multiple voices},
122 @samp{<< f! \\ <e fis!> >>},
125 enharmonic transcription of one or more pitches,
133 @node Chord repetition
134 @unnumberedsubsubsec Chord repetition
136 @cindex Chord, repetition
137 @cindex repetition, using @code{q}
139 In order to save typing, a shortcut can be used to repeat the preceding
140 chord. The chord repetition symbol is @code{q}:
142 @lilypond[verbatim,quote,relative=2]
143 <a c e>1 q <f a c>2 q
146 As with regular chords, the chord repetition symbol can be used with
147 durations, articulations, markups, slurs, beams, etc. as only the
148 pitches of the previous chord are duplicated.
150 @lilypond[verbatim,quote,relative=2]
151 <a c e>1\p^"text" q2\<( q8)[-| q8.]\! q16-1-2-3 q8\prall
154 The chord repetition symbol always remembers the last instance of
155 a chord so it is possible to repeat the most recent chord even if
156 other non-chorded notes or rests have been added since.
158 @lilypond[verbatim,quote,relative=2]
159 <a c e>1 c'4 q2 r8 q8 |
163 However, the chord repetition symbol does not retain any dynamics,
164 articulation or ornamentation within, or attached to, the previous
167 @lilypond[verbatim,quote,relative=2]
168 <a-. c\prall e>1\sfz c'4 q2 r8 q8 |
172 To have some of them retained, the @code{\chordRepeats} function can be
173 be called explicitly with an extra argument specifying a list of
174 @var{event types} to keep unless events of that type are already
175 present on the @code{q} chord itself.
177 @lilypond[verbatim,quote]
179 \chordRepeats #'(articulation-event)
180 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
185 Here using @code{\chordRepeats} inside of a @code{\relative} construction
186 produces unexpected results: once chord events have been expanded, they
187 are indistinguishable from having been entered as regular chords, making
188 @code{\relative} assign an octave based on their current context.
190 Since nested instances of @code{\relative} don't affect one another,
191 another @code{\relative} inside of @code{\chordRepeats} can be used for
192 establishing the octave relations before expanding the repeat chords.
193 In that case, the whole content of the inner @code{\relative} does not
194 affect the outer one; hence the different octave entry of the final note
197 @c Without \new Voice, implicit voice creation does the dumbest thing.
198 @lilypond[verbatim,quote]
201 \chordRepeats #'(articulation-event)
203 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
208 Interactions with @code{\relative} occur only with explicit calls of
209 @code{\chordRepeats}: the implicit expansion at the start of typesetting
210 is done at a time where all instances of @code{\relative} have already
215 @ref{Chord notation},
216 @ref{Articulations and ornamentations}.
219 @file{ly/chord-repetition-init.ly}.
222 @node Simultaneous expressions
223 @unnumberedsubsubsec Simultaneous expressions
225 One or more music expressions enclosed in double angle brackets are
226 taken to be simultaneous. If the first expression begins with a
227 single note or if the whole simultaneous expression appears
228 explicitly within a single voice, the whole expression is placed on
229 a single staff; otherwise the elements of the simultaneous
230 expression are placed on separate staves.
232 The following examples show simultaneous expressions on one staff:
234 @lilypond[quote,verbatim,relative=2]
235 \new Voice { % explicit single voice
236 << { a4 b g2 } { d4 g c,2 } >>
240 @lilypond[quote,verbatim,relative=2]
242 a << { a4 b g } { d4 g c, } >>
245 This can be useful if the simultaneous sections have identical
246 rhythms, but attempts to attach notes with different durations
247 to the same stem will cause errors.
249 The following example shows how simultaneous expressions can
250 generate multiple staves implicitly:
252 @lilypond[quote,verbatim,relative=2]
253 % no single first note
254 << { a4 b g2 } { d4 g2 c,4 } >>
257 Here different rhythms cause no problems.
259 @cindex collisions, clashing note columns
260 @cindex collisions, ignoring
263 If notes from two or more voices, with stems in the same direction, are
264 placed at the same position on the staff and have no shift (or have the
265 same shift specified), the message:
268 warning: ignoring too many clashing note columns
271 will appear during compilation. This message can be suppressed by:
274 \override NoteColumn #'ignore-collision = ##t
277 However, this not only suppresses the warning but will prevent any
278 collision resolution whatsover and may have other unintended effects
279 (also see @emph{Known Issues} in @ref{Collision resolution}).
283 @unnumberedsubsubsec Clusters
288 @funindex \makeClusters
289 @funindex makeClusters
291 A cluster indicates a continuous range of pitches to be played.
292 They can be denoted as the envelope of a set of notes. They are
293 entered by applying the function @code{\makeClusters} to a sequence
296 @lilypond[quote,relative=2,verbatim]
297 \makeClusters { <g b>2 <c g'> }
300 Ordinary notes and clusters can be put together in the same staff,
301 even simultaneously. In such a case no attempt is made to
302 automatically avoid collisions between ordinary notes and clusters.
310 @rlsr{Simultaneous notes}.
313 @rinternals{ClusterSpanner},
314 @rinternals{ClusterSpannerBeacon},
315 @rinternals{Cluster_spanner_engraver}.
320 Clusters look good only if they span at least two chords; otherwise
321 they appear too narrow.
323 Clusters do not have a stem and cannot indicate durations by
324 themselves, but the length of the printed cluster is determined by
325 the durations of the defining chords. Separate clusters need a
326 separating rest between them.
328 Clusters do not produce MIDI output.
330 @node Multiple voices
331 @subsection Multiple voices
333 This section discusses simultaneous notes in multiple voices or
337 * Single-staff polyphony::
339 * Collision resolution::
340 * Automatic part combining::
341 * Writing music in parallel::
345 @node Single-staff polyphony
346 @unnumberedsubsubsec Single-staff polyphony
348 @cindex single-staff polyphony
349 @cindex polyphony, single-staff
351 @cindex lyrics assigned to one voice
355 @funindex \voiceOne ... \voiceFour
360 @strong{@i{Explicitly instantiating voices}}
362 The basic structure needed to achieve multiple independent
363 voices in a single staff is illustrated in the following example:
365 @lilypond[quote,relative=3,verbatim]
368 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
370 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
375 Here, voices are instantiated explicitly and are given names. The
376 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
377 so that first and third voices get stems up, second and fourth
378 voices get stems down, third and fourth voice note heads are
379 horizontally shifted, and rests in the respective voices are
380 automatically moved to avoid collisions. The @code{\oneVoice}
381 command returns all the voice settings to the neutral default
384 @strong{@i{Temporary polyphonic passages}}
386 A temporary polyphonic passage can be created with the following
390 << @{ \voiceOne ... @}
391 \new Voice @{ \voiceTwo ... @}
396 Here, the first expression within a temporary polyphonic passage is
397 placed into the @code{Voice} context which was in use immediately
398 before the polyphonic passage, and that same @code{Voice} context
399 continues after the temporary section. Other expressions within
400 the angle brackets are assigned to distinct temporary voices.
401 This allows lyrics to be assigned to one continuing voice before,
402 during and after a polyphonic section:
404 @lilypond[quote, verbatim, relative=2]
406 \new Voice = "melody" {
421 \new Lyrics \lyricsto "melody" {
428 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
429 required to define the settings of each voice.
431 @strong{@i{The double backslash construct}}
433 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
434 more) expressions are separated by double backslashes, behaves
435 differently to the similar construct without the double backslashes:
436 @emph{all} the expressions within this construct are assigned
437 to new @code{Voice} contexts. These new @code{Voice} contexts
438 are created implicitly and are given the fixed names @code{"1"},
441 The first example could be typeset as follows:
443 @lilypond[quote,relative=3,verbatim]
445 { r8 r16 g e8. f16 g8[ c,] f e16 d }
447 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
451 This syntax can be used where it does not matter that temporary
452 voices are created and then discarded. These implicitly created
453 voices are given the settings equivalent to the effect of the
454 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
455 which they appear in the code.
457 In the following example, the intermediate voice has stems up,
458 therefore we enter it in the third place, so it becomes voice
459 three, which has the stems up as desired. Spacer rests are
460 used to avoid printing doubled rests.
462 @lilypond[quote,relative=3,verbatim]
464 { r8 g g g g f16 ees f8 d }
466 { ees,8 r ees r d r d r }
468 { d'8 s c s bes s a s }
472 In all but the simplest works it is advisable to create explicit
473 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
474 @rlearning{Explicitly instantiating voices}.
476 @strong{@i{Voice order}}
478 When entering multiple voices in the input file, use the following
484 Voice 3: second highest
485 Voice 4: second lowest
486 Voice 5: third highest
487 Voice 6: third lowest
491 Though this may seem counterintuitive, it simplifies the automatic
492 layout process. Note that the odd-numbered voices are given
493 upstems, and the even-numbered voices are given downstems:
495 @lilypond[quote,verbatim]
498 { f''2 } % 1: highest
502 { d''2 } % 3: second-highest
504 { e'2 } % 4: second-lowest
506 { b'2 } % 5: third-highest
508 { g'2 } % 6: third-lowest
512 @warning{Lyrics, spanners (such as slurs, ties, hairpins etc.) cannot be
513 created @q{across} voices.}
515 @strong{@i{Identical rhythms}}
517 In the special case that we want to typeset parallel pieces of music
518 that have the same rhythm, we can combine them into a single
519 @code{Voice} context, thus forming chords. To achieve this, enclose
520 them in a simple simultaneous music construct within an explicit voice:
522 @lilypond[quote,relative=2,verbatim]
524 { e4 f8 d e16 f g8 d4 }
525 { c4 d8 b c16 d e8 b4 }
529 This method leads to strange beamings and warnings if the pieces of
530 music do not have the same rhythm.
542 @rlsr{Simultaneous notes}.
546 @rlearning{Voices contain music},
547 @rlearning{Explicitly instantiating voices}.
550 @ref{Percussion staves},
551 @ref{Invisible rests},
556 @unnumberedsubsubsec Voice styles
559 @cindex styles, voice
560 @cindex coloring voices
561 @funindex \voiceOneStyle
562 @funindex \voiceTwoStyle
563 @funindex \voiceThreeStyle
564 @funindex \voiceFourStyle
565 @funindex \voiceNeutralStyle
567 Voices may be given distinct colors and shapes, allowing them to be
570 @lilypond[quote,relative=2,verbatim]
572 { \voiceOneStyle d4 c2 b4 }
574 { \voiceTwoStyle e,2 e }
576 { \voiceThreeStyle b2. c4 }
578 { \voiceFourStyle g'2 g }
582 The @code{\voiceNeutralStyle} command is used to revert to the
583 standard presentation.
587 @code{\voiceOneStyle},
588 @code{\voiceTwoStyle},
589 @code{\voiceThreeStyle},
590 @code{\voiceFourStyle},
591 @code{\voiceNeutralStyle}.
597 @rlearning{I'm hearing Voices},
598 @rlearning{Other sources of information}.
601 @rlsr{Simultaneous notes}.
604 @node Collision resolution
605 @unnumberedsubsubsec Collision resolution
607 @cindex merging notes
608 @cindex note collisions
611 @cindex multiple voices
612 @cindex voices, multiple
613 @cindex polyphonic music
614 @cindex shifting voices
615 @cindex voices, multiple
616 @cindex shift rest, automatic
625 @funindex \mergeDifferentlyDottedOn
626 @funindex mergeDifferentlyDottedOn
627 @funindex \mergeDifferentlyDottedOff
628 @funindex mergeDifferentlyDottedOff
629 @funindex \mergeDifferentlyHeadedOn
630 @funindex mergeDifferentlyHeadedOn
631 @funindex \mergeDifferentlyHeadedOff
632 @funindex mergeDifferentlyHeadedOff
634 The note heads of notes in different voices with the same pitch,
635 same note head and opposite stem direction are automatically
636 merged, but notes with different note heads or the same stem
637 direction are not. Rests opposite a stem in a different voice
638 are shifted vertically. The following example shows three
639 different circumstances, on beats 1 and 3 in bar 1 and beat 1
640 in bar 2, where the automatic merging fails.
642 @lilypond[quote,verbatim,relative=2]
658 Notes with different note heads may be merged, with the
659 exception of half-note heads and quarter-note heads, as shown
660 below. Here the note heads on beat 1 of bar 1 are now merged:
662 @lilypond[quote,verbatim,relative=2]
665 \mergeDifferentlyHeadedOn
679 Note heads with different dots as shown in beat 3 of bar 1 may be
682 @lilypond[quote,relative=2,verbatim]
685 \mergeDifferentlyHeadedOn
686 \mergeDifferentlyDottedOn
700 The half note and eighth note at the start of the second measure
701 are incorrectly merged because the automatic merge cannot
702 successfully complete the merge when three or more notes line up in
703 the same note column, and in this case the merged note head is
704 incorrect. To allow the merge to select the correct note head
705 a @code{\shift} must be applied to the note that should not be
706 merged. Here, @code{\shiftOn} is applied to move the top
707 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
710 @lilypond[quote,relative=2,verbatim]
713 \mergeDifferentlyHeadedOn
714 \mergeDifferentlyDottedOn
729 The @code{\shiftOn} command allows (but does not force) the notes
730 in a voice to be shifted. When @code{\shiftOn} is applied to a
731 voice, a note or chord in that voice is shifted only if its stem
732 would otherwise collide with a stem from another voice, and only
733 if the colliding stems point in the same direction. The
734 @code{\shiftOff} command prevents this type of shifting from
737 By default, the outer voices (normally voices one and two) have
738 @code{\shiftOff} specified, while the inner voices (three and
739 above) have @code{\shiftOn} specified. When a shift is applied,
740 voices with upstems (odd-numbered voices) are shifted to the
741 right, and voices with downstems (even-numbered voices) are
744 Here is an example to help you visualize how an abbreviated
745 polyphonic expression would be expanded internally.
747 @warning{Note that with three or more voices, the vertical order
748 of voices in your input file should not be the same as the
749 vertical order of voices on the staff!}
751 @lilypond[quote,verbatim]
752 \new Staff \relative c'' {
759 { d'2 } % 3: upper middle
761 { b2 } % 4: lower middle
763 %% internal expansion of the above
765 \new Voice = "1" { \voiceOne \shiftOff f'2 }
766 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
767 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
768 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
773 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
774 provide further shift levels which may be specified temporarily to
775 resolve collisions in complex situations -- see
776 @rlearning{Real music example}.
778 Notes are only merged if they have opposing stem directions (as
779 they have, for example, in voices one and two by default or when
780 the stems are explicitly set in opposite directions).
783 @code{\mergeDifferentlyDottedOn},
784 @code{\mergeDifferentlyDottedOff},
785 @code{\mergeDifferentlyHeadedOn},
786 @code{\mergeDifferentlyHeadedOff}.
795 @lilypondfile[verbatim,quote,texidoc,doctitle]
796 {additional-voices-to-avoid-collisions.ly}
798 @lilypondfile[verbatim,quote,texidoc,doctitle]
799 {forcing-horizontal-shift-of-notes.ly}
806 @rlearning{Multiple notes at once},
807 @rlearning{Voices contain music},
808 @rlearning{Real music example}.
811 @rlsr{Simultaneous notes}.
814 @rinternals{NoteColumn},
815 @rinternals{NoteCollision},
816 @rinternals{RestCollision}.
818 @cindex collisions, ignoring
821 Using @code{\override NoteColumn #'ignore-collision = ##t} will cause
822 differently headed notes in different voices to merge incorrectly.
824 @lilypond[quote,relative=1,verbatim]
825 \mergeDifferentlyHeadedOn
826 << { c16 a' b a } \\ { c,2 } >>
827 \override NoteColumn #'ignore-collision = ##t
828 << { c16 a' b a } \\ { c,2 } >>
833 @c TODO investigate! Sometimes it works, sometimes not. --FV
834 The requirements for successfully merging different note heads that
835 are at the same time differently dotted are not clear.
838 @node Automatic part combining
839 @unnumberedsubsubsec Automatic part combining
841 @cindex automatic part combining
842 @cindex part combiner
843 @cindex combining parts
846 @funindex \partcombine
847 @funindex partcombine
849 Automatic part combining is used to merge two separate parts of music
850 onto a single staff. This can be especially helpful when typesetting
851 orchestral scores. A single @code{Voice} is printed while the two parts
852 of music are the same, but in places where they differ, a second
853 @code{Voice} is printed. Stem directions are set up & down accordingly
854 while Solo and @notation{a due} parts are also identified and marked
857 The syntax for automatic part combining is:
860 \partcombine @var{musicexpr1} @var{musicexpr2}
863 The following example demonstrates the basic functionality, putting
864 parts on a single staff as polyphony and setting stem directions
865 accordingly. The same variables are used for the independent parts and
868 @lilypond[quote,verbatim]
869 instrumentOne = \relative c' {
877 instrumentTwo = \relative g' {
886 \new Staff \instrumentOne
887 \new Staff \instrumentTwo
888 \new Staff \partcombine \instrumentOne \instrumentTwo
892 Both parts have identical notes in the third measure, so only one
893 instance of the notes is printed. Stem, slur, and tie directions are
894 set automatically, depending on whether the parts are playing solo or in
895 unison. When needed in polyphony situations, the first part (with
896 context called @code{one}) gets @qq{up} stems, while the second (called
897 @code{two}) always gets @qq{down} stems. In solo situations, the first
898 and second parts get marked with @qq{Solo} and @qq{Solo II},
899 respectively. The unison (@notation{a due}) parts are marked with the
902 Both arguments to @code{\partcombine} will be interpreted as separate
903 @code{Voice} contexts, so if the music is being specified in relative
904 mode then @emph{both} parts must contain a @code{\relative} function,
909 \relative @dots{} @var{musicexpr1}
910 \relative @dots{} @var{musicexpr2}
914 A @code{\relative} section that encloses a @code{\partcombine} has no
915 effect on the pitches of @code{@var{musicexpr1}} or
916 @code{@var{musicexpr2}}.
918 @funindex \partcombineChords
919 @funindex partcombineChords
920 @funindex \partcombineApart
921 @funindex partcombineApart
922 @funindex \partcombineUnisono
923 @funindex partcombineUnisono
924 @funindex \partcombineSoloI
925 @funindex partcombineSoloI
926 @funindex \partcombineSoloII
927 @funindex partcombineSoloII
928 @funindex \partcombineAutomatic
929 @funindex partcombineAutomatic
931 In professional scores, voices are often kept apart from each other for
932 long passages of music even if some of the notes are the same in both
933 voices, and could just as easily be printed as unison. Combining notes
934 into a chord, or showing one voice as solo is, therefore, not ideal as
935 the @code{\partcombine} function considers each note separately. In this
936 case the @code{\partcombine} function can be overriden with the
939 Commands ending in @code{...Once} apply only to the next note in the
944 @code{\partcombineApart} and @code{\partcombineApartOnce} keep the
945 notes as two separate voices, even if they can be combined into a chord
949 @code{\partcombineChords} and @code{\partcombineChordsOnce} combine the
953 @code{\partcombineUnisono} and @code{\partcombineUnisonoOnce} combine
954 both voices as @qq{unison}.
957 @code{\partcombineSoloI} and @code{\partcombineSoloIOnce} print only
958 voice one, and mark it as a @qq{Solo}.
961 @code{\partcombineSoloII} or @code{\partcombineSoloIIOnce} print only
962 voice two and mark it as a @qq{Solo}.
965 @code{\partcombineAutomatic} and @code{\partcombineAutomaticOnce} end
966 the functions of the commands above, and revert back to the standard
967 @code{\partcombine} functionality.
970 @lilypond[quote,verbatim]
971 instrumentOne = \relative c' {
972 \partcombineApart c2^"apart" e |
973 \partcombineAutomatic e2^"auto" e |
974 \partcombineChords e'2^"chord" e |
975 \partcombineAutomatic c2^"auto" c |
976 \partcombineApart c2^"apart" \partcombineChordsOnce e^"chord once" |
979 instrumentTwo = \relative c' {
989 \new Staff { \instrumentOne }
990 \new Staff { \instrumentTwo }
991 \new Staff { \partcombine \instrumentOne \instrumentTwo }
998 @lilypondfile[verbatim,quote,texidoc,doctitle]
999 {combining-two-parts-on-the-same-staff.ly}
1001 @lilypondfile[verbatim,quote,texidoc,doctitle]
1002 {changing-partcombine-texts.ly}
1011 @ref{Writing parts}.
1014 @rlsr{Simultaneous notes}.
1016 Internals Reference:
1017 @rinternals{PartCombineMusic},
1022 All @code{\partcombine...} functions can only accept two voices and are
1023 not designed to work with lyrics; such that when one of the voices is
1024 explicitly named in order to attach lyrics to it, the partcombiner will
1027 @code{\partcombine...} functions cannot be placed inside a @code{\times}
1028 or @code{\relative} block.
1030 If @code{printPartCombineTexts} is set and the two voices play the same
1031 notes @qq{on and off}, in the same measure, the part combiner may
1032 typeset @code{a2} more than once in that measure.
1034 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1035 cannot, for example, remember if a note in one @code{Voice} has already
1036 started when combining notes that have just started in the other
1037 @code{Voice}. This can lead to a number of unexpected issues including
1038 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1040 @code{\partcombine} keeps all spanners (slurs, ties, hairpins etc.) in
1041 the same @code{Voice} so that if any such spanners start or end in a
1042 different @code{Voice}, they may not be printed properly or at all.
1044 If the @code{\partcombine} function cannot combine both music
1045 expressions (i.e. when both voices have different durations), it will
1046 give the voices, internally, its own custom names: @code{one} and
1047 @code{two} respectively. This means if there is any @qq{switch} to a
1048 differently named @code{Voice} context, the events in that differently
1049 named @code{Voice} will be ignored.
1051 Refer also to @emph{Known issues and warnings} when using
1052 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1053 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1056 @node Writing music in parallel
1057 @unnumberedsubsubsec Writing music in parallel
1059 @cindex writing music in parallel
1060 @cindex interleaved music
1061 @cindex parallel music
1062 @funindex \parallelMusic
1063 @funindex parallelMusic
1065 Music for multiple parts can be interleaved in input code. The
1066 function @code{\parallelMusic} accepts a list with the names of a
1067 number of variables to be created, and a musical expression. The
1068 content of alternate measures from the expression become the value
1069 of the respective variables, so you can use them afterwards to
1072 @warning{Bar checks @code{|} must be used, and the measures must
1073 be of the same length.}
1075 @lilypond[quote,verbatim]
1076 \parallelMusic #'(voiceA voiceB voiceC) {
1078 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1079 r16 e'8.~ e'4 r16 e'8.~ e'4 |
1083 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1084 r16 d'8.~ d'4 r16 d'8.~ d'4 |
1089 \new Staff << \voiceA \\ \voiceB >>
1090 \new Staff { \clef bass \voiceC }
1094 Relative mode may be used. Note that the @code{\relative} command
1095 is not used inside @code{\parallelMusic} itself. The notes are
1096 relative to the preceding note in the voice, not to the previous
1097 note in the input -- in other words, relative notes for
1098 @code{voiceA} ignore the notes in @code{voiceB}.
1100 @lilypond[quote,verbatim]
1101 \parallelMusic #'(voiceA voiceB voiceC) {
1103 r8 g16 c e g, c e r8 g,16 c e g, c e |
1104 r16 e8.~ e4 r16 e8.~ e4 |
1108 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1109 r16 d8.~ d4 r16 d8.~ d4 |
1114 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1115 \new Staff \relative c' { \clef bass \voiceC }
1119 This works quite well for piano music. This example maps four
1120 consecutive measures to four variables:
1122 @lilypond[quote,verbatim]
1128 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1132 c16 d e fis d e fis g |
1138 e16 fis g a fis g a b |
1149 \relative c'' \voiceA
1151 \relative c' \voiceB
1169 @rlearning{Organizing pieces with variables}.
1172 @rlsr{Simultaneous notes}.