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