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,ragged-right,line-width=16\cm]{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
71 <a-+ c-->8. <g\fermata c e\turn>16
74 However some notation, such as dynamics, hairpins and slurs must be
75 attached to the chord, rather than notes within the chord, otherwise
78 @lilypond[verbatim,quote,relative=2]
79 <a\f c( e>1 <a c) e>\f <a\< c e>( <a\! c e>)
80 <a c e>\< <a c e> <a c e>\!
84 @cindex placeholder events
86 A chord acts merely as a container for its notes, its articulations and
87 other attached elements. Consequently, a chord without notes inside
88 does not actually have a duration. Any attached articulations will
89 happen at the same musical time as the next following note or chord and
90 be combined with them (for more complex possibilities of combining such
91 elements, see @ref{Simultaneous expressions}):
93 @lilypond[verbatim,quote,relative=2]
95 <> ) \p \< -. -\markup \italic "sempre staccato"
96 \repeat unfold 4 { c4 e } c1\f
99 @cindex relative pitch, chords
100 @cindex chords, relative pitch
102 Relative mode can be used for pitches in chords. The first note of
103 each chord is always relative to the first note of the chord that
104 came before it, or in the case where no preceding chord exists, the
105 pitch of the last note that came before the chord. All remaining notes
106 in the chord are relative to the note that came before it
107 @emph{within the same chord}.
109 @lilypond[verbatim,quote,relative=2]
110 <a c e>1 <f a c> <a c e> <f' a c> <b, e b,>
113 For more information about chords, see @ref{Chord notation}.
120 @rlearning{Combining notes into chords}.
123 @ref{Chord notation},
124 @ref{Articulations and ornamentations},
125 @ref{Relative octave entry},
126 @ref{Multiple voices}.
129 @rlsr{Simultaneous notes}.
132 Chords containing more than two pitches within a staff space,
133 such as @samp{<e f! fis!>}, create overlapping noteheads.
134 Depending on the situation, better representations might involve
139 temporary use of @ref{Multiple voices},
140 @samp{<< f! \\ <e fis!> >>},
143 enharmonic transcription of one or more pitches,
152 @node Chord repetition
153 @unnumberedsubsubsec Chord repetition
155 @cindex Chord, repetition
156 @cindex repetition, using @code{q}
158 In order to save typing, a shortcut can be used to repeat the preceding
159 chord. The chord repetition symbol is @code{q}:
161 @lilypond[verbatim,quote,relative=2]
162 <a c e>1 q <f a c>2 q
165 As with regular chords, the chord repetition symbol can be used with
166 durations, articulations, markups, slurs, beams, etc. as only the
167 pitches of the previous chord are duplicated.
169 @lilypond[verbatim,quote,relative=2]
170 <a c e>1\p^"text" q2\<( q8)[-| q8.]\! q16-1-2-3 q8\prall
173 The chord repetition symbol always remembers the last instance of
174 a chord so it is possible to repeat the most recent chord even if
175 other non-chorded notes or rests have been added since.
177 @lilypond[verbatim,quote,relative=2]
178 <a c e>1 c'4 q2 r8 q8 |
182 However, the chord repetition symbol does not retain any dynamics,
183 articulation or ornamentation within, or attached to, the previous
186 @lilypond[verbatim,quote,relative=2]
187 <a-. c\prall e>1\sfz c'4 q2 r8 q8 |
191 To have some of them retained, the @code{\chordRepeats} function can be
192 be called explicitly with an extra argument specifying a list of
193 @var{event types} to keep unless events of that type are already
194 present on the @code{q} chord itself.
196 @lilypond[verbatim,quote]
198 \chordRepeats #'(articulation-event)
199 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
204 Here using @code{\chordRepeats} inside of a @code{\relative} construction
205 produces unexpected results: once chord events have been expanded, they
206 are indistinguishable from having been entered as regular chords, making
207 @code{\relative} assign an octave based on their current context.
209 Since nested instances of @code{\relative} don't affect one another,
210 another @code{\relative} inside of @code{\chordRepeats} can be used for
211 establishing the octave relations before expanding the repeat chords.
212 In that case, the whole content of the inner @code{\relative} does not
213 affect the outer one; hence the different octave entry of the final note
216 @c Without \new Voice, implicit voice creation does the dumbest thing.
217 @lilypond[verbatim,quote]
220 \chordRepeats #'(articulation-event)
222 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
227 Interactions with @code{\relative} occur only with explicit calls of
228 @code{\chordRepeats}: the implicit expansion at the start of typesetting
229 is done at a time where all instances of @code{\relative} have already
234 @ref{Chord notation},
235 @ref{Articulations and ornamentations}.
238 @file{ly/chord-repetition-init.ly}.
241 @node Simultaneous expressions
242 @unnumberedsubsubsec Simultaneous expressions
244 One or more music expressions enclosed in double angle brackets are
245 taken to be simultaneous. If the first expression begins with a
246 single note or if the whole simultaneous expression appears
247 explicitly within a single voice, the whole expression is placed on
248 a single staff; otherwise the elements of the simultaneous
249 expression are placed on separate staves.
251 The following examples show simultaneous expressions on one staff:
253 @lilypond[quote,verbatim,relative=2]
254 \new Voice { % explicit single voice
255 << { a4 b g2 } { d4 g c,2 } >>
259 @lilypond[quote,verbatim,relative=2]
261 a << { a4 b g } { d4 g c, } >>
264 This can be useful if the simultaneous sections have identical
265 rhythms, but attempts to attach notes with different durations to
266 the same stem will cause errors. Notes, articulations, and property
267 changes in a @emph{single} @samp{Voice} are collected and engraved in
270 @lilypond[quote,verbatim,relative=2]
271 <a c>4-. <>-. << c a >> << { c-. <c a> } { a s-. } >>
274 Multiple stems or beams or different note durations or properties at
275 the same musical time require the use of multiple voices.
277 The following example shows how simultaneous expressions can
278 generate multiple staves implicitly:
280 @lilypond[quote,verbatim,relative=2]
281 % no single first note
282 << { a4 b g2 } { d4 g2 c,4 } >>
285 Here different rhythms cause no problems because they are
286 interpreted in different voices.
288 @cindex collisions, clashing note columns
289 @cindex collisions, ignoring
292 If notes from two or more voices, with stems in the same direction, are
293 placed at the same position on the staff and have no shift (or have the
294 same shift specified), the message:
297 warning: ignoring too many clashing note columns
300 will appear during compilation. This message can be suppressed by:
303 \override NoteColumn.ignore-collision = ##t
306 However, this not only suppresses the warning but will prevent any
307 collision resolution whatsover and may have other unintended effects
308 (also see @emph{Known Issues} in @ref{Collision resolution}).
312 @unnumberedsubsubsec Clusters
317 @funindex \makeClusters
318 @funindex makeClusters
320 A cluster indicates a continuous range of pitches to be played.
321 They can be denoted as the envelope of a set of notes. They are
322 entered by applying the function @code{\makeClusters} to a sequence
325 @lilypond[quote,relative=2,verbatim]
326 \makeClusters { <g b>2 <c g'> }
329 Ordinary notes and clusters can be put together in the same staff,
330 even simultaneously. In such a case no attempt is made to
331 automatically avoid collisions between ordinary notes and clusters.
338 @rlsr{Simultaneous notes}.
341 @rinternals{ClusterSpanner},
342 @rinternals{ClusterSpannerBeacon},
343 @rinternals{Cluster_spanner_engraver}.
346 Clusters look good only if they span at least two chords; otherwise
347 they appear too narrow.
349 Clusters do not have a stem and cannot indicate durations by
350 themselves, but the length of the printed cluster is determined by
351 the durations of the defining chords. Separate clusters need a
352 separating rest between them.
354 Clusters do not produce MIDI output.
357 @node Multiple voices
358 @subsection Multiple voices
360 This section discusses simultaneous notes in multiple voices or
364 * Single-staff polyphony::
366 * Collision resolution::
367 * Automatic part combining::
368 * Writing music in parallel::
372 @node Single-staff polyphony
373 @unnumberedsubsubsec Single-staff polyphony
375 @cindex single-staff polyphony
376 @cindex polyphony, single-staff
378 @cindex lyrics assigned to one voice
382 @funindex \voiceOne ... \voiceFour
387 @subsubsubheading Explicitly instantiating voices
389 The basic structure needed to achieve multiple independent
390 voices in a single staff is illustrated in the following example:
392 @lilypond[quote,relative=3,verbatim]
395 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
397 { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
402 Here, voices are instantiated explicitly and are given names. The
403 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
404 so that first and third voices get stems up, second and fourth
405 voices get stems down, third and fourth voice note heads are
406 horizontally shifted, and rests in the respective voices are
407 automatically moved to avoid collisions. The @code{\oneVoice}
408 command returns all the voice settings to the neutral default
411 @subsubsubheading Temporary polyphonic passages
413 A temporary polyphonic passage can be created with the following
417 << @{ \voiceOne ... @}
418 \new Voice @{ \voiceTwo ... @}
423 Here, the first expression within a temporary polyphonic passage is
424 placed into the @code{Voice} context which was in use immediately
425 before the polyphonic passage, and that same @code{Voice} context
426 continues after the temporary section. Other expressions within
427 the angle brackets are assigned to distinct temporary voices.
428 This allows lyrics to be assigned to one continuing voice before,
429 during and after a polyphonic section:
431 @lilypond[quote, verbatim, relative=2]
433 \new Voice = "melody" {
448 \new Lyrics \lyricsto "melody" {
455 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
456 required to define the settings of each voice.
458 @subsubsubheading The double backslash construct
460 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
461 more) expressions are separated by double backslashes, behaves
462 differently to the similar construct without the double backslashes:
463 @emph{all} the expressions within this construct are assigned
464 to new @code{Voice} contexts. These new @code{Voice} contexts
465 are created implicitly and are given the fixed names @code{"1"},
468 The first example could be typeset as follows:
470 @lilypond[quote,relative=3,verbatim]
472 { r8 r16 g e8. f16 g8[ c,] f e16 d }
474 { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
478 This syntax can be used where it does not matter that temporary
479 voices are created and then discarded. These implicitly created
480 voices are given the settings equivalent to the effect of the
481 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
482 which they appear in the code.
484 In the following example, the intermediate voice has stems up,
485 therefore we enter it in the third place, so it becomes voice
486 three, which has the stems up as desired. Spacer rests are
487 used to avoid printing doubled rests.
489 @lilypond[quote,relative=3,verbatim]
491 { r8 g g g g f16 ees f8 d }
493 { ees,8 r ees r d r d r }
495 { d'8 s c s bes s a s }
499 In all but the simplest works it is advisable to create explicit
500 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
501 @rlearning{Explicitly instantiating voices}.
503 @subsubsubheading Voice order
505 When entering multiple voices in the input file, use the following
511 Voice 3: second highest
512 Voice 4: second lowest
513 Voice 5: third highest
514 Voice 6: third lowest
518 Though this may seem counterintuitive, it simplifies the automatic
519 layout process. Note that the odd-numbered voices are given
520 upstems, and the even-numbered voices are given downstems:
522 @lilypond[quote,verbatim]
525 { f''2 } % 1: highest
529 { d''2 } % 3: second-highest
531 { e'2 } % 4: second-lowest
533 { b'2 } % 5: third-highest
535 { g'2 } % 6: third-lowest
539 @warning{Lyrics, spanners (such as slurs, ties, hairpins etc.) cannot be
540 created @q{across} voices.}
542 @subsubsubheading Identical rhythms
544 In the special case that we want to typeset parallel pieces of music
545 that have the same rhythm, we can combine them into a single
546 @code{Voice} context, thus forming chords. To achieve this, enclose
547 them in a simple simultaneous music construct within an explicit voice:
549 @lilypond[quote,relative=2,verbatim]
551 { e4 f8 d e16 f g8 d4 }
552 { c4 d8 b c16 d e8 b4 }
556 This method leads to strange beamings and warnings if the pieces of
557 music do not have the same rhythm.
570 @rlearning{Voices contain music},
571 @rlearning{Explicitly instantiating voices}.
574 @ref{Percussion staves},
575 @ref{Invisible rests},
579 @rlsr{Simultaneous notes}.
583 @unnumberedsubsubsec Voice styles
586 @cindex styles, voice
587 @cindex coloring voices
588 @funindex \voiceOneStyle
589 @funindex \voiceTwoStyle
590 @funindex \voiceThreeStyle
591 @funindex \voiceFourStyle
592 @funindex \voiceNeutralStyle
594 Voices may be given distinct colors and shapes, allowing them to be
597 @lilypond[quote,relative=2,verbatim]
599 { \voiceOneStyle d4 c2 b4 }
601 { \voiceTwoStyle e,2 e }
603 { \voiceThreeStyle b2. c4 }
605 { \voiceFourStyle g'2 g }
609 The @code{\voiceNeutralStyle} command is used to revert to the
610 standard presentation.
614 @code{\voiceOneStyle},
615 @code{\voiceTwoStyle},
616 @code{\voiceThreeStyle},
617 @code{\voiceFourStyle},
618 @code{\voiceNeutralStyle}.
623 @rlearning{I'm hearing Voices},
624 @rlearning{Other sources of information}.
627 @rlsr{Simultaneous notes}.
630 @node Collision resolution
631 @unnumberedsubsubsec Collision resolution
633 @cindex merging notes
634 @cindex note collisions
637 @cindex multiple voices
638 @cindex voices, multiple
639 @cindex polyphonic music
640 @cindex shifting voices
641 @cindex voices, multiple
642 @cindex shift rest, automatic
651 @funindex \mergeDifferentlyDottedOn
652 @funindex mergeDifferentlyDottedOn
653 @funindex \mergeDifferentlyDottedOff
654 @funindex mergeDifferentlyDottedOff
655 @funindex \mergeDifferentlyHeadedOn
656 @funindex mergeDifferentlyHeadedOn
657 @funindex \mergeDifferentlyHeadedOff
658 @funindex mergeDifferentlyHeadedOff
660 The note heads of notes in different voices with the same pitch,
661 same note head and opposite stem direction are automatically
662 merged, but notes with different note heads or the same stem
663 direction are not. Rests opposite a stem in a different voice
664 are shifted vertically. The following example shows three
665 different circumstances, on beats 1 and 3 in bar 1 and beat 1
666 in bar 2, where the automatic merging fails.
668 @lilypond[quote,verbatim,relative=2]
684 Notes with different note heads may be merged, with the
685 exception of half-note heads and quarter-note heads, as shown
686 below. Here the note heads on beat 1 of bar 1 are now merged:
688 @lilypond[quote,verbatim,relative=2]
691 \mergeDifferentlyHeadedOn
705 Note heads with different dots as shown in beat 3 of bar 1 may be
708 @lilypond[quote,relative=2,verbatim]
711 \mergeDifferentlyHeadedOn
712 \mergeDifferentlyDottedOn
726 The half note and eighth note at the start of the second measure
727 are incorrectly merged because the automatic merge cannot
728 successfully complete the merge when three or more notes line up in
729 the same note column, and in this case the merged note head is
730 incorrect. To allow the merge to select the correct note head
731 a @code{\shift} must be applied to the note that should not be
732 merged. Here, @code{\shiftOn} is applied to move the top
733 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
736 @lilypond[quote,relative=2,verbatim]
739 \mergeDifferentlyHeadedOn
740 \mergeDifferentlyDottedOn
755 The @code{\shiftOn} command allows (but does not force) the notes
756 in a voice to be shifted. When @code{\shiftOn} is applied to a
757 voice, a note or chord in that voice is shifted only if its stem
758 would otherwise collide with a stem from another voice, and only
759 if the colliding stems point in the same direction. The
760 @code{\shiftOff} command prevents this type of shifting from
763 By default, the outer voices (normally voices one and two) have
764 @code{\shiftOff} specified, while the inner voices (three and
765 above) have @code{\shiftOn} specified. When a shift is applied,
766 voices with upstems (odd-numbered voices) are shifted to the
767 right, and voices with downstems (even-numbered voices) are
770 Here is an example to help you visualize how an abbreviated
771 polyphonic expression would be expanded internally.
773 @warning{Note that with three or more voices, the vertical order
774 of voices in your input file should not be the same as the
775 vertical order of voices on the staff!}
777 @lilypond[quote,verbatim]
778 \new Staff \relative c'' {
785 { d'2 } % 3: upper middle
787 { b2 } % 4: lower middle
789 %% internal expansion of the above
791 \new Voice = "1" { \voiceOne \shiftOff f'2 }
792 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
793 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
794 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
799 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
800 provide further shift levels which may be specified temporarily to
801 resolve collisions in complex situations -- see
802 @rlearning{Real music example}.
804 Notes are only merged if they have opposing stem directions (as
805 they have, for example, in voices one and two by default or when
806 the stems are explicitly set in opposite directions).
809 @code{\mergeDifferentlyDottedOn},
810 @code{\mergeDifferentlyDottedOff},
811 @code{\mergeDifferentlyHeadedOn},
812 @code{\mergeDifferentlyHeadedOff}.
821 @lilypondfile[verbatim,quote,texidoc,doctitle]
822 {additional-voices-to-avoid-collisions.ly}
824 @lilypondfile[verbatim,quote,texidoc,doctitle]
825 {forcing-horizontal-shift-of-notes.ly}
832 @rlearning{Multiple notes at once},
833 @rlearning{Voices contain music},
834 @rlearning{Real music example}.
837 @rlsr{Simultaneous notes}.
840 @rinternals{NoteColumn},
841 @rinternals{NoteCollision},
842 @rinternals{RestCollision}.
844 @cindex collisions, ignoring
847 Using @code{\override NoteColumn.ignore-collision = ##t} will cause
848 differently headed notes in different voices to merge incorrectly.
850 @lilypond[quote,relative=1,verbatim]
851 \mergeDifferentlyHeadedOn
852 << { c16 a' b a } \\ { c,2 } >>
853 \override NoteColumn.ignore-collision = ##t
854 << { c16 a' b a } \\ { c,2 } >>
859 @c TODO investigate! Sometimes it works, sometimes not. --FV
860 The requirements for successfully merging different note heads that
861 are at the same time differently dotted are not clear.
865 @node Automatic part combining
866 @unnumberedsubsubsec Automatic part combining
868 @cindex automatic part combining
869 @cindex part combiner
870 @cindex combining parts
873 @funindex \partcombine
874 @funindex partcombine
876 Automatic part combining is used to merge two separate parts of music
877 onto a single staff. This can be especially helpful when typesetting
878 orchestral scores. A single @code{Voice} is printed while the two parts
879 of music are the same, but in places where they differ, a second
880 @code{Voice} is printed. Stem directions are set up & down accordingly
881 while Solo and @notation{a due} parts are also identified and marked
884 The syntax for automatic part combining is:
887 \partcombine @var{musicexpr1} @var{musicexpr2}
890 The following example demonstrates the basic functionality, putting
891 parts on a single staff as polyphony and setting stem directions
892 accordingly. The same variables are used for the independent parts and
895 @lilypond[quote,verbatim]
896 instrumentOne = \relative c' {
904 instrumentTwo = \relative g' {
913 \new Staff \instrumentOne
914 \new Staff \instrumentTwo
915 \new Staff \partcombine \instrumentOne \instrumentTwo
919 Both parts have identical notes in the third measure, so only one
920 instance of the notes is printed. Stem, slur, and tie directions are
921 set automatically, depending on whether the parts are playing solo or in
922 unison. When needed in polyphony situations, the first part (with
923 context called @code{one}) gets @qq{up} stems, while the second (called
924 @code{two}) always gets @qq{down} stems. In solo situations, the first
925 and second parts get marked with @qq{Solo} and @qq{Solo II},
926 respectively. The unison (@notation{a due}) parts are marked with the
929 Both arguments to @code{\partcombine} will be interpreted as separate
930 @code{Voice} contexts, so if the music is being specified in relative
931 mode then @emph{both} parts must contain a @code{\relative} function,
936 \relative @dots{} @var{musicexpr1}
937 \relative @dots{} @var{musicexpr2}
941 A @code{\relative} section that encloses a @code{\partcombine} has no
942 effect on the pitches of @code{@var{musicexpr1}} or
943 @code{@var{musicexpr2}}.
945 @funindex \partcombineChords
946 @funindex partcombineChords
947 @funindex \partcombineApart
948 @funindex partcombineApart
949 @funindex \partcombineUnisono
950 @funindex partcombineUnisono
951 @funindex \partcombineSoloI
952 @funindex partcombineSoloI
953 @funindex \partcombineSoloII
954 @funindex partcombineSoloII
955 @funindex \partcombineAutomatic
956 @funindex partcombineAutomatic
958 In professional scores, voices are often kept apart from each other for
959 long passages of music even if some of the notes are the same in both
960 voices, and could just as easily be printed as unison. Combining notes
961 into a chord, or showing one voice as solo is, therefore, not ideal as
962 the @code{\partcombine} function considers each note separately. In this
963 case the @code{\partcombine} function can be overriden with the
966 Commands ending in @code{...Once} apply only to the next note in the
971 @code{\partcombineApart} and @code{\partcombineApartOnce} keep the
972 notes as two separate voices, even if they can be combined into a chord
976 @code{\partcombineChords} and @code{\partcombineChordsOnce} combine the
980 @code{\partcombineUnisono} and @code{\partcombineUnisonoOnce} combine
981 both voices as @qq{unison}.
984 @code{\partcombineSoloI} and @code{\partcombineSoloIOnce} print only
985 voice one, and mark it as a @qq{Solo}.
988 @code{\partcombineSoloII} or @code{\partcombineSoloIIOnce} print only
989 voice two and mark it as a @qq{Solo}.
992 @code{\partcombineAutomatic} and @code{\partcombineAutomaticOnce} end
993 the functions of the commands above, and revert back to the standard
994 @code{\partcombine} functionality.
997 @lilypond[quote,verbatim]
998 instrumentOne = \relative c' {
999 \partcombineApart c2^"apart" e |
1000 \partcombineAutomatic e2^"auto" e |
1001 \partcombineChords e'2^"chord" e |
1002 \partcombineAutomatic c2^"auto" c |
1003 \partcombineApart c2^"apart" \partcombineChordsOnce e^"chord once" |
1006 instrumentTwo = \relative c' {
1016 \new Staff { \instrumentOne }
1017 \new Staff { \instrumentTwo }
1018 \new Staff { \partcombine \instrumentOne \instrumentTwo }
1025 @lilypondfile[verbatim,quote,texidoc,doctitle]
1026 {combining-two-parts-on-the-same-staff.ly}
1028 @lilypondfile[verbatim,quote,texidoc,doctitle]
1029 {changing-partcombine-texts.ly}
1037 @ref{Writing parts}.
1040 @rlsr{Simultaneous notes}.
1042 Internals Reference:
1043 @rinternals{PartCombineMusic},
1047 All @code{\partcombine...} functions can only accept two voices and are
1048 not designed to work with lyrics; such that when one of the voices is
1049 explicitly named in order to attach lyrics to it, the partcombiner will
1052 @code{\partcombine...} functions cannot be placed inside a @code{\times}
1053 or @code{\relative} block.
1055 If @code{printPartCombineTexts} is set and the two voices play the same
1056 notes @qq{on and off}, in the same measure, the part combiner may
1057 typeset @code{a2} more than once in that measure.
1059 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1060 cannot, for example, remember if a note in one @code{Voice} has already
1061 started when combining notes that have just started in the other
1062 @code{Voice}. This can lead to a number of unexpected issues including
1063 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1065 @code{\partcombine} keeps all spanners (slurs, ties, hairpins etc.) in
1066 the same @code{Voice} so that if any such spanners start or end in a
1067 different @code{Voice}, they may not be printed properly or at all.
1069 If the @code{\partcombine} function cannot combine both music
1070 expressions (i.e. when both voices have different durations), it will
1071 give the voices, internally, its own custom names: @code{one} and
1072 @code{two} respectively. This means if there is any @qq{switch} to a
1073 differently named @code{Voice} context, the events in that differently
1074 named @code{Voice} will be ignored.
1076 Refer also to @emph{Known issues and warnings} when using
1077 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1078 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1081 @node Writing music in parallel
1082 @unnumberedsubsubsec Writing music in parallel
1084 @cindex writing music in parallel
1085 @cindex interleaved music
1086 @cindex parallel music
1087 @funindex \parallelMusic
1088 @funindex parallelMusic
1090 Music for multiple parts can be interleaved in input code. The
1091 function @code{\parallelMusic} accepts a list with the names of a
1092 number of variables to be created, and a musical expression. The
1093 content of alternate measures from the expression become the value
1094 of the respective variables, so you can use them afterwards to
1097 @warning{Bar checks @code{|} must be used, and the measures must
1098 be of the same length.}
1100 @lilypond[quote,verbatim]
1101 \parallelMusic #'(voiceA voiceB voiceC) {
1103 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1104 r16 e'8.~ e'4 r16 e'8.~ e'4 |
1108 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1109 r16 d'8.~ d'4 r16 d'8.~ d'4 |
1114 \new Staff << \voiceA \\ \voiceB >>
1115 \new Staff { \clef bass \voiceC }
1119 Relative mode may be used. Note that the @code{\relative} command
1120 is not used inside @code{\parallelMusic} itself. The notes are
1121 relative to the preceding note in the voice, not to the previous
1122 note in the input -- in other words, relative notes for
1123 @code{voiceA} ignore the notes in @code{voiceB}.
1125 @lilypond[quote,verbatim]
1126 \parallelMusic #'(voiceA voiceB voiceC) {
1128 r8 g16 c e g, c e r8 g,16 c e g, c e |
1129 r16 e8.~ e4 r16 e8.~ e4 |
1133 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1134 r16 d8.~ d4 r16 d8.~ d4 |
1139 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1140 \new Staff \relative c' { \clef bass \voiceC }
1144 This works quite well for piano music. This example maps four
1145 consecutive measures to four variables:
1147 @lilypond[quote,verbatim]
1153 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1157 c16 d e fis d e fis g |
1163 e16 fis g a fis g a b |
1174 \relative c'' \voiceA
1176 \relative c' \voiceB
1193 @rlearning{Organizing pieces with variables}.
1196 @rlsr{Simultaneous notes}.