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