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