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, clashing note columns
290 @cindex collisions, ignoring
293 If notes from two or more voices, with stems in the same direction, are
294 placed at the same position on the staff and have no shift (or have the
295 same shift specified), the message:
298 warning: ignoring too many clashing note columns
301 will appear during compilation. This message can be suppressed by:
304 \override NoteColumn.ignore-collision = ##t
307 However, this not only suppresses the warning but will prevent any
308 collision resolution whatsover and may have other unintended effects
309 (also see @emph{Known Issues} in @ref{Collision resolution}).
313 @unnumberedsubsubsec Clusters
318 @funindex \makeClusters
319 @funindex makeClusters
321 A cluster indicates a continuous range of pitches to be played.
322 They can be denoted as the envelope of a set of notes. They are
323 entered by applying the function @code{\makeClusters} to a sequence
326 @lilypond[quote,relative=2,verbatim]
327 \makeClusters { <g b>2 <c g'> }
330 Ordinary notes and clusters can be put together in the same staff,
331 even simultaneously. In such a case no attempt is made to
332 automatically avoid collisions between ordinary notes and clusters.
339 @rlsr{Simultaneous notes}.
342 @rinternals{ClusterSpanner},
343 @rinternals{ClusterSpannerBeacon},
344 @rinternals{Cluster_spanner_engraver}.
347 Clusters look good only if they span at least two chords; otherwise
348 they appear too narrow.
350 Clusters do not have a stem and cannot indicate durations by
351 themselves, but the length of the printed cluster is determined by
352 the durations of the defining chords. Separate clusters need a
353 separating rest between them.
355 Clusters do not produce MIDI output.
358 @node Multiple voices
359 @subsection Multiple voices
361 This section discusses simultaneous notes in multiple voices or
365 * Single-staff polyphony::
367 * Collision resolution::
368 * Automatic part combining::
369 * Writing music in parallel::
373 @node Single-staff polyphony
374 @unnumberedsubsubsec Single-staff polyphony
376 @cindex single-staff polyphony
377 @cindex polyphony, single-staff
379 @cindex lyrics assigned to one voice
383 @funindex \voiceOne ... \voiceFour
388 @subsubsubheading Explicitly instantiating voices
390 The basic structure needed to achieve multiple independent
391 voices in a single staff is illustrated in the following example:
393 @lilypond[quote,relative=3,verbatim]
396 { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
398 { \voiceTwo d16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
403 Here, voices are instantiated explicitly and are given names. The
404 @code{\voiceOne} @dots{} @code{\voiceFour} commands set up the voices
405 so that first and third voices get stems up, second and fourth
406 voices get stems down, third and fourth voice note heads are
407 horizontally shifted, and rests in the respective voices are
408 automatically moved to avoid collisions. The @code{\oneVoice}
409 command returns all the voice settings to the neutral default
412 @subsubsubheading Temporary polyphonic passages
414 A temporary polyphonic passage can be created with the following
418 << @{ \voiceOne @dots{} @}
419 \new Voice @{ \voiceTwo @dots{} @}
424 Here, the first expression within a temporary polyphonic passage is
425 placed into the @code{Voice} context which was in use immediately
426 before the polyphonic passage, and that same @code{Voice} context
427 continues after the temporary section. Other expressions within
428 the angle brackets are assigned to distinct temporary voices.
429 This allows lyrics to be assigned to one continuing voice before,
430 during and after a polyphonic section:
432 @lilypond[quote, verbatim, relative=2]
434 \new Voice = "melody" {
449 \new Lyrics \lyricsto "melody" {
456 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
457 required to define the settings of each voice.
459 @subsubsubheading The double backslash construct
461 The @code{<< @{@dots{}@} \\ @{@dots{}@} >>} construct, where the two (or
462 more) expressions are separated by double backslashes, behaves
463 differently to the similar construct without the double backslashes:
464 @emph{all} the expressions within this construct are assigned
465 to new @code{Voice} contexts. These new @code{Voice} contexts
466 are created implicitly and are given the fixed names @code{"1"},
469 The first example could be typeset as follows:
471 @lilypond[quote,relative=3,verbatim]
473 { r8 r16 g e8. f16 g8[ c,] f e16 d }
475 { d16 c d8~ 16 b c8~ 16 b c8~ 16 b8. }
479 This syntax can be used where it does not matter that temporary
480 voices are created and then discarded. These implicitly created
481 voices are given the settings equivalent to the effect of the
482 @code{\voiceOne} @dots{} @code{\voiceFour} commands, in the order in
483 which they appear in the code.
485 In the following example, the intermediate voice has stems up,
486 therefore we enter it in the third place, so it becomes voice
487 three, which has the stems up as desired. Spacer rests are
488 used to avoid printing doubled rests.
490 @lilypond[quote,relative=3,verbatim]
492 { r8 g g g g f16 ees f8 d }
494 { ees,8 r ees r d r d r }
496 { d'8 s c s bes s a s }
500 In all but the simplest works it is advisable to create explicit
501 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
502 @rlearning{Explicitly instantiating voices}.
504 @subsubsubheading Voice order
506 When entering multiple voices in the input file, use the following
512 Voice 3: second highest
513 Voice 4: second lowest
514 Voice 5: third highest
515 Voice 6: third lowest
519 Though this may seem counterintuitive, it simplifies the automatic
520 layout process. Note that the odd-numbered voices are given
521 upstems, and the even-numbered voices are given downstems:
523 @lilypond[quote,verbatim]
526 { f''2 } % 1: highest
530 { d''2 } % 3: second-highest
532 { e'2 } % 4: second-lowest
534 { b'2 } % 5: third-highest
536 { g'2 } % 6: third-lowest
540 @warning{Lyrics, spanners (such as slurs, ties, hairpins etc.) cannot be
541 created @q{across} voices.}
543 @subsubsubheading Identical rhythms
545 In the special case that we want to typeset parallel pieces of music
546 that have the same rhythm, we can combine them into a single
547 @code{Voice} context, thus forming chords. To achieve this, enclose
548 them in a simple simultaneous music construct within an explicit voice:
550 @lilypond[quote,relative=2,verbatim]
552 { e4 f8 d e16 f g8 d4 }
553 { c4 d8 b c16 d e8 b4 }
557 This method leads to strange beamings and warnings if the pieces of
558 music do not have the same rhythm.
571 @rlearning{Voices contain music},
572 @rlearning{Explicitly instantiating voices}.
575 @ref{Percussion staves},
576 @ref{Invisible rests},
580 @rlsr{Simultaneous notes}.
584 @unnumberedsubsubsec Voice styles
587 @cindex styles, voice
588 @cindex coloring voices
589 @funindex \voiceOneStyle
590 @funindex \voiceTwoStyle
591 @funindex \voiceThreeStyle
592 @funindex \voiceFourStyle
593 @funindex \voiceNeutralStyle
595 Voices may be given distinct colors and shapes, allowing them to be
598 @lilypond[quote,relative=2,verbatim]
600 { \voiceOneStyle d4 c2 b4 }
602 { \voiceTwoStyle e,2 e }
604 { \voiceThreeStyle b2. c4 }
606 { \voiceFourStyle g'2 g }
610 The @code{\voiceNeutralStyle} command is used to revert to the
611 standard presentation.
615 @code{\voiceOneStyle},
616 @code{\voiceTwoStyle},
617 @code{\voiceThreeStyle},
618 @code{\voiceFourStyle},
619 @code{\voiceNeutralStyle}.
624 @rlearning{I'm hearing Voices},
625 @rlearning{Other sources of information}.
628 @rlsr{Simultaneous notes}.
631 @node Collision resolution
632 @unnumberedsubsubsec Collision resolution
634 @cindex merging notes
635 @cindex note collisions
638 @cindex multiple voices
639 @cindex voices, multiple
640 @cindex polyphonic music
641 @cindex shifting voices
642 @cindex voices, multiple
643 @cindex shift rest, automatic
652 @funindex \mergeDifferentlyDottedOn
653 @funindex mergeDifferentlyDottedOn
654 @funindex \mergeDifferentlyDottedOff
655 @funindex mergeDifferentlyDottedOff
656 @funindex \mergeDifferentlyHeadedOn
657 @funindex mergeDifferentlyHeadedOn
658 @funindex \mergeDifferentlyHeadedOff
659 @funindex mergeDifferentlyHeadedOff
661 The note heads of notes in different voices with the same pitch,
662 same note head and opposite stem direction are automatically
663 merged, but notes with different note heads or the same stem
664 direction are not. Rests opposite a stem in a different voice
665 are shifted vertically. The following example shows three
666 different circumstances, on beats 1 and 3 in bar 1 and beat 1
667 in bar 2, where the automatic merging fails.
669 @lilypond[quote,verbatim,relative=2]
685 Notes with different note heads may be merged as shown
686 below. In this example the note heads on beat 1 of bar 1 are now merged:
688 @lilypond[quote,verbatim,relative=2]
691 \mergeDifferentlyHeadedOn
705 Quarter and half notes are not merged in this way, since it would be difficult
708 Note heads with different dots as shown in beat 3 of bar 1 may be
711 @lilypond[quote,relative=2,verbatim]
714 \mergeDifferentlyHeadedOn
715 \mergeDifferentlyDottedOn
729 The half note and eighth note at the start of the second measure
730 are incorrectly merged because the automatic merge cannot
731 successfully complete the merge when three or more notes line up in
732 the same note column, and in this case the merged note head is
733 incorrect. To allow the merge to select the correct note head
734 a @code{\shift} must be applied to the note that should not be
735 merged. Here, @code{\shiftOn} is applied to move the top
736 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
739 @lilypond[quote,relative=2,verbatim]
742 \mergeDifferentlyHeadedOn
743 \mergeDifferentlyDottedOn
758 The @code{\shiftOn} command allows (but does not force) the notes
759 in a voice to be shifted. When @code{\shiftOn} is applied to a
760 voice, a note or chord in that voice is shifted only if its stem
761 would otherwise collide with a stem from another voice, and only
762 if the colliding stems point in the same direction. The
763 @code{\shiftOff} command prevents this type of shifting from
766 By default, the outer voices (normally voices one and two) have
767 @code{\shiftOff} specified, while the inner voices (three and
768 above) have @code{\shiftOn} specified. When a shift is applied,
769 voices with upstems (odd-numbered voices) are shifted to the
770 right, and voices with downstems (even-numbered voices) are
773 Here is an example to help you visualize how an abbreviated
774 polyphonic expression would be expanded internally.
776 @warning{Note that with three or more voices, the vertical order
777 of voices in your input file should not be the same as the
778 vertical order of voices on the staff!}
780 @lilypond[quote,verbatim]
781 \new Staff \relative c'' {
788 { d'2 } % 3: upper middle
790 { b2 } % 4: lower middle
792 %% internal expansion of the above
794 \new Voice = "1" { \voiceOne \shiftOff f'2 }
795 \new Voice = "2" { \voiceTwo \shiftOff g,2 }
796 \new Voice = "3" { \voiceThree \shiftOn d'2 } % shifts right
797 \new Voice = "4" { \voiceFour \shiftOn b2 } % shifts left
802 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
803 provide further shift levels which may be specified temporarily to
804 resolve collisions in complex situations -- see
805 @rlearning{Real music example}.
807 Notes are only merged if they have opposing stem directions (as
808 they have, for example, in voices one and two by default or when
809 the stems are explicitly set in opposite directions).
812 @code{\mergeDifferentlyDottedOn},
813 @code{\mergeDifferentlyDottedOff},
814 @code{\mergeDifferentlyHeadedOn},
815 @code{\mergeDifferentlyHeadedOff}.
824 @lilypondfile[verbatim,quote,texidoc,doctitle]
825 {additional-voices-to-avoid-collisions.ly}
827 @lilypondfile[verbatim,quote,texidoc,doctitle]
828 {forcing-horizontal-shift-of-notes.ly}
835 @rlearning{Multiple notes at once},
836 @rlearning{Voices contain music},
837 @rlearning{Real music example}.
840 @rlsr{Simultaneous notes}.
843 @rinternals{NoteColumn},
844 @rinternals{NoteCollision},
845 @rinternals{RestCollision}.
847 @cindex collisions, ignoring
850 Using @code{\override NoteColumn.ignore-collision = ##t} will cause
851 differently headed notes in different voices to merge incorrectly.
853 @lilypond[quote,relative=1,verbatim]
854 \mergeDifferentlyHeadedOn
855 << { c16 a' b a } \\ { c,2 } >>
856 \override NoteColumn.ignore-collision = ##t
857 << { c16 a' b a } \\ { c,2 } >>
862 @c TODO investigate! Sometimes it works, sometimes not. --FV
863 The requirements for successfully merging different note heads that
864 are at the same time differently dotted are not clear.
868 @node Automatic part combining
869 @unnumberedsubsubsec Automatic part combining
871 @cindex automatic part combining
872 @cindex part combiner
873 @cindex combining parts
876 @funindex \partcombine
877 @funindex partcombine
879 Automatic part combining is used to merge two separate parts of music
880 onto a single staff. This can be especially helpful when typesetting
881 orchestral scores. A single @code{Voice} is printed while the two parts
882 of music are the same, but in places where they differ, a second
883 @code{Voice} is printed. Stem directions are set up & down accordingly
884 while Solo and @notation{a due} parts are also identified and marked
887 The syntax for automatic part combining is:
890 \partcombine @var{musicexpr1} @var{musicexpr2}
893 The following example demonstrates the basic functionality, putting
894 parts on a single staff as polyphony and setting stem directions
895 accordingly. The same variables are used for the independent parts and
898 @lilypond[quote,verbatim]
899 instrumentOne = \relative c' {
907 instrumentTwo = \relative g' {
916 \new Staff \instrumentOne
917 \new Staff \instrumentTwo
918 \new Staff \partcombine \instrumentOne \instrumentTwo
922 Both parts have identical notes in the third measure, so only one
923 instance of the notes is printed. Stem, slur, and tie directions are
924 set automatically, depending on whether the parts are playing solo or in
925 unison. When needed in polyphony situations, the first part (with
926 context called @code{one}) gets @qq{up} stems, while the second (called
927 @code{two}) always gets @qq{down} stems. In solo situations, the first
928 and second parts get marked with @qq{Solo} and @qq{Solo II},
929 respectively. The unison (@notation{a due}) parts are marked with the
932 Both arguments to @code{\partcombine} will be interpreted as separate
933 @code{Voice} contexts, so if the music is being specified in relative
934 mode then @emph{both} parts must contain a @code{\relative} function,
939 \relative @dots{} @var{musicexpr1}
940 \relative @dots{} @var{musicexpr2}
944 A @code{\relative} section that encloses a @code{\partcombine} has no
945 effect on the pitches of @code{@var{musicexpr1}} or
946 @code{@var{musicexpr2}}.
948 @funindex \partcombineChords
949 @funindex partcombineChords
950 @funindex \partcombineApart
951 @funindex partcombineApart
952 @funindex \partcombineUnisono
953 @funindex partcombineUnisono
954 @funindex \partcombineSoloI
955 @funindex partcombineSoloI
956 @funindex \partcombineSoloII
957 @funindex partcombineSoloII
958 @funindex \partcombineAutomatic
959 @funindex partcombineAutomatic
961 In professional scores, voices are often kept apart from each other for
962 long passages of music even if some of the notes are the same in both
963 voices, and could just as easily be printed as unison. Combining notes
964 into a chord, or showing one voice as solo is, therefore, not ideal as
965 the @code{\partcombine} function considers each note separately. In this
966 case the @code{\partcombine} function can be overriden with the
969 Commands ending in @code{@dots{}Once} apply only to the next note in the
974 @code{\partcombineApart} and @code{\partcombineApartOnce} keep the
975 notes as two separate voices, even if they can be combined into a chord
979 @code{\partcombineChords} and @code{\partcombineChordsOnce} combine the
983 @code{\partcombineUnisono} and @code{\partcombineUnisonoOnce} combine
984 both voices as @qq{unison}.
987 @code{\partcombineSoloI} and @code{\partcombineSoloIOnce} print only
988 voice one, and mark it as a @qq{Solo}.
991 @code{\partcombineSoloII} or @code{\partcombineSoloIIOnce} print only
992 voice two and mark it as a @qq{Solo}.
995 @code{\partcombineAutomatic} and @code{\partcombineAutomaticOnce} end
996 the functions of the commands above, and revert back to the standard
997 @code{\partcombine} functionality.
1000 @lilypond[quote,verbatim]
1001 instrumentOne = \relative c' {
1002 \partcombineApart c2^"apart" e |
1003 \partcombineAutomatic e2^"auto" e |
1004 \partcombineChords e'2^"chord" e |
1005 \partcombineAutomatic c2^"auto" c |
1006 \partcombineApart c2^"apart" \partcombineChordsOnce e^"chord once" |
1009 instrumentTwo = \relative c' {
1019 \new Staff { \instrumentOne }
1020 \new Staff { \instrumentTwo }
1021 \new Staff { \partcombine \instrumentOne \instrumentTwo }
1026 @subsubsubheading Using \partcombine with lyrics
1028 @cindex \partcombine and lyrics
1030 The @code{\partcombine} command is not designed to work with
1031 lyrics; if one of the voices is explicitly named in order to
1032 attach lyrics to it, the partcombiner will stop working. However,
1033 this effect can be achieved using a @code{NullVoice} context. See
1034 @ref{Polyphony with shared lyrics}.
1039 @lilypondfile[verbatim,quote,texidoc,doctitle]
1040 {combining-two-parts-on-the-same-staff.ly}
1042 @lilypondfile[verbatim,quote,texidoc,doctitle]
1043 {changing-partcombine-texts.ly}
1051 @ref{Writing parts}.
1054 @rlsr{Simultaneous notes}.
1056 Internals Reference:
1057 @rinternals{PartCombineMusic},
1061 All @code{\partcombine@dots{}} functions can only accept two voices.
1063 @code{\partcombine@dots{}} functions cannot be placed inside a @code{\tuplet}
1064 or @code{\relative} block.
1066 If @code{printPartCombineTexts} is set and the two voices play the same
1067 notes @qq{on and off}, in the same measure, the part combiner may
1068 typeset @code{a2} more than once in that measure.
1070 @code{\partcombine} only knows when a note starts in a @code{Voice}; it
1071 cannot, for example, remember if a note in one @code{Voice} has already
1072 started when combining notes that have just started in the other
1073 @code{Voice}. This can lead to a number of unexpected issues including
1074 @qq{Solo} or @qq{Unison} marks being printed incorrectly.
1076 @code{\partcombine} keeps all spanners (slurs, ties, hairpins etc.) in
1077 the same @code{Voice} so that if any such spanners start or end in a
1078 different @code{Voice}, they may not be printed properly or at all.
1080 If the @code{\partcombine} function cannot combine both music
1081 expressions (i.e. when both voices have different durations), it will
1082 give the voices, internally, its own custom names: @code{one} and
1083 @code{two} respectively. This means if there is any @qq{switch} to a
1084 differently named @code{Voice} context, the events in that differently
1085 named @code{Voice} will be ignored.
1087 Refer also to @emph{Known issues and warnings} when using
1088 @code{\partcombine} with tablature in @ref{Default tablatures} and the
1089 @emph{Note} in @ref{Automatic beams} when using automatic beaming.
1092 @node Writing music in parallel
1093 @unnumberedsubsubsec Writing music in parallel
1095 @cindex writing music in parallel
1096 @cindex interleaved music
1097 @cindex parallel music
1098 @funindex \parallelMusic
1099 @funindex parallelMusic
1101 Music for multiple parts can be interleaved in input code. The
1102 function @code{\parallelMusic} accepts a list with the names of a
1103 number of variables to be created, and a musical expression. The
1104 content of alternate measures from the expression become the value
1105 of the respective variables, so you can use them afterwards to
1108 @warning{Bar checks @code{|} must be used, and the measures must
1109 be of the same length.}
1111 @lilypond[quote,verbatim]
1112 \parallelMusic #'(voiceA voiceB voiceC) {
1114 r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
1115 r16 e'8.~ 4 r16 e'8.~ 4 |
1119 r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
1120 r16 d'8.~ 4 r16 d'8.~ 4 |
1125 \new Staff << \voiceA \\ \voiceB >>
1126 \new Staff { \clef bass \voiceC }
1130 Relative mode may be used. Note that the @code{\relative} command
1131 is not used inside @code{\parallelMusic} itself. The notes are
1132 relative to the preceding note in the voice, not to the previous
1133 note in the input -- in other words, relative notes for
1134 @code{voiceA} ignore the notes in @code{voiceB}.
1136 @lilypond[quote,verbatim]
1137 \parallelMusic #'(voiceA voiceB voiceC) {
1139 r8 g16 c e g, c e r8 g,16 c e g, c e |
1140 r16 e8.~ 4 r16 e8.~ 4 |
1144 r8 a,16 d f a, d f r8 a,16 d f a, d f |
1145 r16 d8.~ 4 r16 d8.~ 4 |
1150 \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
1151 \new Staff \relative c' { \clef bass \voiceC }
1155 This works quite well for piano music. This example maps four
1156 consecutive measures to four variables:
1158 @lilypond[quote,verbatim]
1164 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
1168 c16 d e fis d e fis g |
1174 e16 fis g a fis g a b |
1185 \relative c'' \voiceA
1187 \relative c' \voiceB
1204 @rlearning{Organizing pieces with variables}.
1207 @rlsr{Simultaneous notes}.