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