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