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}
157 @cindex @code{q}, chord repetition
159 In order to save typing, a shortcut can be used to repeat the preceding
160 chord. The chord repetition symbol is @code{q}:
162 @lilypond[verbatim,quote,relative=2]
163 <a c e>1 q <f a c>2 q
166 As with regular chords, the chord repetition symbol can be used with
167 durations, articulations, markups, slurs, beams, etc. as only the
168 pitches of the previous chord are duplicated.
170 @lilypond[verbatim,quote,relative=2]
171 <a c e>1\p^"text" q2\<( q8)[-! q8.]\! q16-1-2-3 q8\prall
174 The chord repetition symbol always remembers the last instance of
175 a chord so it is possible to repeat the most recent chord even if
176 other non-chorded notes or rests have been added since.
178 @lilypond[verbatim,quote,relative=2]
179 <a c e>1 c'4 q2 r8 q8 |
183 However, the chord repetition symbol does not retain any dynamics,
184 articulation or ornamentation within, or attached to, the previous
187 @lilypond[verbatim,quote,relative=2]
188 <a-. c\prall e>1\sfz c'4 q2 r8 q8 |
192 To have some of them retained, the @code{\chordRepeats} function can be
193 be called explicitly with an extra argument specifying a list of
194 @var{event types} to keep unless events of that type are already
195 present on the @code{q} chord itself.
197 @lilypond[verbatim,quote]
199 \chordRepeats #'(articulation-event)
200 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
205 Here using @code{\chordRepeats} inside of a @code{\relative} construction
206 produces unexpected results: once chord events have been expanded, they
207 are indistinguishable from having been entered as regular chords, making
208 @code{\relative} assign an octave based on their current context.
210 Since nested instances of @code{\relative} don't affect one another,
211 another @code{\relative} inside of @code{\chordRepeats} can be used for
212 establishing the octave relations before expanding the repeat chords.
213 In that case, the whole content of the inner @code{\relative} does not
214 affect the outer one; hence the different octave entry of the final note
217 @c Without \new Voice, implicit voice creation does the dumbest thing.
218 @lilypond[verbatim,quote]
221 \chordRepeats #'(articulation-event)
223 { <a-. c\prall e>1\sfz c'4 q2 r8 q8-. } |
228 Interactions with @code{\relative} occur only with explicit calls of
229 @code{\chordRepeats}: the implicit expansion at the start of typesetting
230 is done at a time where all instances of @code{\relative} have already
235 @ref{Chord notation},
236 @ref{Articulations and ornamentations}.
239 @file{ly/chord-repetition-init.ly}.
242 @node Simultaneous expressions
243 @unnumberedsubsubsec Simultaneous expressions
245 One or more music expressions enclosed in double angle brackets are
246 taken to be simultaneous. If the first expression begins with a
247 single note or if the whole simultaneous expression appears
248 explicitly within a single voice, the whole expression is placed on
249 a single staff; otherwise the elements of the simultaneous
250 expression are placed on separate staves.
252 The following examples show simultaneous expressions on one staff:
254 @lilypond[quote,verbatim,relative=2]
255 \new Voice { % explicit single voice
256 << { a4 b g2 } { d4 g c,2 } >>
260 @lilypond[quote,verbatim,relative=2]
262 a << { a4 b g } { d4 g c, } >>
265 This can be useful if the simultaneous sections have identical
266 rhythms, but attempts to attach notes with different durations to
267 the same stem will cause errors. Notes, articulations, and property
268 changes in a @emph{single} @samp{Voice} are collected and engraved in
271 @lilypond[quote,verbatim,relative=2]
272 <a c>4-. <>-. << c a >> << { c-. <c a> } { a s-. } >>
275 Multiple stems or beams or different note durations or properties at
276 the same musical time require the use of multiple voices.
278 The following example shows how simultaneous expressions can
279 generate multiple staves implicitly:
281 @lilypond[quote,verbatim,relative=2]
282 % no single first note
283 << { a4 b g2 } { d4 g2 c,4 } >>
286 Here different rhythms cause no problems because they are
287 interpreted in different voices.
289 @cindex collisions, ignoring
292 If notes from two or more voices, with no shifts specified,
293 have stems in the same direction, the message
296 warning: This voice needs a \voiceXx or \shiftXx setting
299 will appear during compilation. This message can be suppressed by:
302 \override NoteColumn.ignore-collision = ##t
305 However, this not only suppresses the warning but will prevent any
306 collision resolution whatsover and may have other unintended effects
307 (also see @emph{Known Issues} in @ref{Collision resolution}).
311 @unnumberedsubsubsec Clusters
316 @funindex \makeClusters
317 @funindex makeClusters
319 A cluster indicates a continuous range of pitches to be played.
320 They can be denoted as the envelope of a set of notes. They are
321 entered by applying the function @code{\makeClusters} to a sequence
324 @lilypond[quote,relative=2,verbatim]
325 \makeClusters { <g b>2 <c g'> }
328 Ordinary notes and clusters can be put together in the same staff,
329 even simultaneously. In such a case no attempt is made to
330 automatically avoid collisions between ordinary notes and clusters.
337 @rlsr{Simultaneous notes}.
340 @rinternals{ClusterSpanner},
341 @rinternals{ClusterSpannerBeacon},
342 @rinternals{Cluster_spanner_engraver}.
345 Clusters look good only if they span at least two chords; otherwise
346 they appear too narrow.
348 Clusters do not have a stem and cannot indicate durations by
349 themselves, but the length of the printed cluster is determined by
350 the durations of the defining chords. Separate clusters need a
351 separating rest between them.
353 Clusters do not produce MIDI output.
356 @node Multiple voices
357 @subsection Multiple voices
359 This section discusses simultaneous notes in multiple voices or
363 * Single-staff polyphony::
365 * Collision resolution::
366 * Automatic part combining::
367 * Writing music in parallel::
371 @node Single-staff polyphony
372 @unnumberedsubsubsec Single-staff polyphony
374 @cindex single-staff polyphony
375 @cindex polyphony, single-staff
377 @cindex lyrics assigned to one voice
381 @funindex \voiceOne ... \voiceFour
386 @subsubsubheading Explicitly instantiating voices
388 The basic structure needed to achieve multiple independent
389 voices in a single staff is illustrated in the following example:
391 @lilypond[quote,relative=3,verbatim]
394 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
396 { \voiceTwo d16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
401 Here, voices are instantiated explicitly and are given names. The
402 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
403 so that first and third voices get stems up, second and fourth
404 voices get stems down, third and fourth voice note heads are
405 horizontally shifted, and rests in the respective voices are
406 automatically moved to avoid collisions. The @code{\oneVoice}
407 command returns all the voice settings to the neutral default
410 @subsubsubheading Temporary polyphonic passages
412 A temporary polyphonic passage can be created with the following
416 << @{ \voiceOne @dots{} @}
417 \new Voice @{ \voiceTwo @dots{} @}
422 Here, the first expression within a temporary polyphonic passage is
423 placed into the @code{Voice} context which was in use immediately
424 before the polyphonic passage, and that same @code{Voice} context
425 continues after the temporary section. Other expressions within
426 the angle brackets are assigned to distinct temporary voices.
427 This allows lyrics to be assigned to one continuing voice before,
428 during and after a polyphonic section:
430 @lilypond[quote, verbatim, relative=2]
432 \new Voice = "melody" {
447 \new Lyrics \lyricsto "melody" {
454 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
455 required to define the settings of each voice.
457 @subsubsubheading The double backslash construct
459 The @code{<< @{@dots{}@} \\ @{@dots{}@} >>} construct, where the two (or
460 more) expressions are separated by double backslashes, behaves
461 differently to the similar construct without the double backslashes:
462 @emph{all} the expressions within this construct are assigned
463 to new @code{Voice} contexts. These new @code{Voice} contexts
464 are created implicitly and are given the fixed names @code{"1"},
467 The first example could be typeset as follows:
469 @lilypond[quote,relative=3,verbatim]
471 { r8 r16 g e8. f16 g8[ c,] f e16 d }
473 { d16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
477 This syntax can be used where it does not matter that temporary
478 voices are created and then discarded. These implicitly created
479 voices are given the settings equivalent to the effect of the
480 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
481 which they appear in the code.
483 In the following example, the intermediate voice has stems up,
484 therefore we enter it in the third place, so it becomes voice
485 three, which has the stems up as desired. Spacer rests are
486 used to avoid printing doubled rests.
488 @lilypond[quote,relative=3,verbatim]
490 { r8 g g g g f16 ees f8 d }
492 { ees,8 r ees r d r d r }
494 { d'8 s c s bes s a s }
498 In all but the simplest works it is advisable to create explicit
499 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
500 @rlearning{Explicitly instantiating voices}.
502 @subsubsubheading Voice order
504 When entering multiple voices in the input file, use the following
510 Voice 3: second highest
511 Voice 4: second lowest
512 Voice 5: third highest
513 Voice 6: third lowest
517 Though this may seem counterintuitive, it simplifies the automatic
518 layout process. Note that the odd-numbered voices are given
519 upstems, and the even-numbered voices are given downstems:
521 @lilypond[quote,verbatim]
524 { f''2 } % 1: highest
528 { d''2 } % 3: second-highest
530 { e'2 } % 4: second-lowest
532 { b'2 } % 5: third-highest
534 { g'2 } % 6: third-lowest
538 @warning{Lyrics, spanners (such as slurs, ties, hairpins etc.) cannot be
539 created @q{across} voices.}
541 @subsubsubheading Identical rhythms
543 In the special case that we want to typeset parallel pieces of music
544 that have the same rhythm, we can combine them into a single
545 @code{Voice} context, thus forming chords. To achieve this, enclose
546 them in a simple simultaneous music construct within an explicit voice:
548 @lilypond[quote,relative=2,verbatim]
550 { e4 f8 d e16 f g8 d4 }
551 { c4 d8 b c16 d e8 b4 }
555 This method leads to strange beamings and warnings if the pieces of
556 music do not have the same rhythm.
569 @rlearning{Voices contain music},
570 @rlearning{Explicitly instantiating voices}.
573 @ref{Percussion staves},
574 @ref{Invisible rests},
578 @rlsr{Simultaneous notes}.
582 @unnumberedsubsubsec Voice styles
585 @cindex styles, voice
586 @cindex coloring voices
587 @funindex \voiceOneStyle
588 @funindex \voiceTwoStyle
589 @funindex \voiceThreeStyle
590 @funindex \voiceFourStyle
591 @funindex \voiceNeutralStyle
593 Voices may be given distinct colors and shapes, allowing them to be
596 @lilypond[quote,relative=2,verbatim]
598 { \voiceOneStyle d4 c2 b4 }
600 { \voiceTwoStyle e,2 e }
602 { \voiceThreeStyle b2. c4 }
604 { \voiceFourStyle g'2 g }
608 The @code{\voiceNeutralStyle} command is used to revert to the
609 standard presentation.
613 @code{\voiceOneStyle},
614 @code{\voiceTwoStyle},
615 @code{\voiceThreeStyle},
616 @code{\voiceFourStyle},
617 @code{\voiceNeutralStyle}.
622 @rlearning{I'm hearing Voices},
623 @rlearning{Other sources of information}.
626 @rlsr{Simultaneous notes}.
629 @node Collision resolution
630 @unnumberedsubsubsec Collision resolution
632 @cindex merging notes
633 @cindex note collisions
636 @cindex multiple voices
637 @cindex voices, multiple
638 @cindex polyphonic music
639 @cindex shifting voices
640 @cindex voices, multiple
641 @cindex shift rest, automatic
650 @funindex \mergeDifferentlyDottedOn
651 @funindex mergeDifferentlyDottedOn
652 @funindex \mergeDifferentlyDottedOff
653 @funindex mergeDifferentlyDottedOff
654 @funindex \mergeDifferentlyHeadedOn
655 @funindex mergeDifferentlyHeadedOn
656 @funindex \mergeDifferentlyHeadedOff
657 @funindex mergeDifferentlyHeadedOff
659 The note heads of notes in different voices with the same pitch,
660 same note head and opposite stem direction are automatically
661 merged, but notes with different note heads or the same stem
662 direction are not. Rests opposite a stem in a different voice
663 are shifted vertically. The following example shows three
664 different circumstances, on beats 1 and 3 in bar 1 and beat 1
665 in bar 2, where the automatic merging fails.
667 @lilypond[quote,verbatim,relative=2]
683 Notes with different note heads may be merged as shown
684 below. In this example the note heads on beat 1 of bar 1 are now merged:
686 @lilypond[quote,verbatim,relative=2]
689 \mergeDifferentlyHeadedOn
703 Quarter and half notes are not merged in this way, since it would be difficult
706 Note heads with different dots as shown in beat 3 of bar 1 may be
709 @lilypond[quote,relative=2,verbatim]
712 \mergeDifferentlyHeadedOn
713 \mergeDifferentlyDottedOn
727 The half note and eighth note at the start of the second measure
728 are incorrectly merged because the automatic merge cannot
729 successfully complete the merge when three or more notes line up in
730 the same note column, and in this case the merged note head is
731 incorrect. To allow the merge to select the correct note head
732 a @code{\shift} must be applied to the note that should not be
733 merged. Here, @code{\shiftOn} is applied to move the top
734 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
737 @lilypond[quote,relative=2,verbatim]
740 \mergeDifferentlyHeadedOn
741 \mergeDifferentlyDottedOn
756 The @code{\shiftOn} command allows (but does not force) the notes
757 in a voice to be shifted. When @code{\shiftOn} is applied to a
758 voice, a note or chord in that voice is shifted only if its stem
759 would otherwise collide with a stem from another voice, and only
760 if the colliding stems point in the same direction. The
761 @code{\shiftOff} command prevents this type of shifting from
764 By default, the outer voices (normally voices one and two) have
765 @code{\shiftOff} specified, while the inner voices (three and
766 above) have @code{\shiftOn} specified. When a shift is applied,
767 voices with upstems (odd-numbered voices) are shifted to the
768 right, and voices with downstems (even-numbered voices) are
771 Here is an example to help you visualize how an abbreviated
772 polyphonic expression would be expanded internally.
774 @warning{Note that with three or more voices, the vertical order
775 of voices in your input file should not be the same as the
776 vertical order of voices on the staff!}
778 @lilypond[quote,verbatim]
779 \new Staff \relative c'' {
786 { d'2 } % 3: upper middle
788 { b2 } % 4: lower middle
790 %% internal expansion of the above
792 \new Voice = "1" { \voiceOne \shiftOff f'2 }
793 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
794 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
795 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
800 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
801 provide further shift levels which may be specified temporarily to
802 resolve collisions in complex situations -- see
803 @rlearning{Real music example}.
805 Notes are only merged if they have opposing stem directions (as
806 they have, for example, in voices one and two by default or when
807 the stems are explicitly set in opposite directions).
810 @code{\mergeDifferentlyDottedOn},
811 @code{\mergeDifferentlyDottedOff},
812 @code{\mergeDifferentlyHeadedOn},
813 @code{\mergeDifferentlyHeadedOff}.
822 @lilypondfile[verbatim,quote,texidoc,doctitle]
823 {additional-voices-to-avoid-collisions.ly}
825 @lilypondfile[verbatim,quote,texidoc,doctitle]
826 {forcing-horizontal-shift-of-notes.ly}
833 @rlearning{Multiple notes at once},
834 @rlearning{Voices contain music},
835 @rlearning{Real music example}.
838 @rlsr{Simultaneous notes}.
841 @rinternals{NoteColumn},
842 @rinternals{NoteCollision},
843 @rinternals{RestCollision}.
845 @cindex collisions, ignoring
848 Using @code{\override NoteColumn.ignore-collision = ##t} will cause
849 differently headed notes in different voices to merge incorrectly.
851 @lilypond[quote,relative=1,verbatim]
852 \mergeDifferentlyHeadedOn
853 << { c16 a' b a } \\ { c,2 } >>
854 \override NoteColumn.ignore-collision = ##t
855 << { c16 a' b a } \\ { c,2 } >>
860 @c TODO investigate! Sometimes it works, sometimes not. --FV
861 The requirements for successfully merging different note heads that
862 are at the same time differently dotted are not clear.
866 @node Automatic part combining
867 @unnumberedsubsubsec Automatic part combining
869 @cindex automatic part combining
870 @cindex part combiner
871 @cindex combining parts
874 @funindex \partcombine
875 @funindex partcombine
877 Automatic part combining is used to merge two separate parts of music
878 onto a single staff. This can be especially helpful when typesetting
879 orchestral scores. A single @code{Voice} is printed while the two parts
880 of music are the same, but in places where they differ, a second
881 @code{Voice} is printed. Stem directions are set up & down accordingly
882 while Solo and @notation{a due} parts are also identified and marked
885 The syntax for automatic part combining is:
888 \partcombine @var{musicexpr1} @var{musicexpr2}
891 The following example demonstrates the basic functionality, putting
892 parts on a single staff as polyphony and setting stem directions
893 accordingly. The same variables are used for the independent parts and
896 @lilypond[quote,verbatim]
897 instrumentOne = \relative c' {
905 instrumentTwo = \relative g' {
914 \new Staff \instrumentOne
915 \new Staff \instrumentTwo
916 \new Staff \partcombine \instrumentOne \instrumentTwo
920 Both parts have identical notes in the third measure, so only one
921 instance of the notes is printed. Stem, slur, and tie directions are
922 set automatically, depending on whether the parts are playing solo or in
923 unison. When needed in polyphony situations, the first part (with
924 context called @code{one}) gets @qq{up} stems, while the second (called
925 @code{two}) always gets @qq{down} stems. In solo situations, the first
926 and second parts get marked with @qq{Solo} and @qq{Solo II},
927 respectively. The unison (@notation{a due}) parts are marked with the
930 Both arguments to @code{\partcombine} will be interpreted as separate
931 @code{Voice} contexts, so if the music is being specified in relative
932 mode then @emph{both} parts must contain a @code{\relative} function,
937 \relative @dots{} @var{musicexpr1}
938 \relative @dots{} @var{musicexpr2}
942 A @code{\relative} section that encloses a @code{\partcombine} has no
943 effect on the pitches of @code{@var{musicexpr1}} or
944 @code{@var{musicexpr2}}.
946 @funindex \partcombineChords
947 @funindex partcombineChords
948 @funindex \partcombineApart
949 @funindex partcombineApart
950 @funindex \partcombineUnisono
951 @funindex partcombineUnisono
952 @funindex \partcombineSoloI
953 @funindex partcombineSoloI
954 @funindex \partcombineSoloII
955 @funindex partcombineSoloII
956 @funindex \partcombineAutomatic
957 @funindex partcombineAutomatic
959 In professional scores, voices are often kept apart from each other for
960 long passages of music even if some of the notes are the same in both
961 voices, and could just as easily be printed as unison. Combining notes
962 into a chord, or showing one voice as solo is, therefore, not ideal as
963 the @code{\partcombine} function considers each note separately. In this
964 case the @code{\partcombine} function can be overriden with the
967 Commands ending in @code{@dots{}Once} apply only to the next note in the
972 @code{\partcombineApart} and @code{\partcombineApartOnce} keep the
973 notes as two separate voices, even if they can be combined into a chord
977 @code{\partcombineChords} and @code{\partcombineChordsOnce} combine the
981 @code{\partcombineUnisono} and @code{\partcombineUnisonoOnce} combine
982 both voices as @qq{unison}.
985 @code{\partcombineSoloI} and @code{\partcombineSoloIOnce} print only
986 voice one, and mark it as a @qq{Solo}.
989 @code{\partcombineSoloII} or @code{\partcombineSoloIIOnce} print only
990 voice two and mark it as a @qq{Solo}.
993 @code{\partcombineAutomatic} and @code{\partcombineAutomaticOnce} end
994 the functions of the commands above, and revert back to the standard
995 @code{\partcombine} functionality.
998 @lilypond[quote,verbatim]
999 instrumentOne = \relative c' {
1000 \partcombineApart c2^"apart" e |
1001 \partcombineAutomatic e2^"auto" e |
1002 \partcombineChords e'2^"chord" e |
1003 \partcombineAutomatic c2^"auto" c |
1004 \partcombineApart c2^"apart" \partcombineChordsOnce e^"chord once" |
1007 instrumentTwo = \relative c' {
1017 \new Staff { \instrumentOne }
1018 \new Staff { \instrumentTwo }
1019 \new Staff { \partcombine \instrumentOne \instrumentTwo }
1024 @subsubsubheading Using \partcombine with lyrics
1026 @cindex \partcombine and lyrics
1028 The @code{\partcombine} command is not designed to work with
1029 lyrics; if one of the voices is explicitly named in order to
1030 attach lyrics to it, the partcombiner will stop working. However,
1031 this effect can be achieved using a @code{NullVoice} context. See
1032 @ref{Polyphony with shared lyrics}.
1037 @lilypondfile[verbatim,quote,texidoc,doctitle]
1038 {combining-two-parts-on-the-same-staff.ly}
1040 @lilypondfile[verbatim,quote,texidoc,doctitle]
1041 {changing-partcombine-texts.ly}
1049 @ref{Writing parts}.
1052 @rlsr{Simultaneous notes}.
1054 Internals Reference:
1055 @rinternals{PartCombineMusic},
1059 All @code{\partcombine@dots{}} functions can only accept two voices.
1061 @code{\partcombine@dots{}} functions cannot be placed inside a @code{\tuplet}
1062 or @code{\relative} block.
1064 If @code{printPartCombineTexts} is set and the two voices play the same
1065 notes @qq{on and off}, in the same measure, the part combiner may
1066 typeset @code{a2} more than once in that measure.
1068 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1069 cannot, for example, remember if a note in one @code{Voice} has already
1070 started when combining notes that have just started in the other
1071 @code{Voice}. This can lead to a number of unexpected issues including
1072 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1074 @code{\partcombine} keeps all spanners (slurs, ties, hairpins etc.) in
1075 the same @code{Voice} so that if any such spanners start or end in a
1076 different @code{Voice}, they may not be printed properly or at all.
1078 If the @code{\partcombine} function cannot combine both music
1079 expressions (i.e. when both voices have different durations), it will
1080 give the voices, internally, its own custom names: @code{one} and
1081 @code{two} respectively. This means if there is any @qq{switch} to a
1082 differently named @code{Voice} context, the events in that differently
1083 named @code{Voice} will be ignored.
1085 Refer also to @emph{Known issues and warnings} when using
1086 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1087 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1090 @node Writing music in parallel
1091 @unnumberedsubsubsec Writing music in parallel
1093 @cindex writing music in parallel
1094 @cindex interleaved music
1095 @cindex parallel music
1096 @funindex \parallelMusic
1097 @funindex parallelMusic
1099 Music for multiple parts can be interleaved in input code. The
1100 function @code{\parallelMusic} accepts a list with the names of a
1101 number of variables to be created, and a musical expression. The
1102 content of alternate measures from the expression become the value
1103 of the respective variables, so you can use them afterwards to
1106 @warning{Bar checks @code{|} must be used, and the measures must
1107 be of the same length.}
1109 @lilypond[quote,verbatim]
1110 \parallelMusic #'(voiceA voiceB voiceC) {
1112 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1113 r16 e'8.~ 4 r16 e'8.~ 4 |
1117 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1118 r16 d'8.~ 4 r16 d'8.~ 4 |
1123 \new Staff << \voiceA \\ \voiceB >>
1124 \new Staff { \clef bass \voiceC }
1128 Relative mode may be used. Note that the @code{\relative} command
1129 is not used inside @code{\parallelMusic} itself. The notes are
1130 relative to the preceding note in the voice, not to the previous
1131 note in the input -- in other words, relative notes for
1132 @code{voiceA} ignore the notes in @code{voiceB}.
1134 @lilypond[quote,verbatim]
1135 \parallelMusic #'(voiceA voiceB voiceC) {
1137 r8 g16 c e g, c e r8 g,16 c e g, c e |
1138 r16 e8.~ 4 r16 e8.~ 4 |
1142 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1143 r16 d8.~ 4 r16 d8.~ 4 |
1148 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1149 \new Staff \relative c' { \clef bass \voiceC }
1153 This works quite well for piano music. This example maps four
1154 consecutive measures to four variables:
1156 @lilypond[quote,verbatim]
1162 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1166 c16 d e fis d e fis g |
1172 e16 fis g a fis g a b |
1183 \relative c'' \voiceA
1185 \relative c' \voiceB
1202 @rlearning{Organizing pieces with variables}.
1205 @rlsr{Simultaneous notes}.