]> 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.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
138 Normally, equal note heads with the same number of dots are
139 automatically merged, but note heads with a different number of dots
140 are not. To merge differently dotted note heads, you can set the
141 @code{merge-differently-dotted} property of the
142 @rinternals{NoteCollision} object:
143
144 @lilypond[quote,verbatim,relative=2]
145 <<
146   { g2 g4 g8 g
147     \override Staff.NoteCollision #'merge-differently-dotted = ##t
148     g2 g4 g8 g }
149   \\
150   { g2. g8. g16
151     g2. g8. g16 }
152 >>
153 @end lilypond
154
155 Similarly, you can merge half note heads with eighth notes, by
156 setting @code{merge-differently-headed}:
157
158 @lilypond[quote,relative=2,verbatim]
159 <<
160   { c8 d e d
161     \override Staff.NoteCollision #'merge-differently-headed = ##t
162     c8 d e d
163   }
164   \\
165   { c2 c }
166 >>
167 @end lilypond
168
169 @noindent
170 Merging notes by setting @code{merge-differently-headed} and
171 @code{merge-differently-dotted} only works for opposing stem
172 directions (i.e., to @code{Voice}s 1 and 2).
173
174 @cindex shift rest, automatic
175
176 LilyPond also vertically shifts rests that are opposite of a stem, for
177 example:
178
179 @lilypond[quote,verbatim]
180 << c''4 \\ r4 >>
181 @end lilypond
182
183 @cindex shift note
184
185 If three or more notes line up in the same column,
186 @code{merge-differently-headed} cannot successfully complete the merge
187 of the two notes that should be merged.  To allow the merge to work
188 properly, apply a @code{\shift} to the note that should not be merged.
189 In the first measure of following example,
190 @code{merge-differently-headed} does not work (the half-note head is
191 solid).  In the second measure, @code{\shiftOn} is applied to move the
192 top @code{g} out of the column, and @code{merge-differently-headed}
193 works properly.
194
195 @c IMO this uglyfies the typesetting. Look for a better example. FV
196
197 @lilypond[quote,verbatim,relative=2]
198 \override Staff.NoteCollision #'merge-differently-headed = ##t
199 <<
200   { d=''2 g2 } \\
201   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
202   { \voiceFour e,,2 e'2}
203 >>
204 <<
205   { d'=''2 \shiftOn g2 } \\ 
206   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
207   { \voiceFour e,,2 e'2}
208 >>
209 @end lilypond
210
211 @cindex multiple voices
212 @cindex polyphonic music
213 @cindex shifting voices
214
215 In some instances of complex polyphonic music, you may need
216 additional voices to avoid collisions between notes.  Additional
217 voices are added by defining an variable, as shown below:
218
219 @lilypond[quote,verbatim]
220 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
221 \relative c'''
222 << 
223   { \voiceOne g2. ~ \stemDown g32[ f( es d c b a b64) g] } \\
224   { \voiceThree b4 } \\
225   { \voiceFive d,  } \\
226   { \voiceTwo g,   }
227 >>
228 @end lilypond
229
230
231 @predefined
232
233 @funindex \oneVoice
234 @code{\oneVoice},
235 @funindex \voiceOne
236 @code{\voiceOne},
237 @funindex \voiceTwo
238 @code{\voiceTwo},
239 @funindex \voiceThree
240 @code{\voiceThree},
241 @funindex \voiceFour
242 @code{\voiceFour}.
243
244 @c undocumented?: --FV
245 @funindex \voiceNeutralStyle
246 @funindex \voiceOneStyle
247 @funindex \voiceTwoStyle
248 @funindex \voiceThreeStyle
249 @funindex \voiceFourStyle
250 @example
251 \voiceNeutralStyle
252 \voiceOneStyle
253 \voiceTwoStyle
254 \voiceThreeStyle
255 \voiceFourStyle
256 @end example
257
258 @funindex \shiftOn
259 @code{\shiftOn},
260 @funindex \shiftOnn
261 @code{\shiftOnn},
262 @funindex \shiftOnnn
263 @code{\shiftOnnn},
264 @funindex \shiftOff
265 @code{\shiftOff}: these commands specify the degree to which
266 chords of the current voice should be shifted.  The outer voices
267 (normally: voices one and two) have @code{\shiftOff}, while the
268 inner voices (three and four) have @code{\shiftOn}.
269 @code{\shiftOnn} and @code{\shiftOnnn} define further shift
270 levels.
271
272 When LilyPond cannot cope, the @code{force-hshift} property of the
273 @rinternals{NoteColumn} object and pitched rests can be used to
274 override typesetting decisions.
275
276 @lilypond[quote,verbatim,relative=1]
277 <<
278   { <d g>2
279     <d g>  }
280   \\
281   { <b f'>2
282     \once \override NoteColumn #'force-hshift = #1.7
283     <b f'> }
284 >>
285
286 @end lilypond
287
288
289 @seealso
290
291 Music Glossary:
292 @rglos{polyphony}
293
294 Learning Manual:
295 @rlearning{Multiple notes at once},
296 @rlearning{Voices contain music},
297 @rlearning{Collisions of objects}.
298
299 Snippets:
300 @rlsr{Simultaneous notes}.
301
302 Internals Reference:
303 @rinternals{NoteColumn}.
304 The objects responsible for resolving collisions
305 are
306 @rinternals{NoteCollision} and
307 @rinternals{RestCollision}.
308
309
310 @knownissues
311
312 When using @code{merge-differently-headed} with an upstem eighth or a
313 shorter note, and a downstem half note, the eighth note stem gets a
314 slightly wrong offset because of the different width of the half note
315 head symbol.
316
317 There is no support for clusters where the same note occurs with
318 different accidentals in the same chord.  In this case, it is
319 recommended to use enharmonic transcription, or to use special
320 cluster notation (see @ref{Clusters}).
321
322 @node Automatic part combining
323 @subsubsection Automatic part combining
324
325 @cindex automatic part combining
326 @cindex part combiner
327 @cindex combining parts
328 @funindex \partcombine
329
330 Automatic part combining is used to merge two parts of music onto a
331 staff.  It is aimed at typesetting orchestral scores.  When the two
332 parts are identical for a period of time, only one is shown.  In
333 places where the two parts differ, they are typeset as separate
334 voices, and stem directions are set automatically.  Also, solo and
335 @notation{a due} parts are identified and marked by default.
336
337 The syntax for part combining is:
338
339 @example
340 \partcombine @var{musicexpr1} @var{musicexpr2}
341 @end example
342
343 The following example demonstrates the basic functionality of the part
344 combiner: putting parts on one staff and setting stem directions and
345 polyphony.  The same variables are used for the independent
346 parts and the combined staff.
347
348 @lilypond[quote,verbatim]
349 instrumentOne = \relative c' {
350   c4 d e f
351   R1
352   d'4 c b a
353   b4 g2 f4
354   e1
355 }
356
357 instrumentTwo = \relative g' {
358   R1
359   g4 a b c
360   d c b a
361   g f( e) d
362   e1
363 }
364
365 <<
366   \new Staff \instrumentOne
367   \new Staff \instrumentTwo
368   \new Staff \partcombine \instrumentOne \instrumentTwo
369 >>
370 @end lilypond
371
372 The notes in the third measure appear only once, although they were
373 specified in both parts.  Stem, slur, and tie directions are set
374 automatically, depending whether there is a solo or unison.  When
375 needed in polyphony situations, the first part (with context called
376 @code{one}) always gets up stems, while the second (called @code{two})
377 always gets down stems.  In solo situations, the parts get marked with
378 @q{Solo} and @q{Solo II}, respectively.  The unisono (@notation{a due})
379 parts are marked by default with the text @qq{a2}.
380
381 Both arguments to @code{\partcombine} will be interpreted as
382 @code{Voice} contexts.  If using relative octaves,
383 @code{\relative} should be specified for both music expressions,
384 i.e.,
385
386 @example
387 \partcombine
388   \relative @dots{} @var{musicexpr1}
389   \relative @dots{} @var{musicexpr2}
390 @end example
391
392 @noindent
393 A @code{\relative} section that is outside of @code{\partcombine}
394 has no effect on the pitches of @var{musicexpr1} and
395 @var{musicexpr2}.
396
397 @snippets
398
399 Parts may be merged without printing text:
400
401 @lilypond[quote,verbatim]
402 \new Staff <<
403   \set Staff.printPartCombineTexts = ##f
404   \partcombine
405     \relative g' { g a( b) r }
406     \relative g' { g r4 r f }
407 >>
408 @end lilypond
409
410 The printed text may be changed:
411
412 @lilypond[quote,verbatim]
413 \new Staff <<
414   \set Score.soloText = #"girl"
415   \set Score.soloIIText = #"boy"
416   \set Score.aDueText = #"together"
417   \partcombine
418     \relative g' { g4 g r r a2 g }
419     \relative g' { r4 r a( b) a2 g }
420 >>
421 @end lilypond
422
423
424 @seealso
425
426 Music Glossary:
427 @rglos{a due},
428 @rglos{part}.
429
430 Notation Reference:
431 @ref{Writing parts}.
432
433 Snippets:
434 @rlsr{Simultaneous notes}.
435
436
437 Internals Reference:
438 @rinternals{PartCombineMusic},
439 @rinternals{Voice}.
440
441 @knownissues
442
443 When @code{printPartCombineTexts} is set, if the two voices play
444 the same notes on and off, the part combiner may typeset @code{a2}
445 more than once in a measure.
446
447 @code{\partcombine} cannot be inside @code{\times}.
448
449 @code{\partcombine} cannot be inside @code{\relative}.
450
451 Internally, the @code{\partcombine} interprets both arguments as
452 @code{Voice}s named @code{one} and @code{two}, and then decides
453 when the parts can be combined.  Consequently, if the arguments
454 switch to differently named @rinternals{Voice} contexts, the
455 events in those will be ignored.
456
457 @c IIRC in users list someone pointed out more issues. FV
458
459 @node Writing music in parallel
460 @subsubsection Writing music in parallel
461
462 @cindex Writing music in parallel
463 @cindex Interleaved music
464 @funindex parallelMusic
465
466 Music for multiple parts can be interleaved in input code.  The
467 function @code{\parallelMusic} accepts a list with the names of a
468 number of variables to be created, and a musical expression.  The
469 content of alternate measures from the expression become the value of
470 the respective variables, so you can use them afterwards to print the
471 music.
472
473 @warning{Bar checks @code{|} must be used, and the measures must
474 be of the same length.}
475
476 @lilypond[quote,verbatim]
477 \parallelMusic #'(voiceA voiceB) {
478   % Bar 1
479   r8 g'16[ c''] e''[ g' c'' e''] r8 g'16[ c''] e''[ g' c'' e''] |
480   c'2                               c'2                         |
481
482   % Bar 2
483   r8 a'16[ d''] f''[ a' d'' f''] r8 a'16[ d''] f''[ a' d'' f''] |
484   c'2                               c'2                         |
485 }
486 \new StaffGroup <<
487   \new Staff  \voiceA
488   \new Staff  \voiceB
489 >>
490 @end lilypond
491
492 Relative mode may be used.  Note that the @code{\relative} command
493 is not used inside @code{\parallelMusic} itself.  The notes are
494 relative to the preceding note in the voice, not to the previous
495 note in the input -- in other words, relative notes for
496 @code{voiceA} ignore the notes in @code{voiceB}.
497
498 @lilypond[quote,verbatim]
499 \parallelMusic #'(voiceA voiceB) {
500   % Bar 1
501   r8 g16 c e g, c e r8 g,16 c e g, c e  |
502   c2                c                   |
503
504   % Bar 2
505   r8 a,16 d f a, d f r8 a,16 d f a, d f |
506   c2                 c                  |
507  }
508 \new StaffGroup <<
509   \new Staff \relative c'' \voiceA
510   \new Staff \relative c'  \voiceB
511 >>
512 @end lilypond
513
514 This works quite well for piano music.  This example maps four
515 consecutive measures to four variables:
516
517 @lilypond[quote,verbatim]
518 global = {
519   \key g \major
520   \time 2/4
521 }
522
523 \parallelMusic #'(voiceA voiceB voiceC voiceD) {
524   % Bar 1
525   a8    b     c   d     |
526   d4          e         |
527   c16 d e fis d e fis g |
528   a4          a         |
529
530   % Bar 2
531   e8      fis  g     a   |
532   fis4         g         |
533   e16 fis g  a fis g a b |
534   a4           a         |
535
536   % Bar 3 ...
537 }   
538
539 \score {   
540 \new PianoStaff <<
541  \new Staff {
542    \global
543    <<
544      \relative c'' \voiceA \\
545      \relative c'  \voiceB
546    >>
547  }
548  \new Staff {
549    \global \clef bass
550    <<
551      \relative c \voiceC \\
552      \relative c \voiceD
553    >>
554  }
555 >>
556 }
557 @end lilypond
558
559
560 @seealso
561
562 Learning Manual:
563 @rlearning{Organizing pieces with variables}
564
565 Snippets:
566 @rlsr{Simultaneous notes}.
567