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