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]
57 <a' c e>1 <a c e>2 <f a c e>4 <a c>8. <g c e>16
61 Chords may also be followed by articulations, again just like simple
64 @lilypond[verbatim,quote]
66 <a' c e>1\fermata <a c e>2-> <f a c e>4\prall <a c>8.^! <g c e>16-.
70 The notes within the chord themselves can also be followed by articulation
73 @lilypond[verbatim,quote]
75 <a' c\prall e>1 <a-> c-^ e>2 <f-. a c-. e-.>4
76 <a-+ c-->8. <g\fermata c e\turn>16
80 However some notation, such as dynamics and hairpins must be
81 attached to the chord rather than to notes within the chord,
82 otherwise they will not print. Other notation like fingerings and
83 slurs will get placed markedly different when attached to notes
84 within a chord rather than to whole chords or single notes.
86 @lilypond[verbatim,quote]
88 <a'\f c( e>1 <a c) e>\f <a\< c e>( <a\! c e>)
89 <a c e>\< <a c e> <a c e>\!
94 @cindex placeholder events
96 A chord acts merely as a container for its notes, its articulations and
97 other attached elements. Consequently, a chord without notes inside
98 does not actually have a duration. Any attached articulations will
99 happen at the same musical time as the next following note or chord and
100 be combined with them (for more complex possibilities of combining such
101 elements, see @ref{Simultaneous expressions}):
103 @lilypond[verbatim,quote]
106 <> ) \p \< -. -\markup \italic "sempre staccato"
107 \repeat unfold 4 { c4 e } c1\f
111 @cindex relative pitch, chords
112 @cindex chords, relative pitch
114 Relative mode can be used for pitches in chords. The first note of
115 each chord is always relative to the first note of the chord that
116 came before it, or in the case where no preceding chord exists, the
117 pitch of the last note that came before the chord. All remaining notes
118 in the chord are relative to the note that came before it
119 @emph{within the same chord}.
121 @lilypond[verbatim,quote]
123 <a' c e>1 <f a c> <a c e> <f' a c> <b, e b,>
127 For more information about chords, see @ref{Chord notation}.
134 @rlearning{Combining notes into chords}.
137 @ref{Chord notation},
138 @ref{Articulations and ornamentations},
139 @ref{Relative octave entry},
140 @ref{Multiple voices}.
143 @rlsr{Simultaneous notes}.
146 Chords containing more than two pitches within a staff space,
147 such as @samp{<e f! fis!>}, create overlapping noteheads.
148 Depending on the situation, better representations might involve
153 temporary use of @ref{Multiple voices},
154 @samp{<< f! \\ <e fis!> >>},
157 enharmonic transcription of one or more pitches,
166 @node Chord repetition
167 @unnumberedsubsubsec Chord repetition
169 @cindex chord, repetition
170 @cindex repetition, using @code{q}
171 @cindex @code{q}, chord repetition
173 In order to save typing, a shortcut can be used to repeat the preceding
174 chord. The chord repetition symbol is @code{q}:
176 @lilypond[verbatim,quote]
178 <a' c e>1 q <f a c>2 q
182 As with regular chords, the chord repetition symbol can be used with
183 durations, articulations, markups, slurs, beams, etc., as only the
184 pitches of the previous chord are duplicated.
186 @lilypond[verbatim,quote]
188 <a' c e>1\p^"text" q2\<( q8)[-! q8.]\! q16-1-2-3 q8\prall
192 The chord repetition symbol always remembers the last instance of
193 a chord so it is possible to repeat the most recent chord even if
194 other non-chorded notes or rests have been added since.
196 @lilypond[verbatim,quote]
198 <a' c e>1 c'4 q2 r8 q8 |
203 However, the chord repetition symbol does not retain any dynamics,
204 articulation or ornamentation within, or attached to, the previous
207 @lilypond[verbatim,quote]
209 <a'-. c\prall e>1\sfz c'4 q2 r8 q8 |
214 To have some of them retained, the @code{\chordRepeats} function can be
215 be called explicitly with an extra argument specifying a list of
216 @var{event types} to keep unless events of that type are already
217 present on the @code{q} chord itself.
219 @lilypond[verbatim,quote]
221 \chordRepeats #'(articulation-event)
222 { <a'-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
227 Here using @code{\chordRepeats} inside of a @code{\relative} construction
228 produces unexpected results: once chord events have been expanded, they
229 are indistinguishable from having been entered as regular chords, making
230 @code{\relative} assign an octave based on their current context.
232 Since nested instances of @code{\relative} don't affect one another,
233 another @code{\relative} inside of @code{\chordRepeats} can be used for
234 establishing the octave relations before expanding the repeat chords.
235 In that case, the whole content of the inner @code{\relative} does not
236 affect the outer one; hence the different octave entry of the final note
239 @lilypond[verbatim,quote]
241 \chordRepeats #'(articulation-event)
243 { <a'-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
248 Interactions with @code{\relative} occur only with explicit calls of
249 @code{\chordRepeats}: the implicit expansion at the start of typesetting
250 is done at a time where all instances of @code{\relative} have already
255 @ref{Chord notation},
256 @ref{Articulations and ornamentations}.
259 @file{ly/chord-repetition-init.ly}.
262 @node Simultaneous expressions
263 @unnumberedsubsubsec Simultaneous expressions
265 One or more music expressions enclosed in double angle brackets are
266 taken to be simultaneous. If the first expression begins with a
267 single note or if the whole simultaneous expression appears
268 explicitly within a single voice, the whole expression is placed on
269 a single staff; otherwise the elements of the simultaneous
270 expression are placed on separate staves.
272 The following examples show simultaneous expressions on one staff:
274 @lilypond[quote,verbatim]
275 \new Voice { % explicit single voice
276 << \relative { a'4 b g2 }
277 \relative { d'4 g c,2 } >>
281 @lilypond[quote,verbatim]
284 a' << \relative { a'4 b g }
285 \relative { d'4 g c, } >>
289 This can be useful if the simultaneous sections have identical
290 rhythms, but attempts to attach notes with different durations to
291 the same stem will cause errors. Notes, articulations, and property
292 changes in a @emph{single} @samp{Voice} are collected and engraved in
295 @lilypond[quote,verbatim]
297 <a' c>4-. <>-. << c a >> << { c-. <c a> } { a s-. } >>
301 Multiple stems or beams or different note durations or properties at
302 the same musical time require the use of multiple voices.
304 The following example shows how simultaneous expressions can
305 generate multiple staves implicitly:
307 @lilypond[quote,verbatim]
308 % no single first note
309 << \relative { a'4 b g2 }
310 \relative { d'4 g2 c,4 } >>
313 Here different rhythms cause no problems because they are
314 interpreted in different voices.
316 @cindex collisions, ignoring
319 If notes from two or more voices, with no shifts specified,
320 have stems in the same direction, the message
323 warning: This voice needs a \voiceXx or \shiftXx setting
326 will appear during compilation. This message can be suppressed by:
329 \override NoteColumn.ignore-collision = ##t
332 However, this not only suppresses the warning but will prevent any
333 collision resolution whatsover and may have other unintended effects
334 (also see @emph{Known Issues} in @ref{Collision resolution}).
338 @unnumberedsubsubsec Clusters
343 @funindex \makeClusters
345 A cluster indicates a continuous range of pitches to be played.
346 They can be denoted as the envelope of a set of notes. They are
347 entered by applying the function @code{\makeClusters} to a sequence
350 @lilypond[quote,verbatim]
351 \relative \makeClusters { <g' b>2 <c g'> }
354 Ordinary notes and clusters can be put together in the same staff,
355 even simultaneously. In such a case no attempt is made to
356 automatically avoid collisions between ordinary notes and clusters.
363 @rlsr{Simultaneous notes}.
366 @rinternals{ClusterSpanner},
367 @rinternals{ClusterSpannerBeacon},
368 @rinternals{Cluster_spanner_engraver}.
371 Clusters look good only if they span at least two chords; otherwise
372 they appear too narrow.
374 Clusters do not have a stem and cannot indicate durations by
375 themselves, but the length of the printed cluster is determined by
376 the durations of the defining chords. Separate clusters need a
377 separating rest between them.
379 Clusters do not produce MIDI output.
382 @node Multiple voices
383 @subsection Multiple voices
385 This section discusses simultaneous notes in multiple voices or
389 * Single-staff polyphony::
391 * Collision resolution::
392 * Automatic part combining::
393 * Writing music in parallel::
397 @node Single-staff polyphony
398 @unnumberedsubsubsec Single-staff polyphony
400 @cindex single-staff polyphony
401 @cindex polyphony, single-staff
403 @cindex lyrics assigned to one voice
406 @funindex \voiceOne ... \voiceFour
410 @subsubsubheading Explicitly instantiating voices
412 The basic structure needed to achieve multiple independent
413 voices in a single staff is illustrated in the following example:
415 @lilypond[quote,verbatim]
418 \relative { \voiceOne r8 r16 g'' e8. f16 g8[ c,] f e16 d }
420 \relative { \voiceTwo d''16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
425 Here, voices are instantiated explicitly and are given names. The
426 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
427 so that first and third voices get stems up, second and fourth
428 voices get stems down, third and fourth voice note heads are
429 horizontally shifted, and rests in the respective voices are
430 automatically moved to avoid collisions. The @code{\oneVoice}
431 command returns all the voice settings to the neutral default
434 @subsubsubheading Temporary polyphonic passages
436 A temporary polyphonic passage can be created with the following
440 << @{ \voiceOne @dots{} @}
441 \new Voice @{ \voiceTwo @dots{} @}
446 Here, the first expression within a temporary polyphonic passage is
447 placed into the @code{Voice} context which was in use immediately
448 before the polyphonic passage, and that same @code{Voice} context
449 continues after the temporary section. Other expressions within
450 the angle brackets are assigned to distinct temporary voices.
451 This allows lyrics to be assigned to one continuing voice before,
452 during and after a polyphonic section:
454 @lilypond[quote,verbatim]
456 \new Voice = "melody" {
471 \new Lyrics \lyricsto "melody" {
478 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
479 required to define the settings of each voice.
481 @subsubsubheading The double backslash construct
483 The @code{<< @{@dots{}@} \\ @{@dots{}@} >>} construct, where the two (or
484 more) expressions are separated by double backslashes, behaves
485 differently to the similar construct without the double backslashes:
486 @emph{all} the expressions within this construct are assigned
487 to new @code{Voice} contexts. These new @code{Voice} contexts
488 are created implicitly and are given the fixed names @code{"1"},
491 The first example could be typeset as follows:
493 @lilypond[quote,verbatim]
495 \relative { r8 r16 g'' e8. f16 g8[ c,] f e16 d }
497 \relative { d''16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
501 This syntax can be used where it does not matter that temporary
502 voices are created and then discarded. These implicitly created
503 voices are given the settings equivalent to the effect of the
504 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
505 which they appear in the code.
507 In the following example, the intermediate voice has stems up,
508 therefore we enter it in the third place, so it becomes voice
509 three, which has the stems up as desired. Spacer rests are
510 used to avoid printing doubled rests.
512 @lilypond[quote,verbatim]
514 \relative { r8 g'' g g g f16 ees f8 d }
516 \relative { ees'8 r ees r d r d r }
518 \relative { d''8 s c s bes s a s }
522 In all but the simplest works it is advisable to create explicit
523 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
524 @rlearning{Explicitly instantiating voices}.
526 @subsubsubheading Voice order
528 When entering multiple voices in the input file, use the following
534 Voice 3: second highest
535 Voice 4: second lowest
536 Voice 5: third highest
537 Voice 6: third lowest
541 Though this may seem counterintuitive, it simplifies the automatic
542 layout process. Note that the odd-numbered voices are given
543 upstems, and the even-numbered voices are given downstems:
545 @lilypond[quote,verbatim]
548 { f''2 } % 1: highest
552 { d''2 } % 3: second-highest
554 { e'2 } % 4: second-lowest
556 { b'2 } % 5: third-highest
558 { g'2 } % 6: third-lowest
562 @warning{Lyrics and spanners (such as slurs, ties, hairpins, etc.) cannot
563 be created @q{across} voices.}
565 @subsubsubheading Identical rhythms
567 In the special case that we want to typeset parallel pieces of music
568 that have the same rhythm, we can combine them into a single
569 @code{Voice} context, thus forming chords. To achieve this, enclose
570 them in a simple simultaneous music construct within an explicit voice:
572 @lilypond[quote,verbatim]
574 \relative { e''4 f8 d e16 f g8 d4 }
575 \relative { c''4 d8 b c16 d e8 b4 }
579 This method leads to strange beamings and warnings if the pieces of
580 music do not have the same rhythm.
593 @rlearning{Voices contain music},
594 @rlearning{Explicitly instantiating voices}.
597 @ref{Percussion staves},
598 @ref{Invisible rests},
602 @rlsr{Simultaneous notes}.
606 @unnumberedsubsubsec Voice styles
609 @cindex styles, voice
610 @cindex coloring voices
611 @funindex \voiceOneStyle
612 @funindex \voiceTwoStyle
613 @funindex \voiceThreeStyle
614 @funindex \voiceFourStyle
615 @funindex \voiceNeutralStyle
617 Voices may be given distinct colors and shapes, allowing them to be
620 @lilypond[quote,verbatim]
622 \relative { \voiceOneStyle d''4 c2 b4 }
624 \relative { \voiceTwoStyle e'2 e }
626 \relative { \voiceThreeStyle b2. c4 }
628 \relative { \voiceFourStyle g'2 g }
632 The @code{\voiceNeutralStyle} command is used to revert to the
633 standard presentation.
637 @code{\voiceOneStyle},
638 @code{\voiceTwoStyle},
639 @code{\voiceThreeStyle},
640 @code{\voiceFourStyle},
641 @code{\voiceNeutralStyle}.
646 @rlearning{I'm hearing Voices},
647 @rlearning{Other sources of information}.
650 @rlsr{Simultaneous notes}.
653 @node Collision resolution
654 @unnumberedsubsubsec Collision resolution
656 @cindex merging notes
657 @cindex note collisions
660 @cindex multiple voices
661 @cindex voices, multiple
662 @cindex polyphonic music
663 @cindex shifting voices
664 @cindex voices, multiple
665 @cindex shift rest, automatic
670 @funindex \mergeDifferentlyDottedOn
671 @funindex \mergeDifferentlyDottedOff
672 @funindex \mergeDifferentlyHeadedOn
673 @funindex \mergeDifferentlyHeadedOff
675 The note heads of notes in different voices with the same pitch,
676 same note head and opposite stem direction are automatically
677 merged, but notes with different note heads or the same stem
678 direction are not. Rests opposite a stem in a different voice
679 are shifted vertically. The following example shows three
680 different circumstances, on beats 1 and 3 in bar 1 and beat 1
681 in bar 2, where the automatic merging fails.
683 @lilypond[quote,verbatim]
701 Notes with different note heads may be merged as shown
702 below. In this example the note heads on beat 1 of bar 1 are now merged:
704 @lilypond[quote,verbatim]
707 \mergeDifferentlyHeadedOn
723 Quarter and half notes are not merged in this way, since it would be difficult
726 Note heads with different dots as shown in beat 3 of bar 1 may be
729 @lilypond[quote,verbatim]
732 \mergeDifferentlyHeadedOn
733 \mergeDifferentlyDottedOn
749 The half note and eighth note at the start of the second measure
750 are incorrectly merged because the automatic merge cannot
751 successfully complete the merge when three or more notes line up in
752 the same note column, and in this case the merged note head is
753 incorrect. To allow the merge to select the correct note head
754 a @code{\shift} must be applied to the note that should not be
755 merged. Here, @code{\shiftOn} is applied to move the top
756 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
759 @lilypond[quote,verbatim]
762 \mergeDifferentlyHeadedOn
763 \mergeDifferentlyDottedOn
780 The @code{\shiftOn} command allows (but does not force) the notes
781 in a voice to be shifted. When @code{\shiftOn} is applied to a
782 voice, a note or chord in that voice is shifted only if its stem
783 would otherwise collide with a stem from another voice, and only
784 if the colliding stems point in the same direction. The
785 @code{\shiftOff} command prevents this type of shifting from
788 By default, the outer voices (normally voices one and two) have
789 @code{\shiftOff} specified, while the inner voices (three and
790 above) have @code{\shiftOn} specified. When a shift is applied,
791 voices with upstems (odd-numbered voices) are shifted to the
792 right, and voices with downstems (even-numbered voices) are
795 Here is an example to help you visualize how an abbreviated
796 polyphonic expression would be expanded internally.
798 @warning{Note that with three or more voices, the vertical order
799 of voices in your input file should not be the same as the
800 vertical order of voices on the staff!}
802 @lilypond[quote,verbatim]
803 \new Staff \relative {
806 { f''2 } % 1: highest
810 { d'2 } % 3: upper middle
812 { b2 } % 4: lower middle
814 %% internal expansion of the above
816 \new Voice = "1" { \voiceOne \shiftOff f'2 }
817 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
818 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
819 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
824 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
825 provide further shift levels which may be specified temporarily to
826 resolve collisions in complex situations -- see
827 @rlearning{Real music example}.
829 Notes are only merged if they have opposing stem directions (as
830 they have, for example, in voices one and two by default or when
831 the stems are explicitly set in opposite directions).
834 @code{\mergeDifferentlyDottedOn},
835 @code{\mergeDifferentlyDottedOff},
836 @code{\mergeDifferentlyHeadedOn},
837 @code{\mergeDifferentlyHeadedOff}.
846 @lilypondfile[verbatim,quote,texidoc,doctitle]
847 {additional-voices-to-avoid-collisions.ly}
849 @lilypondfile[verbatim,quote,texidoc,doctitle]
850 {forcing-horizontal-shift-of-notes.ly}
857 @rlearning{Multiple notes at once},
858 @rlearning{Voices contain music},
859 @rlearning{Real music example}.
862 @rlsr{Simultaneous notes}.
865 @rinternals{NoteColumn},
866 @rinternals{NoteCollision},
867 @rinternals{RestCollision}.
869 @cindex collisions, ignoring
872 Using @code{\override NoteColumn.ignore-collision = ##t} will cause
873 differently headed notes in different voices to merge incorrectly.
875 @lilypond[quote,verbatim,fragment]
876 \mergeDifferentlyHeadedOn
877 << \relative { c'16 a' b a } \\ \relative { c'2 } >>
878 \override NoteColumn.ignore-collision = ##t
879 << \relative { c'16 a' b a } \\ \relative { c'2 } >>
884 @c TODO investigate! Sometimes it works, sometimes not. --FV
885 The requirements for successfully merging different note heads that
886 are at the same time differently dotted are not clear.
890 @node Automatic part combining
891 @unnumberedsubsubsec Automatic part combining
893 @cindex automatic part combining
894 @cindex part combiner
895 @cindex combining parts
898 @funindex \partcombine
900 Automatic part combining is used to merge two separate parts of music
901 onto a single staff. This can be especially helpful when typesetting
902 orchestral scores. A single @code{Voice} is printed while the two parts
903 of music are the same, but in places where they differ, a second
904 @code{Voice} is printed. Stem directions are set up & down accordingly
905 while Solo and @notation{a due} parts are also identified and marked
908 The syntax for automatic part combining is:
911 \partcombine @var{musicexpr1} @var{musicexpr2}
914 The following example demonstrates the basic functionality, putting
915 parts on a single staff as polyphony and setting stem directions
916 accordingly. The same variables are used for the independent parts and
919 @lilypond[quote,verbatim]
920 instrumentOne = \relative {
928 instrumentTwo = \relative {
937 \new Staff \instrumentOne
938 \new Staff \instrumentTwo
939 \new Staff \partcombine \instrumentOne \instrumentTwo
943 Both parts have identical notes in the third measure, so only one
944 instance of the notes is printed. Stem, slur, and tie directions are
945 set automatically, depending on whether the parts are playing solo or in
946 unison. When needed in polyphony situations, the first part (with
947 context called @code{one}) gets @qq{up} stems, while the second (called
948 @code{two}) always gets @qq{down} stems. In solo situations, the first
949 and second parts get marked with @qq{Solo} and @qq{Solo II},
950 respectively. The unison (@notation{a due}) parts are marked with the
953 By default, the partcombiner merges two notes of the same pitch as an
954 @notation{a due} note, combines notes with the same
955 rhythm less than a ninth apart as chords and separates notes more than
956 a ninth apart (or when the voices cross) into
957 separate voices. This can be overridden with an optional argument of a pair
958 of numbers after the @code{\partcombine} command: the first specifies
959 the interval where notes start to be combined (the default is zero) and the
960 second where the notes are split into separate voices. Setting the second
961 argument to zero means that the partcombiner splits notes with an interval of
962 a second or more, setting it to one splits notes of a third or more, and so on.
964 @lilypond[quote,verbatim]
965 instrumentOne = \relative {
971 instrumentTwo = \relative {
978 \new Staff \partcombine \instrumentOne \instrumentTwo
979 \new Staff \partcombine #'(2 . 3) \instrumentOne \instrumentTwo
984 Both arguments to @code{\partcombine} will be interpreted as separate
985 @code{Voice} contexts, so if the music is being specified in relative
986 mode then @emph{both} parts must contain a @code{\relative} function,
991 \relative @dots{} @var{musicexpr1}
992 \relative @dots{} @var{musicexpr2}
996 A @code{\relative} section that encloses a @code{\partcombine} has no
997 effect on the pitches of @code{@var{musicexpr1}} or
998 @code{@var{musicexpr2}}.
1000 @funindex \partcombineChords
1001 @funindex \partcombineApart
1002 @funindex \partcombineUnisono
1003 @funindex \partcombineSoloI
1004 @funindex \partcombineSoloII
1005 @funindex \partcombineAutomatic
1007 In professional scores, voices are often kept apart from each other for
1008 long passages of music even if some of the notes are the same in both
1009 voices, and could just as easily be printed as unison. Combining notes
1010 into a chord, or showing one voice as solo is, therefore, not ideal as
1011 the @code{\partcombine} function considers each note separately. In this
1012 case the @code{\partcombine} function can be overridden with one of the
1013 following commands. All of the commands may be preceded with
1014 @code{\once} in order to have them only apply to the next note in
1015 the music expression.
1019 @code{\partcombineApart} keeps the
1020 notes as two separate voices, even if they can be combined into a chord
1024 @code{\partcombineChords} combines the
1028 @code{\partcombineUnisono} combines
1029 both voices as @qq{unison}.
1032 @code{\partcombineSoloI} prints only
1033 voice one, and marks it as a @qq{Solo}.
1036 @code{\partcombineSoloII} prints only
1037 voice two and marks it as a @qq{Solo}.
1040 @code{\partcombineAutomatic} ends
1041 the functions of the commands above, and reverts back to the standard
1042 @code{\partcombine} functionality.
1045 @lilypond[quote,verbatim]
1046 instrumentOne = \relative c' {
1047 \partcombineApart c2^"apart" e |
1048 \partcombineAutomatic e2^"auto" e |
1049 \partcombineChords e'2^"chord" e |
1050 \partcombineAutomatic c2^"auto" c |
1051 \partcombineApart c2^"apart" \once \partcombineChords e^"chord once" |
1054 instrumentTwo = \relative {
1064 \new Staff { \instrumentOne }
1065 \new Staff { \instrumentTwo }
1066 \new Staff { \partcombine \instrumentOne \instrumentTwo }
1071 @subsubsubheading Using \partcombine with lyrics
1073 @cindex \partcombine and lyrics
1075 The @code{\partcombine} command is not designed to work with
1076 lyrics; if one of the voices is explicitly named in order to
1077 attach lyrics to it, the partcombiner will stop working. However,
1078 this effect can be achieved using a @code{NullVoice} context. See
1079 @ref{Polyphony with shared lyrics}.
1084 @lilypondfile[verbatim,quote,texidoc,doctitle]
1085 {combining-two-parts-on-the-same-staff.ly}
1087 @lilypondfile[verbatim,quote,texidoc,doctitle]
1088 {changing-partcombine-texts.ly}
1096 @ref{Writing parts}.
1099 @rlsr{Simultaneous notes}.
1101 Internals Reference:
1102 @rinternals{PartCombineMusic},
1106 All @code{\partcombine@dots{}} functions can only accept two voices.
1108 @code{\partcombine@dots{}} functions cannot be placed inside a @code{\tuplet}
1109 or @code{\relative} block.
1111 If @code{printPartCombineTexts} is set and the two voices play the same
1112 notes @qq{on and off}, in the same measure, the part combiner may
1113 typeset @code{a2} more than once in that measure.
1115 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1116 cannot, for example, remember if a note in one @code{Voice} has already
1117 started when combining notes that have just started in the other
1118 @code{Voice}. This can lead to a number of unexpected issues including
1119 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1121 @code{\partcombine} keeps all spanners (slurs, ties, hairpins, etc.) in
1122 the same @code{Voice} so that if any such spanners start or end in a
1123 different @code{Voice}, they may not be printed properly or at all.
1125 If the @code{\partcombine} function cannot combine both music
1126 expressions (i.e., when both voices have different durations), it will
1127 give the voices, internally, its own custom names: @code{one} and
1128 @code{two} respectively. This means if there is any @qq{switch} to a
1129 differently named @code{Voice} context, the events in that differently
1130 named @code{Voice} will be ignored.
1132 Refer also to @emph{Known issues and warnings} when using
1133 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1134 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1137 @node Writing music in parallel
1138 @unnumberedsubsubsec Writing music in parallel
1140 @cindex writing music in parallel
1141 @cindex interleaved music
1142 @cindex parallel music
1143 @funindex \parallelMusic
1145 Music for multiple parts can be interleaved in input code. The
1146 function @code{\parallelMusic} accepts a list with the names of a
1147 number of variables to be created, and a musical expression. The
1148 content of alternate measures from the expression become the value
1149 of the respective variables, so you can use them afterwards to
1152 @warning{Bar checks @code{|} must be used, and the measures must
1153 be of the same length.}
1155 @lilypond[quote,verbatim]
1156 \parallelMusic #'(voiceA voiceB voiceC) {
1158 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1159 r16 e'8.~ 4 r16 e'8.~ 4 |
1163 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1164 r16 d'8.~ 4 r16 d'8.~ 4 |
1169 \new Staff << \voiceA \\ \voiceB >>
1170 \new Staff { \clef bass \voiceC }
1174 Relative mode may be used. Note that the @code{\relative} command
1175 is not used inside @code{\parallelMusic} itself. The notes are
1176 relative to the preceding note in the voice, not to the previous
1177 note in the input -- in other words, relative notes for
1178 @code{voiceA} ignore the notes in @code{voiceB}.
1180 @lilypond[quote,verbatim]
1181 \parallelMusic #'(voiceA voiceB voiceC) {
1183 r8 g16 c e g, c e r8 g,16 c e g, c e |
1184 r16 e8.~ 4 r16 e8.~ 4 |
1188 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1189 r16 d8.~ 4 r16 d8.~ 4 |
1194 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1195 \new Staff \relative c' { \clef bass \voiceC }
1199 This works quite well for piano music. This example maps four
1200 consecutive measures to four variables:
1202 @lilypond[quote,verbatim]
1208 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1212 c16 d e fis d e fis g |
1218 e16 fis g a fis g a b |
1229 \relative c'' \voiceA
1231 \relative c' \voiceB
1248 @rlearning{Organizing pieces with variables}.
1251 @rlsr{Simultaneous notes}.