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>\!
82 @cindex placeholder events
84 A chord acts merely as a container for its notes, its articulations and
85 other attached elements. Consequently, a chord without notes inside
86 does not actually have a duration. Any attached articulations will
87 happen at the same musical time as the next following note or chord and
88 be combined with them (for more complex possibilities of combining such
89 elements, see @ref{Simultaneous expressions}):
91 @lilypond[verbatim,quote,relative=2]
93 <> ) \p \< -. -\markup \italic "sempre staccato"
94 \repeat unfold 4 { c4 e } c1\f
97 @cindex relative pitch, chords
98 @cindex chords, relative pitch
100 Relative mode can be used for pitches in chords. The first note of
101 each chord is always relative to the first note of the chord that
102 came before it, or in the case where no preceding chord exists, the
103 pitch of the last note that came before the chord. All remaining notes
104 in the chord are relative to the note that came before it
105 @emph{within the same chord}.
107 @lilypond[verbatim,quote,relative=2]
108 <a c e>1 <f a c> <a c e> <f' a c> <b, e b,>
111 For more information about chords, see @ref{Chord notation}.
118 @rlearning{Combining notes into chords}.
121 @ref{Chord notation},
122 @ref{Articulations and ornamentations},
123 @ref{Relative octave entry},
124 @ref{Multiple voices}.
127 @rlsr{Simultaneous notes}.
130 Chords containing more than two pitches within a staff space,
131 such as @samp{<e f! fis!>}, create overlapping noteheads.
132 Depending on the situation, better representations might involve
137 temporary use of @ref{Multiple voices},
138 @samp{<< f! \\ <e fis!> >>},
141 enharmonic transcription of one or more pitches,
150 @node Chord repetition
151 @unnumberedsubsubsec Chord repetition
153 @cindex Chord, repetition
154 @cindex repetition, using @code{q}
156 In order to save typing, a shortcut can be used to repeat the preceding
157 chord. The chord repetition symbol is @code{q}:
159 @lilypond[verbatim,quote,relative=2]
160 <a c e>1 q <f a c>2 q
163 As with regular chords, the chord repetition symbol can be used with
164 durations, articulations, markups, slurs, beams, etc. as only the
165 pitches of the previous chord are duplicated.
167 @lilypond[verbatim,quote,relative=2]
168 <a c e>1\p^"text" q2\<( q8)[-| q8.]\! q16-1-2-3 q8\prall
171 The chord repetition symbol always remembers the last instance of
172 a chord so it is possible to repeat the most recent chord even if
173 other non-chorded notes or rests have been added since.
175 @lilypond[verbatim,quote,relative=2]
176 <a c e>1 c'4 q2 r8 q8 |
180 However, the chord repetition symbol does not retain any dynamics,
181 articulation or ornamentation within, or attached to, the previous
184 @lilypond[verbatim,quote,relative=2]
185 <a-. c\prall e>1\sfz c'4 q2 r8 q8 |
189 To have some of them retained, the @code{\chordRepeats} function can be
190 be called explicitly with an extra argument specifying a list of
191 @var{event types} to keep unless events of that type are already
192 present on the @code{q} chord itself.
194 @lilypond[verbatim,quote]
196 \chordRepeats #'(articulation-event)
197 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
202 Here using @code{\chordRepeats} inside of a @code{\relative} construction
203 produces unexpected results: once chord events have been expanded, they
204 are indistinguishable from having been entered as regular chords, making
205 @code{\relative} assign an octave based on their current context.
207 Since nested instances of @code{\relative} don't affect one another,
208 another @code{\relative} inside of @code{\chordRepeats} can be used for
209 establishing the octave relations before expanding the repeat chords.
210 In that case, the whole content of the inner @code{\relative} does not
211 affect the outer one; hence the different octave entry of the final note
214 @c Without \new Voice, implicit voice creation does the dumbest thing.
215 @lilypond[verbatim,quote]
218 \chordRepeats #'(articulation-event)
220 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
225 Interactions with @code{\relative} occur only with explicit calls of
226 @code{\chordRepeats}: the implicit expansion at the start of typesetting
227 is done at a time where all instances of @code{\relative} have already
232 @ref{Chord notation},
233 @ref{Articulations and ornamentations}.
236 @file{ly/chord-repetition-init.ly}.
239 @node Simultaneous expressions
240 @unnumberedsubsubsec Simultaneous expressions
242 One or more music expressions enclosed in double angle brackets are
243 taken to be simultaneous. If the first expression begins with a
244 single note or if the whole simultaneous expression appears
245 explicitly within a single voice, the whole expression is placed on
246 a single staff; otherwise the elements of the simultaneous
247 expression are placed on separate staves.
249 The following examples show simultaneous expressions on one staff:
251 @lilypond[quote,verbatim,relative=2]
252 \new Voice { % explicit single voice
253 << { a4 b g2 } { d4 g c,2 } >>
257 @lilypond[quote,verbatim,relative=2]
259 a << { a4 b g } { d4 g c, } >>
262 This can be useful if the simultaneous sections have identical
263 rhythms, but attempts to attach notes with different durations to
264 the same stem will cause errors. Notes, articulations, and property
265 changes in a @emph{single} @samp{Voice} are collected and engraved in
268 @lilypond[quote,verbatim,relative=2]
269 <a c>4-. <>-. << c a >> << { c-. <c a> } { a s-. } >>
272 Multiple stems or beams or different note durations or properties at
273 the same musical time require the use of multiple voices.
275 The following example shows how simultaneous expressions can
276 generate multiple staves implicitly:
278 @lilypond[quote,verbatim,relative=2]
279 % no single first note
280 << { a4 b g2 } { d4 g2 c,4 } >>
283 Here different rhythms cause no problems because they are
284 interpreted in different voices.
286 @cindex collisions, clashing note columns
287 @cindex collisions, ignoring
290 If notes from two or more voices, with stems in the same direction, are
291 placed at the same position on the staff and have no shift (or have the
292 same shift specified), the message:
295 warning: ignoring too many clashing note columns
298 will appear during compilation. This message can be suppressed by:
301 \override NoteColumn #'ignore-collision = ##t
304 However, this not only suppresses the warning but will prevent any
305 collision resolution whatsover and may have other unintended effects
306 (also see @emph{Known Issues} in @ref{Collision resolution}).
310 @unnumberedsubsubsec Clusters
315 @funindex \makeClusters
316 @funindex makeClusters
318 A cluster indicates a continuous range of pitches to be played.
319 They can be denoted as the envelope of a set of notes. They are
320 entered by applying the function @code{\makeClusters} to a sequence
323 @lilypond[quote,relative=2,verbatim]
324 \makeClusters { <g b>2 <c g'> }
327 Ordinary notes and clusters can be put together in the same staff,
328 even simultaneously. In such a case no attempt is made to
329 automatically avoid collisions between ordinary notes and clusters.
336 @rlsr{Simultaneous notes}.
339 @rinternals{ClusterSpanner},
340 @rinternals{ClusterSpannerBeacon},
341 @rinternals{Cluster_spanner_engraver}.
344 Clusters look good only if they span at least two chords; otherwise
345 they appear too narrow.
347 Clusters do not have a stem and cannot indicate durations by
348 themselves, but the length of the printed cluster is determined by
349 the durations of the defining chords. Separate clusters need a
350 separating rest between them.
352 Clusters do not produce MIDI output.
355 @node Multiple voices
356 @subsection Multiple voices
358 This section discusses simultaneous notes in multiple voices or
362 * Single-staff polyphony::
364 * Collision resolution::
365 * Automatic part combining::
366 * Writing music in parallel::
370 @node Single-staff polyphony
371 @unnumberedsubsubsec Single-staff polyphony
373 @cindex single-staff polyphony
374 @cindex polyphony, single-staff
376 @cindex lyrics assigned to one voice
380 @funindex \voiceOne ... \voiceFour
385 @strong{@i{Explicitly instantiating voices}}
387 The basic structure needed to achieve multiple independent
388 voices in a single staff is illustrated in the following example:
390 @lilypond[quote,relative=3,verbatim]
393 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
395 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
400 Here, voices are instantiated explicitly and are given names. The
401 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
402 so that first and third voices get stems up, second and fourth
403 voices get stems down, third and fourth voice note heads are
404 horizontally shifted, and rests in the respective voices are
405 automatically moved to avoid collisions. The @code{\oneVoice}
406 command returns all the voice settings to the neutral default
409 @strong{@i{Temporary polyphonic passages}}
411 A temporary polyphonic passage can be created with the following
415 << @{ \voiceOne ... @}
416 \new Voice @{ \voiceTwo ... @}
421 Here, the first expression within a temporary polyphonic passage is
422 placed into the @code{Voice} context which was in use immediately
423 before the polyphonic passage, and that same @code{Voice} context
424 continues after the temporary section. Other expressions within
425 the angle brackets are assigned to distinct temporary voices.
426 This allows lyrics to be assigned to one continuing voice before,
427 during and after a polyphonic section:
429 @lilypond[quote, verbatim, relative=2]
431 \new Voice = "melody" {
446 \new Lyrics \lyricsto "melody" {
453 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
454 required to define the settings of each voice.
456 @strong{@i{The double backslash construct}}
458 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
459 more) expressions are separated by double backslashes, behaves
460 differently to the similar construct without the double backslashes:
461 @emph{all} the expressions within this construct are assigned
462 to new @code{Voice} contexts. These new @code{Voice} contexts
463 are created implicitly and are given the fixed names @code{"1"},
466 The first example could be typeset as follows:
468 @lilypond[quote,relative=3,verbatim]
470 { r8 r16 g e8. f16 g8[ c,] f e16 d }
472 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
476 This syntax can be used where it does not matter that temporary
477 voices are created and then discarded. These implicitly created
478 voices are given the settings equivalent to the effect of the
479 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
480 which they appear in the code.
482 In the following example, the intermediate voice has stems up,
483 therefore we enter it in the third place, so it becomes voice
484 three, which has the stems up as desired. Spacer rests are
485 used to avoid printing doubled rests.
487 @lilypond[quote,relative=3,verbatim]
489 { r8 g g g g f16 ees f8 d }
491 { ees,8 r ees r d r d r }
493 { d'8 s c s bes s a s }
497 In all but the simplest works it is advisable to create explicit
498 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
499 @rlearning{Explicitly instantiating voices}.
501 @strong{@i{Voice order}}
503 When entering multiple voices in the input file, use the following
509 Voice 3: second highest
510 Voice 4: second lowest
511 Voice 5: third highest
512 Voice 6: third lowest
516 Though this may seem counterintuitive, it simplifies the automatic
517 layout process. Note that the odd-numbered voices are given
518 upstems, and the even-numbered voices are given downstems:
520 @lilypond[quote,verbatim]
523 { f''2 } % 1: highest
527 { d''2 } % 3: second-highest
529 { e'2 } % 4: second-lowest
531 { b'2 } % 5: third-highest
533 { g'2 } % 6: third-lowest
537 @warning{Lyrics, spanners (such as slurs, ties, hairpins etc.) cannot be
538 created @q{across} voices.}
540 @strong{@i{Identical rhythms}}
542 In the special case that we want to typeset parallel pieces of music
543 that have the same rhythm, we can combine them into a single
544 @code{Voice} context, thus forming chords. To achieve this, enclose
545 them in a simple simultaneous music construct within an explicit voice:
547 @lilypond[quote,relative=2,verbatim]
549 { e4 f8 d e16 f g8 d4 }
550 { c4 d8 b c16 d e8 b4 }
554 This method leads to strange beamings and warnings if the pieces of
555 music do not have the same rhythm.
568 @rlearning{Voices contain music},
569 @rlearning{Explicitly instantiating voices}.
572 @ref{Percussion staves},
573 @ref{Invisible rests},
577 @rlsr{Simultaneous notes}.
581 @unnumberedsubsubsec Voice styles
584 @cindex styles, voice
585 @cindex coloring voices
586 @funindex \voiceOneStyle
587 @funindex \voiceTwoStyle
588 @funindex \voiceThreeStyle
589 @funindex \voiceFourStyle
590 @funindex \voiceNeutralStyle
592 Voices may be given distinct colors and shapes, allowing them to be
595 @lilypond[quote,relative=2,verbatim]
597 { \voiceOneStyle d4 c2 b4 }
599 { \voiceTwoStyle e,2 e }
601 { \voiceThreeStyle b2. c4 }
603 { \voiceFourStyle g'2 g }
607 The @code{\voiceNeutralStyle} command is used to revert to the
608 standard presentation.
612 @code{\voiceOneStyle},
613 @code{\voiceTwoStyle},
614 @code{\voiceThreeStyle},
615 @code{\voiceFourStyle},
616 @code{\voiceNeutralStyle}.
621 @rlearning{I'm hearing Voices},
622 @rlearning{Other sources of information}.
625 @rlsr{Simultaneous notes}.
628 @node Collision resolution
629 @unnumberedsubsubsec Collision resolution
631 @cindex merging notes
632 @cindex note collisions
635 @cindex multiple voices
636 @cindex voices, multiple
637 @cindex polyphonic music
638 @cindex shifting voices
639 @cindex voices, multiple
640 @cindex shift rest, automatic
649 @funindex \mergeDifferentlyDottedOn
650 @funindex mergeDifferentlyDottedOn
651 @funindex \mergeDifferentlyDottedOff
652 @funindex mergeDifferentlyDottedOff
653 @funindex \mergeDifferentlyHeadedOn
654 @funindex mergeDifferentlyHeadedOn
655 @funindex \mergeDifferentlyHeadedOff
656 @funindex mergeDifferentlyHeadedOff
658 The note heads of notes in different voices with the same pitch,
659 same note head and opposite stem direction are automatically
660 merged, but notes with different note heads or the same stem
661 direction are not. Rests opposite a stem in a different voice
662 are shifted vertically. The following example shows three
663 different circumstances, on beats 1 and 3 in bar 1 and beat 1
664 in bar 2, where the automatic merging fails.
666 @lilypond[quote,verbatim,relative=2]
682 Notes with different note heads may be merged, with the
683 exception of half-note heads and quarter-note heads, as shown
684 below. Here the note heads on beat 1 of bar 1 are now merged:
686 @lilypond[quote,verbatim,relative=2]
689 \mergeDifferentlyHeadedOn
703 Note heads with different dots as shown in beat 3 of bar 1 may be
706 @lilypond[quote,relative=2,verbatim]
709 \mergeDifferentlyHeadedOn
710 \mergeDifferentlyDottedOn
724 The half note and eighth note at the start of the second measure
725 are incorrectly merged because the automatic merge cannot
726 successfully complete the merge when three or more notes line up in
727 the same note column, and in this case the merged note head is
728 incorrect. To allow the merge to select the correct note head
729 a @code{\shift} must be applied to the note that should not be
730 merged. Here, @code{\shiftOn} is applied to move the top
731 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
734 @lilypond[quote,relative=2,verbatim]
737 \mergeDifferentlyHeadedOn
738 \mergeDifferentlyDottedOn
753 The @code{\shiftOn} command allows (but does not force) the notes
754 in a voice to be shifted. When @code{\shiftOn} is applied to a
755 voice, a note or chord in that voice is shifted only if its stem
756 would otherwise collide with a stem from another voice, and only
757 if the colliding stems point in the same direction. The
758 @code{\shiftOff} command prevents this type of shifting from
761 By default, the outer voices (normally voices one and two) have
762 @code{\shiftOff} specified, while the inner voices (three and
763 above) have @code{\shiftOn} specified. When a shift is applied,
764 voices with upstems (odd-numbered voices) are shifted to the
765 right, and voices with downstems (even-numbered voices) are
768 Here is an example to help you visualize how an abbreviated
769 polyphonic expression would be expanded internally.
771 @warning{Note that with three or more voices, the vertical order
772 of voices in your input file should not be the same as the
773 vertical order of voices on the staff!}
775 @lilypond[quote,verbatim]
776 \new Staff \relative c'' {
783 { d'2 } % 3: upper middle
785 { b2 } % 4: lower middle
787 %% internal expansion of the above
789 \new Voice = "1" { \voiceOne \shiftOff f'2 }
790 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
791 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
792 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
797 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
798 provide further shift levels which may be specified temporarily to
799 resolve collisions in complex situations -- see
800 @rlearning{Real music example}.
802 Notes are only merged if they have opposing stem directions (as
803 they have, for example, in voices one and two by default or when
804 the stems are explicitly set in opposite directions).
807 @code{\mergeDifferentlyDottedOn},
808 @code{\mergeDifferentlyDottedOff},
809 @code{\mergeDifferentlyHeadedOn},
810 @code{\mergeDifferentlyHeadedOff}.
819 @lilypondfile[verbatim,quote,texidoc,doctitle]
820 {additional-voices-to-avoid-collisions.ly}
822 @lilypondfile[verbatim,quote,texidoc,doctitle]
823 {forcing-horizontal-shift-of-notes.ly}
830 @rlearning{Multiple notes at once},
831 @rlearning{Voices contain music},
832 @rlearning{Real music example}.
835 @rlsr{Simultaneous notes}.
838 @rinternals{NoteColumn},
839 @rinternals{NoteCollision},
840 @rinternals{RestCollision}.
842 @cindex collisions, ignoring
845 Using @code{\override NoteColumn #'ignore-collision = ##t} will cause
846 differently headed notes in different voices to merge incorrectly.
848 @lilypond[quote,relative=1,verbatim]
849 \mergeDifferentlyHeadedOn
850 << { c16 a' b a } \\ { c,2 } >>
851 \override NoteColumn #'ignore-collision = ##t
852 << { c16 a' b a } \\ { c,2 } >>
857 @c TODO investigate! Sometimes it works, sometimes not. --FV
858 The requirements for successfully merging different note heads that
859 are at the same time differently dotted are not clear.
863 @node Automatic part combining
864 @unnumberedsubsubsec Automatic part combining
866 @cindex automatic part combining
867 @cindex part combiner
868 @cindex combining parts
871 @funindex \partcombine
872 @funindex partcombine
874 Automatic part combining is used to merge two separate parts of music
875 onto a single staff. This can be especially helpful when typesetting
876 orchestral scores. A single @code{Voice} is printed while the two parts
877 of music are the same, but in places where they differ, a second
878 @code{Voice} is printed. Stem directions are set up & down accordingly
879 while Solo and @notation{a due} parts are also identified and marked
882 The syntax for automatic part combining is:
885 \partcombine @var{musicexpr1} @var{musicexpr2}
888 The following example demonstrates the basic functionality, putting
889 parts on a single staff as polyphony and setting stem directions
890 accordingly. The same variables are used for the independent parts and
893 @lilypond[quote,verbatim]
894 instrumentOne = \relative c' {
902 instrumentTwo = \relative g' {
911 \new Staff \instrumentOne
912 \new Staff \instrumentTwo
913 \new Staff \partcombine \instrumentOne \instrumentTwo
917 Both parts have identical notes in the third measure, so only one
918 instance of the notes is printed. Stem, slur, and tie directions are
919 set automatically, depending on whether the parts are playing solo or in
920 unison. When needed in polyphony situations, the first part (with
921 context called @code{one}) gets @qq{up} stems, while the second (called
922 @code{two}) always gets @qq{down} stems. In solo situations, the first
923 and second parts get marked with @qq{Solo} and @qq{Solo II},
924 respectively. The unison (@notation{a due}) parts are marked with the
927 Both arguments to @code{\partcombine} will be interpreted as separate
928 @code{Voice} contexts, so if the music is being specified in relative
929 mode then @emph{both} parts must contain a @code{\relative} function,
934 \relative @dots{} @var{musicexpr1}
935 \relative @dots{} @var{musicexpr2}
939 A @code{\relative} section that encloses a @code{\partcombine} has no
940 effect on the pitches of @code{@var{musicexpr1}} or
941 @code{@var{musicexpr2}}.
943 @funindex \partcombineChords
944 @funindex partcombineChords
945 @funindex \partcombineApart
946 @funindex partcombineApart
947 @funindex \partcombineUnisono
948 @funindex partcombineUnisono
949 @funindex \partcombineSoloI
950 @funindex partcombineSoloI
951 @funindex \partcombineSoloII
952 @funindex partcombineSoloII
953 @funindex \partcombineAutomatic
954 @funindex partcombineAutomatic
956 In professional scores, voices are often kept apart from each other for
957 long passages of music even if some of the notes are the same in both
958 voices, and could just as easily be printed as unison. Combining notes
959 into a chord, or showing one voice as solo is, therefore, not ideal as
960 the @code{\partcombine} function considers each note separately. In this
961 case the @code{\partcombine} function can be overriden with the
964 Commands ending in @code{...Once} apply only to the next note in the
969 @code{\partcombineApart} and @code{\partcombineApartOnce} keep the
970 notes as two separate voices, even if they can be combined into a chord
974 @code{\partcombineChords} and @code{\partcombineChordsOnce} combine the
978 @code{\partcombineUnisono} and @code{\partcombineUnisonoOnce} combine
979 both voices as @qq{unison}.
982 @code{\partcombineSoloI} and @code{\partcombineSoloIOnce} print only
983 voice one, and mark it as a @qq{Solo}.
986 @code{\partcombineSoloII} or @code{\partcombineSoloIIOnce} print only
987 voice two and mark it as a @qq{Solo}.
990 @code{\partcombineAutomatic} and @code{\partcombineAutomaticOnce} end
991 the functions of the commands above, and revert back to the standard
992 @code{\partcombine} functionality.
995 @lilypond[quote,verbatim]
996 instrumentOne = \relative c' {
997 \partcombineApart c2^"apart" e |
998 \partcombineAutomatic e2^"auto" e |
999 \partcombineChords e'2^"chord" e |
1000 \partcombineAutomatic c2^"auto" c |
1001 \partcombineApart c2^"apart" \partcombineChordsOnce e^"chord once" |
1004 instrumentTwo = \relative c' {
1014 \new Staff { \instrumentOne }
1015 \new Staff { \instrumentTwo }
1016 \new Staff { \partcombine \instrumentOne \instrumentTwo }
1023 @lilypondfile[verbatim,quote,texidoc,doctitle]
1024 {combining-two-parts-on-the-same-staff.ly}
1026 @lilypondfile[verbatim,quote,texidoc,doctitle]
1027 {changing-partcombine-texts.ly}
1035 @ref{Writing parts}.
1038 @rlsr{Simultaneous notes}.
1040 Internals Reference:
1041 @rinternals{PartCombineMusic},
1045 All @code{\partcombine...} functions can only accept two voices and are
1046 not designed to work with lyrics; such that when one of the voices is
1047 explicitly named in order to attach lyrics to it, the partcombiner will
1050 @code{\partcombine...} functions cannot be placed inside a @code{\times}
1051 or @code{\relative} block.
1053 If @code{printPartCombineTexts} is set and the two voices play the same
1054 notes @qq{on and off}, in the same measure, the part combiner may
1055 typeset @code{a2} more than once in that measure.
1057 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1058 cannot, for example, remember if a note in one @code{Voice} has already
1059 started when combining notes that have just started in the other
1060 @code{Voice}. This can lead to a number of unexpected issues including
1061 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1063 @code{\partcombine} keeps all spanners (slurs, ties, hairpins etc.) in
1064 the same @code{Voice} so that if any such spanners start or end in a
1065 different @code{Voice}, they may not be printed properly or at all.
1067 If the @code{\partcombine} function cannot combine both music
1068 expressions (i.e. when both voices have different durations), it will
1069 give the voices, internally, its own custom names: @code{one} and
1070 @code{two} respectively. This means if there is any @qq{switch} to a
1071 differently named @code{Voice} context, the events in that differently
1072 named @code{Voice} will be ignored.
1074 Refer also to @emph{Known issues and warnings} when using
1075 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1076 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1079 @node Writing music in parallel
1080 @unnumberedsubsubsec Writing music in parallel
1082 @cindex writing music in parallel
1083 @cindex interleaved music
1084 @cindex parallel music
1085 @funindex \parallelMusic
1086 @funindex parallelMusic
1088 Music for multiple parts can be interleaved in input code. The
1089 function @code{\parallelMusic} accepts a list with the names of a
1090 number of variables to be created, and a musical expression. The
1091 content of alternate measures from the expression become the value
1092 of the respective variables, so you can use them afterwards to
1095 @warning{Bar checks @code{|} must be used, and the measures must
1096 be of the same length.}
1098 @lilypond[quote,verbatim]
1099 \parallelMusic #'(voiceA voiceB voiceC) {
1101 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1102 r16 e'8.~ e'4 r16 e'8.~ e'4 |
1106 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1107 r16 d'8.~ d'4 r16 d'8.~ d'4 |
1112 \new Staff << \voiceA \\ \voiceB >>
1113 \new Staff { \clef bass \voiceC }
1117 Relative mode may be used. Note that the @code{\relative} command
1118 is not used inside @code{\parallelMusic} itself. The notes are
1119 relative to the preceding note in the voice, not to the previous
1120 note in the input -- in other words, relative notes for
1121 @code{voiceA} ignore the notes in @code{voiceB}.
1123 @lilypond[quote,verbatim]
1124 \parallelMusic #'(voiceA voiceB voiceC) {
1126 r8 g16 c e g, c e r8 g,16 c e g, c e |
1127 r16 e8.~ e4 r16 e8.~ e4 |
1131 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1132 r16 d8.~ d4 r16 d8.~ d4 |
1137 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1138 \new Staff \relative c' { \clef bass \voiceC }
1142 This works quite well for piano music. This example maps four
1143 consecutive measures to four variables:
1145 @lilypond[quote,verbatim]
1151 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1155 c16 d e fis d e fis g |
1161 e16 fis g a fis g a b |
1172 \relative c'' \voiceA
1174 \relative c' \voiceB
1191 @rlearning{Organizing pieces with variables}.
1194 @rlsr{Simultaneous notes}.