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