]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/simultaneous.itely
Merge branch 'lilypond/translation' of ssh://trettig@git.sv.gnu.org/srv/git/lilypond...
[lilypond.git] / Documentation / user / 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.11.51"
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 * Clusters::
35 @end menu
36
37
38 @node Chorded notes
39 @unnumberedsubsubsec Chorded notes
40
41 @cindex chords
42 @cindex brackets, angle
43 @funindex <
44 @funindex >
45 @funindex <...>
46
47 A chord is formed by a enclosing a set of pitches between @code{<} and
48 @code{>}.  A chord may be followed by a duration and/or a set of
49 articulations, just like simple notes:
50
51 @lilypond[verbatim,quote,relative=1]
52 <c e g>2 <c f a>4-> <e g c>-.
53 @end lilypond
54
55 For more information about chords, see @ref{Chord notation}.
56
57 @seealso
58
59 Music Glossary:
60 @rglos{chord}.
61
62 Learning Manual:
63 @rlearning{Combining notes into chords}.
64
65 Notation Reference:
66 @ref{Chord notation}.
67
68 Snippets:
69 @rlsr{Simultaneous notes}.
70
71 @ignore
72 @knownissues
73
74 For some reason, music expressions like @code{<< @{ g8 e8 @} a4 >>}
75 that should automatically turn into chords, appear split in two
76 staves.  To avoid this, use explicit chords instead as in
77 @code{<g a>8 <e a>8}.
78 @end ignore
79
80
81 @node Clusters
82 @unnumberedsubsubsec Clusters
83
84 @cindex cluster
85 @funindex \makeClusters
86
87 A cluster indicates a continuous range of pitches to be played.  They
88 can be denoted as the envelope of a set of notes.  They are entered by
89 applying the function @code{\makeClusters} to a sequence of chords,
90 e.g.,
91
92 @lilypond[quote,relative=2,verbatim]
93 \makeClusters { <g b>2 <c g'> }
94 @end lilypond
95
96 Ordinary notes and clusters can be put together in the same staff,
97 even simultaneously.  In such a case no attempt is made to
98 automatically avoid collisions between ordinary notes and clusters.
99
100 @seealso
101
102 Music Glossary:
103 @rglos{cluster}.
104
105 Snippets:
106 @rlsr{Simultaneous notes}.
107
108 Internals Reference:
109 @rinternals{ClusterSpanner},
110 @rinternals{ClusterSpannerBeacon},
111 @rinternals{Cluster_spanner_engraver}.
112
113 @knownissues
114
115 Clusters look good only if they span at least two chords; otherwise
116 they appear too narrow.
117
118 Clusters do not have a stem and cannot indicate durations by
119 themselves.  Separate clusters would need a separating rest between
120 them.
121
122
123 @node Multiple voices
124 @subsection Multiple voices
125
126 This section discusses simultaneous notes in multiple voices or
127 multiple staves.
128
129 @menu
130 * Single-staff polyphony::
131 * Voice styles::
132 * Collision resolution::
133 * Automatic part combining::
134 * Writing music in parallel::
135 @end menu
136
137
138 @node Single-staff polyphony
139 @unnumberedsubsubsec Single-staff polyphony
140
141 To typeset parallel pieces of music that have the same rhythm, they
142 can be combined into a single @code{Voice} context, thus forming
143 chords.  To achieve this, enclose them in a simultaneous music
144 construction:
145
146 @lilypond[quote,relative=2,verbatim]
147 \new Voice <<
148   { e4 f8 d e16 f g8 d4 }
149   { c4 d8 b c16 d e8 b4 }
150 >>
151 @end lilypond
152
153 This method leads to strange beamings and warnings if the pieces of
154 music do not have the same rhythm.  To typeset multiple, truly
155 independent voices in a single staff, the @code{<<@{...@} \\
156 @{...@}>>} construction can be used as a simplified method, where the
157 two (or more) voices are separated by double backslashes.
158
159 @lilypond[quote,relative=3,verbatim]
160 <<
161   { r8 r16 g e8. f16 g8[ c,] f e16 d }
162   \\
163   { d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
164 >>
165 @end lilypond
166
167 First and third voices get stems up, second and fourth voices get
168 stems down, third and fourth voice note heads are horizontally shifted,
169 and rests move to avoid collisions.  In the following example, the
170 intermediate voice has stems up, therefore we enter it in the third
171 place, so it becomes voice three which has the stems up as desired.
172
173 @lilypond[quote,relative=3,verbatim]
174 <<
175   { r8 g g  g g f16 es f8 d }
176   \\
177   { es,8 r es r d r d r }
178   \\
179   { d'8 s c s bes s a s }
180 >>
181 @end lilypond
182
183 Spacing rests are often used to avoid too many rests, as seen in the
184 example above.
185
186 Voices created by this simplified method are implicit @code{Voice}
187 contexts; in all but simplest works it is advised to create explicit
188 @code{Voice} contexts using the @code{\new} and @code{\context}
189 commands as it is explained in @rlearning{Contexts and engravers} and
190 @rlearning{Explicitly instantiating voices}.
191
192 This applies to a common case: each music expression in the
193 @code{<<@{...@} \\ @{...@}>>} construct is placed in a new voice,
194 distinct from the voice for single-voice music; to temporarily add
195 only one additional voice to an existing one, it is necessary to
196 instantiate that voice explicitly.  When doing this, to force the
197 settings that would be implicitly made by the simplified method, the
198 @code{\voiceOne} ... @code{\voiceFour}, and @code{\oneVoice} commands
199 can be used:
200
201 @example
202 << @{ \voiceOne ... @} \new Voice @{ \voiceTwo ... @} >> \oneVoice
203 @end example
204
205 This construct keeps a voice alive throughout the polyphonic section.
206 For example, this allows lyrics to be assigned to one consistent voice.
207
208 @lilypond[quote, verbatim, relative=2]
209 <<
210   \new Voice = "melody" {
211     a4
212     <<
213       {
214         \voiceOne
215         g f
216       }
217       \new Voice {
218         \voiceTwo
219         e d
220       }
221     >>
222     \oneVoice
223     e
224   }
225   \new Lyrics \lyricsto "melody" {
226   This is my song.
227   }
228 >>
229 @end lilypond
230
231 @predefined
232
233 @funindex \voiceOne
234 @code{\voiceOne},
235 @funindex \voiceTwo
236 @code{\voiceTwo},
237 @funindex \voiceThree
238 @code{\voiceThree},
239 @funindex \voiceFour
240 @code{\voiceFour},
241 @funindex \oneVoice
242 @code{\oneVoice}.
243
244 @seealso
245
246 Learning Manual:
247 @rlearning{Voices contain music},
248 @rlearning{Explicitly instantiating voices}.
249
250 Notation Reference:
251 @ref{Percussion staves}.
252
253 Snippets:
254 @rlsr{Simultaneous notes}.
255
256
257 @node Voice styles
258 @unnumberedsubsubsec Voice styles
259
260 @cindex voice styles
261 @cindex styles, voice
262 @cindex coloring voices
263
264 Voices may be given distinct colors and shapes, allowing them to be
265 easily identified:
266
267 @lilypond[quote,relative=2,verbatim]
268 <<
269   { \voiceOneStyle d4 c2 b4 }
270   \\
271   { \voiceTwoStyle e,2 e }
272   \\
273   { \voiceThreeStyle b2. c4 }
274   \\
275   { \voiceFourStyle g'2 g }
276 >>
277 @end lilypond
278
279 To revert the standard presentation, the @code{\voiceNeutralstyle}
280 command is used.
281
282 @predefined
283
284 @funindex \voiceOneStyle
285 @code{\voiceOneStyle},
286 @funindex \voiceTwoStyle
287 @code{\voiceTwoStyle},
288 @funindex \voiceThreeStyle
289 @code{\voiceThreeStyle},
290 @funindex \voiceFourStyle
291 @code{\voiceFourStyle},
292 @funindex \voiceNeutralStyle
293 @code{\voiceNeutralStyle}.
294
295 @seealso
296
297 Learning Manual:
298 @rlearning{I'm hearing Voices},
299 @rlearning{Other sources of information}.
300
301 Snippets:
302 @rlsr{Simultaneous notes}.
303
304
305 @node Collision resolution
306 @unnumberedsubsubsec Collision resolution
307
308 @cindex merging notes
309 @cindex note collisions
310 @cindex collisions
311 @funindex \shiftOn
312 @funindex \shiftOnn
313 @funindex \shiftOnnn
314 @funindex \shiftOff
315 @cindex shift rest, automatic
316
317 Note heads with equal durations are automatically merged, while
318 note heads with unequal durations are not merged.  Rests opposite
319 a stem are shifted vertically.
320
321 @lilypond[quote,verbatim,relative=2]
322 <<
323   {
324     c8 d e d c d c4
325     g'2 fis
326   } \\ {
327     c2 c8. b16 c4
328     e,2 r
329   } \\ {
330     \oneVoice
331     s1
332     e8 a b c d2
333   }
334 >>
335 @end lilypond
336
337 Note heads with different note heads may be merged, with the
338 exception of half-note heads and quarter-note heads:
339
340 @lilypond[quote,verbatim,relative=2]
341 <<
342   {
343     \mergeDifferentlyHeadedOn
344     c8 d e d c d c4
345     g'2 fis
346   } \\ {
347     c2 c8. b16 c4
348     e,2 r
349   } \\ {
350     \oneVoice
351     s1
352     e8 a b c d2
353   }
354 >>
355 @end lilypond
356
357 Note heads with different dots may be merged:
358
359 @lilypond[quote,relative=2,verbatim]
360 <<
361   {
362     \mergeDifferentlyHeadedOn
363     \mergeDifferentlyDottedOn
364     c8 d e d c d c4
365     g'2 fis
366   } \\ {
367     c2 c8. b16 c4
368     e,2 r
369   } \\ {
370     \oneVoice
371     s1
372     e8 a b c d2
373   }
374 >>
375 @end lilypond
376
377 @cindex shift note
378
379 The collision on the second measure happens because
380 @code{merge-differently-headed} cannot successfully complete the
381 merge when three or more notes line up in the same column -- in
382 fact, you will obtain a warning for this reason.  To allow the
383 merge to work properly, apply a @code{\shift} to the note that
384 should not be merged.  Here, @code{\shiftOn} is applied to move
385 the top @code{g} out of the column, and
386 @code{merge-differently-headed} works properly.
387
388 @lilypond[quote,relative=2,verbatim]
389 <<
390   {
391     \mergeDifferentlyHeadedOn
392     \mergeDifferentlyDottedOn
393     c8 d e d c d c4
394     \shiftOn
395     g'2 fis
396   } \\ {
397     c2 c8. b16 c4
398     e,2 r
399   } \\ {
400     \oneVoice
401     s1
402     e8 a b c d2
403   }
404
405 >>
406 @end lilypond
407
408 The @code{\shiftOn}, @code{\shiftOnn}, and @code{\shiftOnnn}
409 commands specify the degree to which chords of the current voice
410 should be shifted.  The outer voices (normally: voices one and
411 two) have @code{\shiftOff}, while the inner voices (three and
412 four) have @code{\shiftOn}.  @code{\shiftOnn} and
413 @code{\shiftOnnn} define further shift levels.
414
415 Notes are only merged if they have opposing stem directions (i.e., in
416 @code{Voice} 1 and 2).
417
418 @cindex multiple voices
419 @cindex polyphonic music
420 @cindex shifting voices
421
422 @predefined
423
424 @funindex \mergeDifferentlyDottedOn
425 @code{\mergeDifferentlyDottedOn},
426 @funindex \mergeDifferentlyDottedOff
427 @code{\mergeDifferentlyDottedOff},
428 @funindex \mergeDifferentlyHeadedOn
429 @code{\mergeDifferentlyHeadedOn},
430 @funindex \mergeDifferentlyHeadedOff
431 @code{\mergeDifferentlyHeadedOff}.
432
433 @funindex \shiftOn
434 @code{\shiftOn},
435 @funindex \shiftOnn
436 @code{\shiftOnn},
437 @funindex \shiftOnnn
438 @code{\shiftOnnn},
439 @funindex \shiftOff
440 @code{\shiftOff}.
441
442 @snippets
443
444 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
445 {additional-voices-to-avoid-collisions.ly}
446
447 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
448 {forcing-horizontal-shift-of-notes.ly}
449
450 @seealso
451
452 Music Glossary:
453 @rglos{polyphony}.
454
455 Learning Manual:
456 @rlearning{Multiple notes at once},
457 @rlearning{Voices contain music},
458 @rlearning{Collisions of objects}.
459
460 Snippets:
461 @rlsr{Simultaneous notes}.
462
463 Internals Reference:
464 @rinternals{NoteColumn},
465 @rinternals{NoteCollision},
466 @rinternals{RestCollision}.
467
468 @knownissues
469
470 When using @code{merge-differently-headed} with an upstem eighth
471 or a shorter note, and a downstem half note, the eighth note stem
472 gets a slightly wrong offset because of the different width of the
473 half note head symbol.
474
475 @c investigate! Sometimes it works, sometimes not. --FV
476 The requirements for successfully merging different note heads that
477 are at the same time differently dotted are not clear.
478
479 There is no support for chords where the same note occurs with
480 different accidentals in the same chord.  In this case, it is
481 recommended to use enharmonic transcription, or to use special
482 cluster notation (see @ref{Clusters}).
483
484
485 @node Automatic part combining
486 @unnumberedsubsubsec Automatic part combining
487
488 @cindex automatic part combining
489 @cindex part combiner
490 @cindex combining parts
491 @funindex \partcombine
492
493 Automatic part combining is used to merge two parts of music onto
494 a staff.  It is aimed at typesetting orchestral scores.  When the
495 two parts are identical for a period of time, only one is shown.
496 In places where the two parts differ, they are typeset as separate
497 voices, and stem directions are set automatically.  Also, solo and
498 @notation{a due} parts are identified and marked by default.
499
500 The syntax for part combining is:
501
502 @example
503 \partcombine @var{musicexpr1} @var{musicexpr2}
504 @end example
505
506 The following example demonstrates the basic functionality of the
507 part combiner: putting parts on one staff and setting stem
508 directions and polyphony.  The same variables are used for the
509 independent parts and the combined staff.
510
511 @lilypond[quote,verbatim]
512 instrumentOne = \relative c' {
513   c4 d e f
514   R1
515   d'4 c b a
516   b4 g2 f4
517   e1
518 }
519
520 instrumentTwo = \relative g' {
521   R1
522   g4 a b c
523   d c b a
524   g f( e) d
525   e1
526 }
527
528 <<
529   \new Staff \instrumentOne
530   \new Staff \instrumentTwo
531   \new Staff \partcombine \instrumentOne \instrumentTwo
532 >>
533 @end lilypond
534
535 The notes in the third measure appear only once, although they
536 were specified in both parts.  Stem, slur, and tie directions are
537 set automatically, depending whether there is a solo or unison.
538 When needed in polyphony situations, the first part (with context
539 called @code{one}) always gets up stems, while the second (called
540 @code{two}) always gets down stems.  In solo situations, the parts
541 get marked with @q{Solo} and @q{Solo II}, respectively.  The
542 unisono (@notation{a due}) parts are marked by default with the
543 text @qq{a2}.
544
545 Both arguments to @code{\partcombine} will be interpreted as
546 @code{Voice} contexts.  If using relative octaves,
547 @code{\relative} should be specified for both music expressions,
548 i.e.,
549
550 @example
551 \partcombine
552   \relative @dots{} @var{musicexpr1}
553   \relative @dots{} @var{musicexpr2}
554 @end example
555
556 @noindent
557 A @code{\relative} section that is outside of @code{\partcombine}
558 has no effect on the pitches of @var{musicexpr1} and
559 @var{musicexpr2}.
560
561 @snippets
562
563 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
564 {combining-two-parts-on-the-same-staff.ly}
565
566 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
567 {changing-partcombine-texts.ly}
568
569 @seealso
570
571 Music Glossary:
572 @rglos{a due},
573 @rglos{part}.
574
575 Notation Reference:
576 @ref{Writing parts}.
577
578 Snippets:
579 @rlsr{Simultaneous notes}.
580
581 Internals Reference:
582 @rinternals{PartCombineMusic},
583 @rinternals{Voice}.
584
585 @knownissues
586
587 When @code{printPartCombineTexts} is set, if the two voices play
588 the same notes on and off, the part combiner may typeset @code{a2}
589 more than once in a measure.
590
591 @code{\partcombine} cannot be inside @code{\times}.
592
593 @code{\partcombine} cannot be inside @code{\relative}.
594
595 Internally, the @code{\partcombine} interprets both arguments as
596 @code{Voice}s named @code{one} and @code{two}, and then decides
597 when the parts can be combined.  Consequently, if the arguments
598 switch to differently named @rinternals{Voice} contexts, the
599 events in those will be ignored.
600
601 @c IIRC in users list someone pointed out more issues. TODO: lookup FV
602
603
604 @node Writing music in parallel
605 @unnumberedsubsubsec Writing music in parallel
606
607 @cindex Writing music in parallel
608 @cindex Interleaved music
609 @funindex parallelMusic
610
611 Music for multiple parts can be interleaved in input code.  The
612 function @code{\parallelMusic} accepts a list with the names of a
613 number of variables to be created, and a musical expression.  The
614 content of alternate measures from the expression become the value
615 of the respective variables, so you can use them afterwards to
616 print the music.
617
618 @warning{Bar checks @code{|} must be used, and the measures must
619 be of the same length.}
620
621 @lilypond[quote,verbatim]
622 \parallelMusic #'(voiceA voiceB voiceC) {
623   % Bar 1
624   r8 g'16 c'' e'' g' c'' e'' r8 g'16 c'' e'' g' c'' e'' |
625   r16 e'8.~   e'4            r16 e'8.~   e'4            |
626   c'2                        c'2                        |
627
628   % Bar 2
629   r8 a'16 d'' f'' a' d'' f'' r8 a'16 d'' f'' a' d'' f'' |
630   r16 d'8.~   d'4            r16 d'8.~   d'4            |
631   c'2                        c'2                        |
632
633 }
634 \new StaffGroup <<
635   \new Staff << \voiceA \\ \voiceB >>
636   \new Staff { \clef bass \voiceC }
637 >>
638 @end lilypond
639
640 Relative mode may be used.  Note that the @code{\relative} command
641 is not used inside @code{\parallelMusic} itself.  The notes are
642 relative to the preceding note in the voice, not to the previous
643 note in the input -- in other words, relative notes for
644 @code{voiceA} ignore the notes in @code{voiceB}.
645
646 @lilypond[quote,verbatim]
647 \parallelMusic #'(voiceA voiceB voiceC) {
648   % Bar 1
649   r8 g16 c e g, c e r8 g,16 c e g, c e  |
650   r16 e8.~ e4       r16 e8.~  e4        |
651   c2                c                   |
652
653   % Bar 2
654   r8 a,16 d f a, d f r8 a,16 d f a, d f |
655   r16 d8.~  d4       r16 d8.~  d4       |
656   c2                 c                  |
657
658  }
659 \new StaffGroup <<
660   \new Staff << \relative c'' \voiceA \\ \relative c' \voiceB >>
661   \new Staff \relative c' { \clef bass \voiceC }
662 >>
663 @end lilypond
664
665 This works quite well for piano music.  This example maps four
666 consecutive measures to four variables:
667
668 @lilypond[quote,verbatim]
669 global = {
670   \key g \major
671   \time 2/4
672 }
673
674 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
675   % Bar 1
676   a8    b     c   d     |
677   d4          e         |
678   c16 d e fis d e fis g |
679   a4          a         |
680
681   % Bar 2
682   e8      fis  g     a   |
683   fis4         g         |
684   e16 fis g  a fis g a b |
685   a4           a         |
686
687   % Bar 3 ...
688 }
689
690 \score {
691   \new PianoStaff <<
692      \new Staff {
693        \global
694        <<
695          \relative c'' \voiceA
696          \\
697          \relative c'  \voiceB
698        >>
699      }
700      \new Staff {
701        \global \clef bass
702        <<
703          \relative c \voiceC
704          \\
705          \relative c \voiceD
706        >>
707      }
708   >>
709 }
710 @end lilypond
711
712 @seealso
713
714 Learning Manual:
715 @rlearning{Organizing pieces with variables}.
716
717 Snippets:
718 @rlsr{Simultaneous notes}.