]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/simultaneous.itely
55bf27b1018c1d7d50a86ef571920835b144e9b9
[lilypond.git] / Documentation / notation / simultaneous.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
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..
8 @end ignore
9
10 @c \version "2.13.36"
11
12
13 @node Simultaneous notes
14 @section Simultaneous notes
15
16 @lilypondfile[quote]{simultaneous-headword.ly}
17
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.
21
22 @menu
23 * Single voice::
24 * Multiple voices::
25 @end menu
26
27
28 @node Single voice
29 @subsection Single voice
30
31 This section discusses simultaneous notes inside the same voice.
32
33 @menu
34 * Chorded notes::
35 * Chord repetition::
36 * Simultaneous expressions::
37 * Clusters::
38 @end menu
39
40
41 @node Chorded notes
42 @unnumberedsubsubsec Chorded notes
43
44 @cindex chords
45 @cindex brackets, angle
46
47 @funindex <
48 @funindex >
49 @funindex <...>
50
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
53 notes.
54
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
57 @end lilypond
58
59 Chords may also be followed by articulations, again just like simple
60 notes.
61
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-.
64 @end lilypond
65
66 The notes within the chord themselves can also be followed by articulation
67 and ornamentation.
68
69 @lilypond[verbatim,quote,relative=2]
70 <a c\prall e>1 <a-> c-^ e>2 <f-. a c-. e-.>4 <a-+ c-->8. <g\fermata c e\turn>16
71 @end lilypond
72
73 However some notation, such as dynamics, hairpins and slurs must be
74 attached to the chord, rather than notes within the chord, otherwise
75 they will not print.
76
77 @lilypond[verbatim,quote,relative=2]
78 <a\f c( e>1 <a c) e>\f <a\< c e>( <a\! c e>) <a c e>\< <a c e> <a c e>\!
79 @end lilypond
80
81 @cindex relative pitch, chords
82 @cindex chords, relative pitch
83
84 Relative mode can be used for pitches in chords.  The first note of
85 each chord is always relative to the first note of the chord that
86 came before it, or in the case where no preceding chord exists, the
87 pitch of the last note that came before the chord.  All remaining notes
88 in the chord are relative to the note that came before it
89 @emph{within the same chord}.
90
91 @lilypond[verbatim,quote,relative=2]
92 <a c e>1 <f a c> <a c e> <f' a c> <b, e b,>
93 @end lilypond
94
95 For more information about chords, see @ref{Chord notation}.
96
97 @seealso
98 Music Glossary:
99 @rglos{chord}.
100
101 Learning Manual:
102 @rlearning{Combining notes into chords}.
103
104 Notation Reference:
105 @ref{Chord notation},
106 @ref{Articulations and ornamentations},
107 @ref{Relative octave entry}.
108
109 Snippets:
110 @rlsr{Simultaneous notes}.
111
112
113 @node Chord repetition
114 @unnumberedsubsubsec Chord repetition
115
116 In order to save typing, a shortcut can be used to repeat the preceding
117 chord.  The chord repetition symbol is @code{q}:
118
119 @lilypond[verbatim,quote,relative=2]
120 <a c e>1 q <f a c>2 q
121 @end lilypond
122
123 As with regular chords, the chord repetition symbol can be used with
124 durations, articulations, markups, slurs, beams, etc. as only the
125 pitches of the previous chord are duplicated.
126
127 @lilypond[verbatim,quote,relative=2]
128 <a c e>1\p^"text" q2\<( q8)[-| q8.]\! q16-1-2-3 q8\prall
129 @end lilypond
130
131 The chord repetition symbol always remembers the last instance of
132 a chord so it is possible to repeat the most recent chord even if
133 other non-chorded notes or rests have been added since.
134
135 @lilypond[verbatim,quote,relative=2]
136 <a c e>1 c4 q2 r8 q8
137 @end lilypond
138
139 However, the chord repetition symbol does not retain any dynamics,
140 articulation or ornamentation within, or attached to the previous chord.
141
142 @lilypond[verbatim,quote,relative=2]
143 <a-. c\prall e>1\sfz c4 q2 r8 q8
144 @end lilypond
145
146 @seealso
147 Notation Reference:
148 @ref{Chord notation},
149 @ref{Articulations and ornamentations}.
150
151 Installed Files:
152 @file{ly/@/chord@/-repetition@/-init@/.ly}.
153
154
155 @node Simultaneous expressions
156 @unnumberedsubsubsec Simultaneous expressions
157
158 One or more music expressions enclosed in double angle brackets are
159 taken to be simultaneous.  If the first expression begins with a
160 single note or if the whole simultaneous expression appears
161 explicitly within a single voice, the whole expression is placed on
162 a single staff; otherwise the elements of the simultaneous
163 expression are placed on separate staves.
164
165 The following examples show simultaneous expressions on one staff:
166
167 @lilypond[quote,verbatim,relative=2]
168 \new Voice {  % explicit single voice
169   << { a4 b g2 } { d4 g c,2 } >>
170 }
171 @end lilypond
172
173 @lilypond[quote,verbatim,relative=2]
174 % single first note
175 a << { a4 b g } { d4 g c, } >>
176 @end lilypond
177
178 This can be useful if the simultaneous sections have identical
179 rhythms, but attempts to attach notes with different durations
180 to the same stem will cause errors.
181
182 The following example shows how simultaneous expressions can
183 generate multiple staves implicitly:
184
185 @lilypond[quote,verbatim,relative=2]
186 % no single first note
187 << { a4 b g2 } { d4 g2 c,4 } >>
188 @end lilypond
189
190 Here different rhythms cause no problems.
191
192
193 @node Clusters
194 @unnumberedsubsubsec Clusters
195
196 @cindex cluster
197 @cindex note cluster
198
199 @funindex \makeClusters
200 @funindex makeClusters
201
202 A cluster indicates a continuous range of pitches to be played.
203 They can be denoted as the envelope of a set of notes.  They are
204 entered by applying the function @code{\makeClusters} to a sequence
205 of chords, e.g.,
206
207 @lilypond[quote,relative=2,verbatim]
208 \makeClusters { <g b>2 <c g'> }
209 @end lilypond
210
211 Ordinary notes and clusters can be put together in the same staff,
212 even simultaneously.  In such a case no attempt is made to
213 automatically avoid collisions between ordinary notes and clusters.
214
215
216 @seealso
217 Music Glossary:
218 @rglos{cluster}.
219
220 Snippets:
221 @rlsr{Simultaneous notes}.
222
223 Internals Reference:
224 @rinternals{ClusterSpanner},
225 @rinternals{ClusterSpannerBeacon},
226 @rinternals{Cluster_spanner_engraver}.
227
228
229 @knownissues
230
231 Clusters look good only if they span at least two chords; otherwise
232 they appear too narrow.
233
234 Clusters do not have a stem and cannot indicate durations by
235 themselves, but the length of the printed cluster is determined by
236 the durations of the defining chords.  Separate clusters need a
237 separating rest between them.
238
239 Clusters do not produce MIDI output.
240
241 @node Multiple voices
242 @subsection Multiple voices
243
244 This section discusses simultaneous notes in multiple voices or
245 multiple staves.
246
247 @menu
248 * Single-staff polyphony::
249 * Voice styles::
250 * Collision resolution::
251 * Automatic part combining::
252 * Writing music in parallel::
253 @end menu
254
255
256 @node Single-staff polyphony
257 @unnumberedsubsubsec Single-staff polyphony
258
259 @cindex single-staff polyphony
260 @cindex polyphony, single-staff
261 @cindex voice
262 @cindex lyrics assigned to one voice
263
264 @funindex \voiceOne
265 @funindex voiceOne
266 @funindex \voiceOne ... \voiceFour
267 @funindex Voice
268 @funindex \oneVoice
269 @funindex oneVoice
270
271 @strong{@i{Explicitly instantiating voices}}
272
273 The basic structure needed to achieve multiple independent
274 voices in a single staff is illustrated in the following example:
275
276 @lilypond[quote,relative=3,verbatim]
277 \new Staff <<
278   \new Voice = "first"
279     { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
280   \new Voice= "second"
281     { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
282 >>
283 @end lilypond
284
285 @noindent
286 Here, voices are instantiated explicitly and are given names.  The
287 @code{\voiceOne} ... @code{\voiceFour} commands set up the voices
288 so that first and third voices get stems up, second and fourth
289 voices get stems down, third and fourth voice note heads are
290 horizontally shifted, and rests in the respective voices are
291 automatically moved to avoid collisions.  The @code{\oneVoice}
292 command returns all the voice settings to the neutral default
293 directions.
294
295 @strong{@i{Temporary polyphonic passages}}
296
297 A temporary polyphonic passage can be created with the following
298 construct:
299
300 @example
301 << @{ \voiceOne ... @}
302   \new Voice @{ \voiceTwo ... @}
303 >> \oneVoice
304 @end example
305
306 @noindent
307 Here, the first expression within a temporary polyphonic passage is
308 placed into the @code{Voice} context which was in use immediately
309 before the polyphonic passage, and that same @code{Voice} context
310 continues after the temporary section.  Other expressions within
311 the angle brackets are assigned to distinct temporary voices.
312 This allows lyrics to be assigned to one continuing voice before,
313 during and after a polyphonic section:
314
315 @lilypond[quote, verbatim, relative=2]
316 <<
317   \new Voice = "melody" {
318     a4
319     <<
320       {
321         \voiceOne
322         g f
323       }
324       \new Voice {
325         \voiceTwo
326         d2
327       }
328     >>
329     \oneVoice
330     e4
331   }
332   \new Lyrics \lyricsto "melody" {
333   This is my song.
334   }
335 >>
336 @end lilypond
337
338 @noindent
339 Here, the @code{\voiceOne} and @code{\voiceTwo} commands are
340 required to define the settings of each voice.
341
342 @strong{@i{The double backslash construct}}
343
344 The @code{<< @{...@} \\ @{...@} >>} construct, where the two (or
345 more) expressions are separated by double backslashes, behaves
346 differently to the similar construct without the double backslashes:
347 @emph{all} the expressions within this construct are assigned
348 to new @code{Voice} contexts.  These new @code{Voice} contexts
349 are created implicitly and are given the fixed names @code{"1"},
350 @code{"2"}, etc.
351
352 The first example could be typeset as follows:
353
354 @lilypond[quote,relative=3,verbatim]
355 <<
356   { r8 r16 g e8. f16 g8[ c,] f e16 d }
357   \\
358   { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
359 >>
360 @end lilypond
361
362 This syntax can be used where it does not matter that temporary
363 voices are created and then discarded.  These implicitly created
364 voices are given the settings equivalent to the effect of the
365 @code{\voiceOne} ... @code{\voiceFour} commands, in the order in
366 which they appear in the code.
367
368 In the following example, the intermediate voice has stems up,
369 therefore we enter it in the third place, so it becomes voice
370 three, which has the stems up as desired.  Spacer rests are
371 used to avoid printing doubled rests.
372
373 @lilypond[quote,relative=3,verbatim]
374 <<
375   { r8 g g  g g f16 ees f8 d }
376   \\
377   { ees,8 r ees r d r d r }
378   \\
379   { d'8 s c s bes s a s }
380 >>
381 @end lilypond
382
383 In all but the simplest works it is advisable to create explicit
384 @code{Voice} contexts as explained in @rlearning{Contexts and engravers} and
385 @rlearning{Explicitly instantiating voices}.
386
387 @strong{@i{Voice order}}
388
389 When entering multiple voices in the input file, use the following
390 order:
391
392 @example
393 Voice 1: highest
394 Voice 2: lowest
395 Voice 3: second highest
396 Voice 4: second lowest
397 Voice 5: third highest
398 Voice 6: third lowest
399 etc.
400 @end example
401
402 Though this may seem counterintuitive, it simplifies the automatic
403 layout process.  Note that the odd-numbered voices are given
404 upstems, and the even-numbered voices are given downstems:
405
406 @lilypond[quote,verbatim]
407 \new Staff <<
408   \time 2/4
409   { f''2 }  % 1: highest
410   \\
411   { c'2  }  % 2: lowest
412   \\
413   { d''2 }  % 3: second-highest
414   \\
415   { e'2  }  % 4: second-lowest
416   \\
417   { b'2  }  % 5: third-highest
418   \\
419   { g'2  }  % 6: third-lowest
420 >>
421 @end lilypond
422
423 @strong{@i{Identical rhythms}}
424
425 In the special case that we want to typeset parallel pieces of music
426 that have the same rhythm, we can combine them into a single
427 @code{Voice} context, thus forming chords.  To achieve this, enclose
428 them in a simple simultaneous music construct within an explicit voice:
429
430 @lilypond[quote,relative=2,verbatim]
431 \new Voice <<
432   { e4 f8 d e16 f g8 d4 }
433   { c4 d8 b c16 d e8 b4 }
434 >>
435 @end lilypond
436
437 This method leads to strange beamings and warnings if the pieces of
438 music do not have the same rhythm.
439
440
441 @predefined
442 @code{\voiceOne},
443 @code{\voiceTwo},
444 @code{\voiceThree},
445 @code{\voiceFour},
446 @code{\oneVoice}.
447 @endpredefined
448
449
450 @seealso
451 Learning Manual:
452 @rlearning{Voices contain music},
453 @rlearning{Explicitly instantiating voices}.
454
455 Notation Reference:
456 @ref{Percussion staves},
457 @ref{Invisible rests},
458 @ref{Stems}.
459
460 Snippets:
461 @rlsr{Simultaneous notes}.
462
463
464 @node Voice styles
465 @unnumberedsubsubsec Voice styles
466
467 @cindex voice styles
468 @cindex styles, voice
469 @cindex coloring voices
470 @funindex \voiceOneStyle
471 @funindex \voiceTwoStyle
472 @funindex \voiceThreeStyle
473 @funindex \voiceFourStyle
474 @funindex \voiceNeutralStyle
475
476 Voices may be given distinct colors and shapes, allowing them to be
477 easily identified:
478
479 @lilypond[quote,relative=2,verbatim]
480 <<
481   { \voiceOneStyle d4 c2 b4 }
482   \\
483   { \voiceTwoStyle e,2 e }
484   \\
485   { \voiceThreeStyle b2. c4 }
486   \\
487   { \voiceFourStyle g'2 g }
488 >>
489 @end lilypond
490
491 The @code{\voiceNeutralStyle} command is used to revert to the
492 standard presentation.
493
494
495 @predefined
496 @code{\voiceOneStyle},
497 @code{\voiceTwoStyle},
498 @code{\voiceThreeStyle},
499 @code{\voiceFourStyle},
500 @code{\voiceNeutralStyle}.
501 @endpredefined
502
503
504 @seealso
505 Learning Manual:
506 @rlearning{I'm hearing Voices},
507 @rlearning{Other sources of information}.
508
509 Snippets:
510 @rlsr{Simultaneous notes}.
511
512
513 @node Collision resolution
514 @unnumberedsubsubsec Collision resolution
515
516 @cindex merging notes
517 @cindex note collisions
518 @cindex collisions
519 @cindex shift note
520 @cindex multiple voices
521 @cindex voices, multiple
522 @cindex polyphonic music
523 @cindex shifting voices
524 @cindex voices, multiple
525 @cindex shift rest, automatic
526 @funindex \shiftOn
527 @funindex shiftOn
528 @funindex \shiftOnn
529 @funindex shiftOnn
530 @funindex \shiftOnnn
531 @funindex shiftOnnn
532 @funindex \shiftOff
533 @funindex shiftOff
534 @funindex \mergeDifferentlyDottedOn
535 @funindex mergeDifferentlyDottedOn
536 @funindex \mergeDifferentlyDottedOff
537 @funindex mergeDifferentlyDottedOff
538 @funindex \mergeDifferentlyHeadedOn
539 @funindex mergeDifferentlyHeadedOn
540 @funindex \mergeDifferentlyHeadedOff
541 @funindex mergeDifferentlyHeadedOff
542
543 The note heads of notes in different voices with the same pitch,
544 same note head and opposite stem direction are automatically
545 merged, but notes with different note heads or the same stem
546 direction are not.  Rests opposite a stem in a different voice
547 are shifted vertically.  The following example shows three
548 different circumstances, on beats 1 and 3 in bar 1 and beat 1
549 in bar 2, where the automatic merging fails.
550
551 @lilypond[quote,verbatim,relative=2]
552 <<
553   {
554     c8 d e d c d c4
555     g'2 fis
556   } \\ {
557     c2 c8. b16 c4
558     e,2 r
559   } \\ {
560     \oneVoice
561     s1
562     e8 a b c d2
563   }
564 >>
565 @end lilypond
566
567 Notes with different note heads may be merged, with the
568 exception of half-note heads and quarter-note heads, as shown
569 below.  Here the note heads on beat 1 of bar 1 are now merged:
570
571 @lilypond[quote,verbatim,relative=2]
572 <<
573   {
574     \mergeDifferentlyHeadedOn
575     c8 d e d c d c4
576     g'2 fis
577   } \\ {
578     c2 c8. b16 c4
579     e,2 r
580   } \\ {
581     \oneVoice
582     s1
583     e8 a b c d2
584   }
585 >>
586 @end lilypond
587
588 Note heads with different dots as shown in beat 3 of bar 1 may be
589 also be merged:
590
591 @lilypond[quote,relative=2,verbatim]
592 <<
593   {
594     \mergeDifferentlyHeadedOn
595     \mergeDifferentlyDottedOn
596     c8 d e d c d c4
597     g'2 fis
598   } \\ {
599     c2 c8. b16 c4
600     e,2 r
601   } \\ {
602     \oneVoice
603     s1
604     e8 a b c d2
605   }
606 >>
607 @end lilypond
608
609
610 The half note and eighth note at the start of the second measure
611 are incorrectly merged because the automatic merge cannot
612 successfully complete the merge when three or more notes line up in
613 the same note column, and in this case the merged note head is
614 incorrect.  To allow the merge to select the correct note head
615 a @code{\shift} must be applied to the note that should not be
616 merged.  Here, @code{\shiftOn} is applied to move the top
617 @notation{g} out of the column, and @code{\mergeDifferentlyHeadedOn}
618 then works properly.
619
620 @lilypond[quote,relative=2,verbatim]
621 <<
622   {
623     \mergeDifferentlyHeadedOn
624     \mergeDifferentlyDottedOn
625     c8 d e d c d c4
626     \shiftOn
627     g'2 fis
628   } \\ {
629     c2 c8. b16 c4
630     e,2 r
631   } \\ {
632     \oneVoice
633     s1
634     e8 a b c d2
635   }
636 >>
637 @end lilypond
638
639 The @code{\shiftOn} command allows (but does not force) the notes
640 in a voice to be shifted.  When @code{\shiftOn} is applied to a
641 voice, a note or chord in that voice is shifted only if its stem
642 would otherwise collide with a stem from another voice, and only
643 if the colliding stems point in the same direction.  The
644 @code{\shiftOff} command prevents this type of shifting from
645 occuring.
646
647 By default, the outer voices (normally voices one and two) have
648 @code{\shiftOff} specified, while the inner voices (three and
649 above) have @code{\shiftOn} specified.  When a shift is applied,
650 voices with upstems (odd-numbered voices) are shifted to the
651 right, and voices with downstems (even-numbered voices) are
652 shifted to the left.
653
654 Here is an example to help you visualize how an abbreviated
655 polyphonic expression would be expanded internally.
656
657 @warning{Note that with three or more voices, the vertical order
658 of voices in your input file should not be the same as the
659 vertical order of voices on the staff!}
660
661 @lilypond[quote,verbatim]
662 \new Staff \relative c'' {
663   %% abbreviated entry
664   <<
665     { f2  }  % 1: highest
666     \\
667     { g,2 }  % 2: lowest
668     \\
669     { d'2 }  % 3: upper middle
670     \\
671     { b2  }  % 4: lower middle
672   >>
673   %% internal expansion of the above
674   <<
675     \new Voice = "1" { \voiceOne   \shiftOff f'2 }
676     \new Voice = "2" { \voiceTwo   \shiftOff g,2 }
677     \new Voice = "3" { \voiceThree \shiftOn  d'2 } % shifts right
678     \new Voice = "4" { \voiceFour  \shiftOn  b2  } % shifts left
679   >>
680 }
681 @end lilypond
682
683 Two additional commands, @code{\shiftOnn} and @code{\shiftOnnn}
684 provide further shift levels which may be specified temporarily to
685 resolve collisions in complex situations -- see
686 @rlearning{Real music example}.
687
688 Notes are only merged if they have opposing stem directions (as
689 they have, for example, in voices one and two by default or when
690 the stems are explicitly set in opposite directions).
691
692
693 @predefined
694 @code{\mergeDifferentlyDottedOn},
695 @code{\mergeDifferentlyDottedOff},
696 @code{\mergeDifferentlyHeadedOn},
697 @code{\mergeDifferentlyHeadedOff}.
698
699 @code{\shiftOn},
700 @code{\shiftOnn},
701 @code{\shiftOnnn},
702 @code{\shiftOff}.
703 @endpredefined
704
705
706 @snippets
707
708 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
709 {additional-voices-to-avoid-collisions.ly}
710
711 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
712 {forcing-horizontal-shift-of-notes.ly}
713
714
715 @seealso
716 Music Glossary:
717 @rglos{polyphony}.
718
719 Learning Manual:
720 @rlearning{Multiple notes at once},
721 @rlearning{Voices contain music},
722 @rlearning{Real music example}.
723
724 Snippets:
725 @rlsr{Simultaneous notes}.
726
727 Internals Reference:
728 @rinternals{NoteColumn},
729 @rinternals{NoteCollision},
730 @rinternals{RestCollision}.
731
732
733 @knownissues
734
735 @ignore
736 @c TODO investigate! Sometimes it works, sometimes not. --FV
737 The requirements for successfully merging different note heads that
738 are at the same time differently dotted are not clear.
739 @end ignore
740
741 There is no support for chords where the same note occurs with
742 different accidentals in the same chord.  In this case, it is
743 recommended to use enharmonic transcription, or to use special
744 cluster notation (see @ref{Clusters}).
745
746
747 @node Automatic part combining
748 @unnumberedsubsubsec Automatic part combining
749
750 @cindex automatic part combining
751 @cindex part combiner
752 @cindex combining parts
753 @cindex a due part
754 @cindex solo part
755 @funindex \partcombine
756 @funindex partcombine
757
758 Automatic part combining is used to merge two parts of music onto
759 a staff.  It is aimed at typesetting orchestral scores.  When the
760 two parts are identical for a period of time, only one is shown.
761 In places where the two parts differ, they are typeset as separate
762 voices, and stem directions are set automatically.  Also, solo and
763 @notation{a due} parts are identified and marked by default.
764
765 The syntax for part combining is:
766
767 @example
768 \partcombine @var{musicexpr1} @var{musicexpr2}
769 @end example
770
771 The following example demonstrates the basic functionality of the
772 part combiner: putting parts on one staff and setting stem
773 directions and polyphony.  The same variables are used for the
774 independent parts and the combined staff.
775
776 @lilypond[quote,verbatim]
777 instrumentOne = \relative c' {
778   c4 d e f
779   R1
780   d'4 c b a
781   b4 g2 f4
782   e1
783 }
784
785 instrumentTwo = \relative g' {
786   R1
787   g4 a b c
788   d c b a
789   g f( e) d
790   e1
791 }
792
793 <<
794   \new Staff \instrumentOne
795   \new Staff \instrumentTwo
796   \new Staff \partcombine \instrumentOne \instrumentTwo
797 >>
798 @end lilypond
799
800 The notes in the third measure appear only once, although they were
801 specified in both parts.  Stem, slur, and tie directions are set
802 automatically, depending whether there is a solo or unison.  When
803 needed in polyphony situations, the first part (with context called
804 @code{one}) always gets up stems, while the second (called @code{two})
805 always gets down stems.  In solo situations, the first and second
806 parts get marked with @q{Solo} and @q{Solo II}, respectively.  The
807 unisono (@notation{a due}) parts are marked by default with the text
808 @qq{a2}.
809
810 Both arguments to @code{\partcombine} will be interpreted as
811 @code{Voice} contexts.  If using relative octaves,
812 @code{\relative} should be specified for both music expressions,
813 i.e.,
814
815 @example
816 \partcombine
817   \relative @dots{} @var{musicexpr1}
818   \relative @dots{} @var{musicexpr2}
819 @end example
820
821 @noindent
822 A @code{\relative} section that is outside of @code{\partcombine}
823 has no effect on the pitches of @code{@var{musicexpr1}} and
824 @code{@var{musicexpr2}}.
825
826 @snippets
827
828 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
829 {combining-two-parts-on-the-same-staff.ly}
830
831 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
832 {changing-partcombine-texts.ly}
833
834
835 @seealso
836 Music Glossary:
837 @rglos{a due},
838 @rglos{part}.
839
840 Notation Reference:
841 @ref{Writing parts}.
842
843 Snippets:
844 @rlsr{Simultaneous notes}.
845
846 Internals Reference:
847 @rinternals{PartCombineMusic},
848 @rinternals{Voice}.
849
850
851 @knownissues
852
853 @code{\partcombine} can only accept two voices.
854
855 When @code{printPartCombineTexts} is set, if the two voices play
856 the same notes on and off, the part combiner may typeset @code{a2}
857 more than once in a measure.
858
859 @code{\partcombine} cannot be inside @code{\times}.
860
861 @code{\partcombine} cannot be inside @code{\relative}.
862
863 Internally, the @code{\partcombine} interprets both arguments as
864 @code{Voice}s and decides when the parts can be combined.  When they have
865 different durations they cannot be combined and are given the names
866 @code{one} and @code{two}.  Consequently, if the arguments switch to
867 differently named @rinternals{Voice} contexts, the events in those will
868 be ignored.  Likewise, partcombining isn't designed to work with lyrics;
869 when one of the voices is explicitly named in order to attach lyrics to
870 it, the partcombining stops working.
871
872 @code{\partcombine} only observes onset times of notes.  It cannot
873 determine whether a previously started note is playing or not, leading
874 to various problems.
875
876
877 @node Writing music in parallel
878 @unnumberedsubsubsec Writing music in parallel
879
880 @cindex writing music in parallel
881 @cindex interleaved music
882 @cindex parallel music
883 @funindex \parallelMusic
884 @funindex parallelMusic
885
886 Music for multiple parts can be interleaved in input code.  The
887 function @code{\parallelMusic} accepts a list with the names of a
888 number of variables to be created, and a musical expression.  The
889 content of alternate measures from the expression become the value
890 of the respective variables, so you can use them afterwards to
891 print the music.
892
893 @warning{Bar checks @code{|} must be used, and the measures must
894 be of the same length.}
895
896 @lilypond[quote,verbatim]
897 \parallelMusic #'(voiceA voiceB voiceC) {
898   % Bar 1
899   r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
900   r16 e'8.~   e'4            r16 e'8.~   e'4            |
901   c'2                        c'2                        |
902
903   % Bar 2
904   r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
905   r16 d'8.~   d'4            r16 d'8.~   d'4            |
906   c'2                        c'2                        |
907
908 }
909 \new StaffGroup <<
910   \new Staff << \voiceA \\ \voiceB >>
911   \new Staff { \clef bass \voiceC }
912 >>
913 @end lilypond
914
915 Relative mode may be used.  Note that the @code{\relative} command
916 is not used inside @code{\parallelMusic} itself.  The notes are
917 relative to the preceding note in the voice, not to the previous
918 note in the input -- in other words, relative notes for
919 @code{voiceA} ignore the notes in @code{voiceB}.
920
921 @lilypond[quote,verbatim]
922 \parallelMusic #'(voiceA voiceB voiceC) {
923   % Bar 1
924   r8 g16 c e g, c e r8 g,16 c e g, c e  |
925   r16 e8.~ e4       r16 e8.~  e4        |
926   c2                c                   |
927
928   % Bar 2
929   r8 a,16 d f a, d f r8 a,16 d f a, d f |
930   r16 d8.~  d4       r16 d8.~  d4       |
931   c2                 c                  |
932
933  }
934 \new StaffGroup <<
935   \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
936   \new Staff \relative c' { \clef bass \voiceC }
937 >>
938 @end lilypond
939
940 This works quite well for piano music.  This example maps four
941 consecutive measures to four variables:
942
943 @lilypond[quote,verbatim]
944 global = {
945   \key g \major
946   \time 2/4
947 }
948
949 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
950   % Bar 1
951   a8    b     c   d     |
952   d4          e         |
953   c16 d e fis d e fis g |
954   a4          a         |
955
956   % Bar 2
957   e8      fis  g     a   |
958   fis4         g         |
959   e16 fis g  a fis g a b |
960   a4           a         |
961
962   % Bar 3 ...
963 }
964
965 \score {
966   \new PianoStaff <<
967      \new Staff {
968        \global
969        <<
970          \relative c'' \voiceA
971          \\
972          \relative c'  \voiceB
973        >>
974      }
975      \new Staff {
976        \global \clef bass
977        <<
978          \relative c \voiceC
979          \\
980          \relative c \voiceD
981        >>
982      }
983   >>
984 }
985 @end lilypond
986
987
988 @seealso
989 Learning Manual:
990 @rlearning{Organizing pieces with variables}.
991
992 Snippets:
993 @rlsr{Simultaneous notes}.