]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/simultaneous.itely
Move translated docs into Pitches and Rhythms
[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 @node Simultaneous notes
10 @section Simultaneous notes
11
12 Polyphony in music refers to having more than one voice occurring in
13 a piece of music.  Polyphony in LilyPond refers to having more than
14 one voice on the same staff.
15
16 @menu
17 * Single voice::                
18 * Multiple voices::             
19 @end menu
20
21
22 @node Single voice
23 @subsection Single voice
24
25 @menu
26 * Chords::                      
27 * Clusters::                    
28 @end menu
29
30 @node Chords
31 @unnumberedsubsubsec Chords
32
33 @cindex Chords
34
35 A chord is formed by a enclosing a set of pitches between @code{<}
36 and @code{>}.  A chord may be followed by a duration, and a set of
37 articulations, just like simple notes
38
39 @lilypond[verbatim,ragged-right,fragment,quote,relative=1]
40 <c e g>4 <c>8
41 @end lilypond
42
43 For more information about chords, see @ref{Introducing chord names}.
44
45
46 @node Clusters
47 @unnumberedsubsubsec Clusters
48
49 @cindex cluster
50
51 A cluster indicates a continuous range of pitches to be played.  They
52 can be denoted as the envelope of a set of notes.  They are entered by
53 applying the function @code{makeClusters} to a sequence of
54 chords, e.g.,
55 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
56 \makeClusters { <c e > <b f'> }
57 @end lilypond
58
59 Ordinary notes and clusters can be put together in the same staff,
60 even simultaneously.  In such a case no attempt is made to
61 automatically avoid collisions between ordinary notes and clusters.
62
63 @seealso
64
65 Program reference: @internalsref{ClusterSpanner},
66 @internalsref{ClusterSpannerBeacon},
67 @internalsref{Cluster_spanner_engraver}.
68
69 Examples: @lsr{contemporary,cluster@/.ly}.
70
71 @refbugs
72
73 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
74 accurately.  Use @code{<g a>8 <e a>8} instead.
75
76
77
78 @node Multiple voices
79 @subsection Multiple voices
80
81 @menu
82 * Basic polyphony::             
83 * Explicitly instantiating voices::  
84 * Collision Resolution::        
85 * Automatic part combining::    
86 * Writing music in parallel::   
87 @end menu
88
89 @node Basic polyphony
90 @unnumberedsubsubsec Basic polyphony
91
92 @cindex polyphony
93
94 The easiest way to enter fragments with more than one voice on a staff
95 is to enter each voice as a sequence (with @code{@{...@}}), and combine
96 them simultaneously, separating the voices with @code{\\}
97
98 @funindex \\
99
100 @lilypond[quote,verbatim,fragment]
101 \new Staff \relative c' {
102   c16 d e f
103   <<
104     { g4 f e | d2 e2 } \\
105     { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
106     { s2. | s4 b4 c2 }
107   >>
108 }
109 @end lilypond
110
111 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
112 voices are sometimes called @q{layers} in other notation packages}
113 @cindex layers
114 to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
115 each of these contexts, vertical direction of slurs, stems, etc., is set
116 appropriately.
117
118 These voices are all separate from the voice that contains the notes just
119 outside the @code{<< \\ >>} construct.  This should be noted when making
120 changes at the voice level.  This also means that slurs and ties cannot go
121 into or out of a @code{<< \\ >>} construct.  Conversely, parallel voices
122 from separate @code{<< \\ >>} constructs on the same staff are the
123 same voice.  Here is the same example, with different noteheads and
124 colors for each
125 voice.  Note that the change to the note-head style in the main voice does
126 not affect
127 the inside of the @code{<< \\ >>} constructs.  Also, the change to the
128 second
129 voice in the first @code{<< \\ >>} construct is effective in the second
130 @code{<< \\ >>}, and the voice is tied across the two constructs.
131
132 @cindex note heads, styles
133
134 @lilypond[quote,verbatim,fragment]
135 \new Staff \relative c' {
136   \override NoteHead #'style = #'cross
137   \override NoteHead #'color = #red
138   c16 d e f
139   <<
140     { g4 f e } \\
141     { \override NoteHead #'style = #'triangle
142       \override NoteHead #'color = #blue
143     r8 e4 d c8 ~ }
144   >> |
145   <<
146     { d2 e2 } \\
147     { c8 b16 a b8 g ~ g2 } \\
148     { \override NoteHead #'style = #'slash 
149       \override NoteHead #'color = #green
150       s4 b4 c2 }
151   >>
152 }
153 @end lilypond
154
155 Polyphony does not change the relationship of notes within a
156 @code{\relative @{ @}} block.  Each note is calculated relative
157 to the note immediately preceding it.
158
159 @example
160 \relative @{ noteA << noteB \\ noteC >> noteD @}
161 @end example
162
163 @code{noteC} is relative to @code{noteB}, not @code{noteA};
164 @code{noteD} is relative to @code{noteC}, not @code{noteB} or
165 @code{noteA}.
166
167
168 @node Explicitly instantiating voices
169 @unnumberedsubsubsec Explicitly instantiating voices
170
171 @internalsref{Voice} contexts can also be instantiated manually
172 inside a @code{<< >>} block to create polyphonic music, using
173 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions
174 and a horizontal shift for each part.
175
176 Specifically,
177 @example
178 << \upper \\ \lower >>
179 @end example
180
181 @noindent
182 is equivalent to
183
184 @example
185 <<
186   \new Voice = "1" @{ \voiceOne \upper @}
187   \new Voice = "2" @{ \voiceTwo \lower @}
188 >>
189 @end example
190
191 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
192 articulations, text annotations, augmentation dots of dotted
193 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
194 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
195 make them point downwards.
196 The command @code{\oneVoice} will revert back to the normal setting.
197
198 An expression that appears directly inside a @code{<< >>} belongs to
199 the main voice.  This is useful when extra voices appear while the main
200 voice is playing.  Here is a more correct rendition of the example from
201 the previous section.  The crossed colored noteheads demonstrate that the main
202 melody is now in a single voice context.
203
204 @lilypond[quote,ragged-right,verbatim]
205 \new Staff \relative c' {
206   \override NoteHead #'style = #'cross
207   \override NoteHead #'color = #red
208   c16 d e f
209   \voiceOne
210   <<
211     { g4 f e | d2 e2 }
212     \new Voice="1" { \voiceTwo
213       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
214       \oneVoice
215     }
216     \new Voice { \voiceThree
217       s2. | s4 b4 c2
218       \oneVoice
219     }
220   >>
221   \oneVoice
222 }
223 @end lilypond
224
225 The correct definition of the voices allows the melody to be slurred.
226 @lilypond[quote,ragged-right,verbatim]
227 \new Staff \relative c' {
228   c16^( d e f
229   \voiceOne
230   <<
231     { g4 f e | d2 e2) }
232     \context Voice="1" { \voiceTwo
233       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
234       \oneVoice
235     }
236     \new Voice { \voiceThree
237       s2. s4 b4 c2
238       \oneVoice
239     }
240   >>
241   \oneVoice
242 }
243 @end lilypond
244
245 Avoiding the @code{\\} separator also allows nesting polyphony
246 constructs, which in some case might be a more natural way to typeset
247 the music.
248
249 @lilypond[quote,ragged-right,verbatim]
250 \new Staff \relative c' {
251   c16^( d e f
252   \voiceOne
253   <<
254     { g4 f e | d2 e2) }
255     \context Voice="1" { \voiceTwo
256       r8 e4 d c8 ~ |
257       <<
258         {c8 b16 a b8 g ~ g2}
259         \new Voice { \voiceThree
260           s4 b4 c2
261           \oneVoice
262         }
263       >>
264     \oneVoice
265     }
266   >>
267   \oneVoice
268 }
269 @end lilypond
270
271 In some instances of complex polyphonic music, you may need additional
272 voices to avoid collisions between notes.  Additional voices are added
273 by defining an identifier, as shown below:
274
275 @lilypond[quote,verbatim,ragged-right,relative=2]
276 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
277
278 \relative c''' <<
279   { \voiceOne g4 ~  \stemDown g32[ f( es d c b a b64 )g] } \\
280   { \voiceThree  b4} \\
281   { \voiceFive d,} \\
282   { \voiceTwo g,}
283 >>
284 @end lilypond
285
286
287 @node Collision Resolution
288 @unnumberedsubsubsec Collision Resolution
289
290 Normally, note heads with a different number of dots are not merged, but
291 when the object property @code{merge-differently-dotted} is set in
292 the @internalsref{NoteCollision} object, they are merged:
293
294 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
295 \new Voice << {
296   g8 g8
297   \override Staff.NoteCollision
298     #'merge-differently-dotted = ##t
299   g8 g8
300 } \\ { g8.[ f16] g8.[ f16] } >>
301 @end lilypond
302
303 Similarly, you can merge half note heads with eighth notes, by setting
304 @code{merge-differently-headed}:
305
306 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
307 \new Voice << {
308   c8 c4.
309   \override Staff.NoteCollision
310     #'merge-differently-headed = ##t
311 c8 c4. } \\ { c2 c2 } >>
312 @end lilypond
313
314 @noindent
315 @code{merge-differently-headed} and @code{merge-differently-dotted}
316 only apply to opposing stem directions (ie. Voice 1 & 2).
317
318 LilyPond also vertically shifts rests that are opposite of a stem,
319 for example
320
321 @lilypond[quote,ragged-right,fragment,verbatim]
322 \new Voice << c''4 \\ r4 >>
323 @end lilypond
324
325 If three or more notes line up in the same column,
326 @code{merge-differently-headed} cannot
327 successfully complete the merge of the two notes that should be merged.
328 To allow the merge to work properly, apply a @code{\shift} to the note that
329 should not be merged.  In the first measure of following example,
330 @code{merge-differently-headed} does not work (the half-note head is
331 solid).  In the second measure, @code{\shiftOn} is applied to move the
332 top @code{g} out of the column, and @code{merge-differently-headed}
333 works properly.
334
335 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
336 \override Staff.NoteCollision #'merge-differently-headed = ##t
337 <<
338   { d=''2 g2 } \\
339   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
340   { \voiceFour e,,2 e'2}
341 >>
342 <<
343   { d'=''2 \shiftOn g2 } \\ 
344   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
345   { \voiceFour e,,2 e'2}
346 >>
347 @end lilypond
348
349
350 @refcommands
351
352 @funindex \oneVoice
353 @code{\oneVoice},
354 @funindex \voiceOne
355 @code{\voiceOne},
356 @funindex \voiceTwo
357 @code{\voiceTwo},
358 @funindex \voiceThree
359 @code{\voiceThree},
360 @funindex \voiceFour
361 @code{\voiceFour}.
362
363 @funindex \shiftOn
364 @code{\shiftOn},
365 @funindex \shiftOnn
366 @code{\shiftOnn},
367 @funindex \shiftOnnn
368 @code{\shiftOnnn},
369 @funindex \shiftOff
370 @code{\shiftOff}: these commands specify the
371 degree to which chords of the current voice should be shifted.
372 The outer voices (normally: voice one and
373 two) have @code{\shiftOff}, while the inner voices (three and four)
374 have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
375 further shift levels.
376
377 When LilyPond cannot cope, the @code{force-hshift}
378 property of the @internalsref{NoteColumn} object and pitched rests can
379 be used to override typesetting decisions.
380
381 @lilypond[quote,verbatim,ragged-right]
382 \relative <<
383 {
384   <d g>
385   <d g>
386 } \\ {
387   <b f'>
388   \once \override NoteColumn #'force-hshift = #1.7
389   <b f'>
390 } >>
391 @end lilypond
392
393
394 @seealso
395
396 Program reference: the objects responsible for resolving collisions are
397 @internalsref{NoteCollision} and @internalsref{RestCollision}.
398
399
400 @refbugs
401
402 When using @code{merge-differently-headed} with an upstem eighth or a
403 shorter note, and a downstem half note, the eighth note gets the wrong
404 offset.
405
406 There is no support for clusters where the same note occurs with
407 different accidentals in the same chord.  In this case, it is
408 recommended to use enharmonic transcription, or to use special cluster
409 notation (see @ref{Clusters}).
410
411
412 @node Automatic part combining
413 @unnumberedsubsubsec Automatic part combining
414 @cindex automatic part combining
415 @cindex part combiner
416
417 Automatic part combining is used to merge two parts of music onto a
418 staff.  It is aimed at typesetting orchestral scores.  When the two
419 parts are identical for a period of time, only one is shown.  In
420 places where the two parts differ, they are typeset as separate
421 voices, and stem directions are set automatically.  Also, solo and
422 @emph{a due} parts are identified and can be marked.
423
424 The syntax for part combining is
425
426 @example
427 \partcombine @var{musicexpr1} @var{musicexpr2}
428 @end example
429
430
431 The following example demonstrates the basic functionality of the part
432 combiner: putting parts on one staff, and setting stem directions and
433 polyphony
434
435 @lilypond[quote,verbatim,ragged-right,fragment]
436 \new Staff \partcombine
437   \relative g' { g g a( b) c c r r }
438   \relative g' { g g r4 r e e g g }
439 @end lilypond
440
441 The first @code{g} appears only once, although it was
442 specified twice (once in each part).  Stem, slur, and tie directions are
443 set automatically, depending whether there is a solo or unisono.  The
444 first part (with context called @code{one}) always gets up stems, and
445 @q{Solo}, while the second (called @code{two}) always gets down stems and
446 @q{Solo II}.
447
448 If you just want the merging parts, and not the textual markings, you
449 may set the property @code{printPartCombineTexts} to false
450
451 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
452 \new Staff <<
453   \set Staff.printPartCombineTexts = ##f
454   \partcombine
455     \relative g' { g a( b) r }
456     \relative g' { g r4 r f }
457 >>
458 @end lilypond
459
460 To change the text that is printed for solos or merging, you may
461 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
462 properties.
463
464 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
465 \new Staff <<
466   \set Score.soloText = #"ichi"
467   \set Score.soloIIText = #"ni"
468   \set Score.aDueText = #"tachi"
469   \partcombine
470     \relative g' { g4 g a( b) r }
471     \relative g' { g4 g r r f }
472 >>
473 @end lilypond
474
475 Both arguments to @code{\partcombine} will be interpreted as
476 @internalsref{Voice} contexts.  If using relative octaves,
477 @code{\relative} should be specified for both music expressions, i.e.,
478
479 @example
480 \partcombine
481   \relative @dots{} @var{musicexpr1}
482   \relative @dots{} @var{musicexpr2}
483 @end example
484
485 @noindent
486 A @code{\relative} section that is outside of @code{\partcombine} has
487 no effect on the pitches of @var{musicexpr1} and @var{musicexpr2}.
488
489 @seealso
490
491 Program reference: @internalsref{PartCombineMusic}.
492
493 @refbugs
494
495 When @code{printPartCombineTexts} is set, when the two voices play the
496 same notes on and off, the part combiner may typeset @code{a2} more
497 than once in a measure.
498
499 @code{\partcombine} cannot be inside @code{\times}.
500
501 @code{\partcombine} cannot be inside @code{\relative}.
502
503 Internally, the @code{\partcombine} interprets both arguments as
504 @code{Voice}s named @code{one} and @code{two}, and then decides when
505 the parts can be combined.  Consequently, if the arguments switch to
506 differently named @internalsref{Voice} contexts, the events in those
507 will be ignored.
508
509
510 @node Writing music in parallel
511 @unnumberedsubsubsec Writing music in parallel
512
513 @cindex Writing music in parallel
514 @cindex Interleaved music
515
516 Music for multiple parts can be interleaved
517
518 @lilypond[quote,fragment,verbatim]
519 \parallelMusic #'(voiceA voiceB) {
520   r8     g'16[ c''] e''[ g' c'' e''] r8     g'16[ c''] e''[ g' c'' e''] |
521   c'2                                c'2                                |
522   r8     a'16[ d''] f''[ a' d'' f''] r8     a'16[ d''] f''[ a' d'' f''] |
523   c'2                                c'2                                |
524 }
525 \new StaffGroup <<
526   \new Staff \new Voice \voiceA
527   \new Staff \new Voice \voiceB
528 >>
529 @end lilypond
530
531 This works quite well for piano music
532
533 @lilypond[quote,verbatim]
534 music = {
535   \key c \major
536   \time 4/4
537   \parallelMusic #'(voiceA voiceB voiceC voiceD) {
538     % Bar 1
539     r8  g'16[ c''] e''[ g' c'' e''] r8  g'16[ c''] e''[ g' c''
540 e''] |
541     c'2                                 c'2 |
542     r8  a16[ d'] f'[ a d' f']       r8  a16[ d'] f'[ a d' f'] |
543     c2                                  c2 |
544
545     % Bar 2
546     a'8 b'      c'' d''    e'' f''    g'' a'' |
547     d'4         d'         d'         d' |
548     c16 d e f   d e f g    e f g a    f g a b |
549     a,4         a,4        a,4        a,4 |
550
551     % Bar 3 ...
552   }
553 }
554
555 \score {
556   \new PianoStaff <<
557     \music
558     \new Staff <<
559       \voiceA \\
560       \voiceB
561     >>
562     \new Staff {
563       \clef bass
564       <<
565         \voiceC \\
566         \voiceD
567       >>
568     }
569   >>
570 }
571 @end lilypond
572
573
574