]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/simultaneous.itely
Merge branch 'master' of git://git.sv.gnu.org/lilypond.git into td-lily
[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>1 <c e g>->
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 @lsrdir{Simultaneous,Simultaneous-notes}.
66
67 @knownissues
68
69 Music expressions like @code{<< @{ g8 e8 @} a4 >>} are not printed
70 accurately.  Use @code{<g a>8 <e a>8} instead.
71
72
73 @node Clusters
74 @subsubsection Clusters
75
76 @cindex cluster
77 @funindex \makeClusters
78
79 A cluster indicates a continuous range of pitches to be played.  They
80 can be denoted as the envelope of a set of notes.  They are entered by
81 applying the function @code{\makeClusters} to a sequence of chords,
82 e.g.,
83
84 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
85 \makeClusters { <g b>2 <c g'> }
86 @end lilypond
87
88 Ordinary notes and clusters can be put together in the same staff,
89 even simultaneously.  In such a case no attempt is made to
90 automatically avoid collisions between ordinary notes and clusters.
91
92 @seealso
93
94 Music Glossary:
95 @rglos{cluster}.
96
97 Snippets:
98 @lsrdir{Simultaneous,Simultaneous-notes}.
99
100 Internals Reference:
101 @internalsref{ClusterSpanner},
102 @internalsref{ClusterSpannerBeacon},
103 @internalsref{Cluster_spanner_engraver}.
104
105 @c Examples: @lsr{contemporary,cluster@/.ly}.
106
107 @knownissues
108
109 Clusters only look good if they span at least two chords; otherwise
110 they appear too narrow.
111
112 Clusters do not have a stem and can not indicate durations by
113 themselves.  Separate clusters would need a separating rest between
114 them.
115
116 @node Multiple voices
117 @subsection Multiple voices
118
119 @menu
120 * Collision resolution::        
121 * Automatic part combining::    
122 * Writing music in parallel::   
123 @end menu
124
125 @node Collision resolution
126 @subsubsection Collision resolution
127
128 @cindex merging notes
129 @cindex note collisions
130
131 Normally, note heads with a different number of dots are not
132 merged, but when the object property
133 @code{merge-differently-dotted} is set in the
134 @internalsref{NoteCollision} object, they are merged:
135
136 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
137 \new Voice << {
138   g8 g8
139   \override Staff.NoteCollision
140     #'merge-differently-dotted = ##t
141   g8 g8
142 } \\ { g8.[ f16] g8.[ f16] } >>
143 @end lilypond
144
145 Similarly, you can merge half note heads with eighth notes, by
146 setting @code{merge-differently-headed}:
147
148 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
149 \new Voice << {
150   c8 c4.
151   \override Staff.NoteCollision
152     #'merge-differently-headed = ##t
153 c8 c4. } \\ { c2 c2 } >>
154 @end lilypond
155
156 @noindent
157 @code{merge-differently-headed} and
158 @code{merge-differently-dotted} only apply to opposing stem
159 directions (i.e. Voice 1 & 2).
160
161 LilyPond also vertically shifts rests that are opposite of a stem,
162 for example
163
164 @lilypond[quote,ragged-right,fragment,verbatim]
165 \new Voice << c''4 \\ r4 >>
166 @end lilypond
167
168 @cindex shift note
169
170 If three or more notes line up in the same column,
171 @code{merge-differently-headed} cannot successfully complete the
172 merge of the two notes that should be merged.  To allow the merge
173 to work properly, apply a @code{\shift} to the note that should
174 not be merged.  In the first measure of following example,
175 @code{merge-differently-headed} does not work (the half-note head
176 is solid).  In the second measure, @code{\shiftOn} is applied to
177 move the top @code{g} out of the column, and
178 @code{merge-differently-headed} works properly.
179
180 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
181 \override Staff.NoteCollision #'merge-differently-headed = ##t
182 <<
183   { d=''2 g2 } \\
184   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
185   { \voiceFour e,,2 e'2}
186 >>
187 <<
188   { d'=''2 \shiftOn g2 } \\ 
189   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
190   { \voiceFour e,,2 e'2}
191 >>
192 @end lilypond
193
194 @cindex multiple voices
195 @cindex polyphonic music
196 @cindex shifting voices
197
198 In some instances of complex polyphonic music, you may need
199 additional voices to avoid collisions between notes.  Additional
200 voices are added by defining an variable, as shown below:
201
202 @lilypond[quote,verbatim,ragged-right,relative=2]
203 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
204
205 \relative c''' <<
206   { \voiceOne g4 ~  \stemDown g32[ f( es d c b a b64 )g] } \\
207   { \voiceThree  b4} \\
208   { \voiceFive d,} \\
209   { \voiceTwo g,}
210 >>
211 @end lilypond
212
213
214
215 @predefined
216
217 @funindex \oneVoice
218 @code{\oneVoice},
219 @funindex \voiceOne
220 @code{\voiceOne},
221 @funindex \voiceTwo
222 @code{\voiceTwo},
223 @funindex \voiceThree
224 @code{\voiceThree},
225 @funindex \voiceFour
226 @code{\voiceFour}.
227
228 @funindex \voiceNeutralStyle
229 @funindex \voiceOneStyle
230 @funindex \voiceTwoStyle
231 @funindex \voiceThreeStyle
232 @funindex \voiceFourStyle
233 @example
234 \voiceNeutralStyle
235 \voiceOneStyle
236 \voiceTwoStyle
237 \voiceThreeStyle
238 \voiceFourStyle
239 @end example
240
241 @funindex \shiftOn
242 @code{\shiftOn},
243 @funindex \shiftOnn
244 @code{\shiftOnn},
245 @funindex \shiftOnnn
246 @code{\shiftOnnn},
247 @funindex \shiftOff
248 @code{\shiftOff}: these commands specify the degree to which
249 chords of the current voice should be shifted.  The outer voices
250 (normally: voice one and two) have @code{\shiftOff}, while the
251 inner voices (three and four) have @code{\shiftOn}.
252 @code{\shiftOnn} and @code{\shiftOnnn} define further shift
253 levels.
254
255 When LilyPond cannot cope, the @code{force-hshift} property of the
256 @internalsref{NoteColumn} object and pitched rests can be used to
257 override typesetting decisions.
258
259 @lilypond[quote,verbatim,ragged-right]
260 \relative <<
261 {
262   <d g>
263   <d g>
264 } \\ {
265   <b f'>
266   \once \override NoteColumn #'force-hshift = #1.7
267   <b f'>
268 } >>
269 @end lilypond
270
271
272 @seealso
273
274 Snippets:
275 @lsrdir{Simultaneous,Simultaneous-notes}.
276
277 Internals Reference: the objects responsible for resolving collisions
278 are
279 @internalsref{NoteCollision} and
280 @internalsref{RestCollision}.
281
282
283 @knownissues
284
285 When using @code{merge-differently-headed} with an upstem eighth
286 or a shorter note, and a downstem half note, the eighth note gets
287 the wrong offset.
288
289 There is no support for clusters where the same note occurs with
290 different accidentals in the same chord.  In this case, it is
291 recommended to use enharmonic transcription, or to use special
292 cluster notation (see @ref{Clusters}).
293
294
295 @node Automatic part combining
296 @subsubsection Automatic part combining
297 @cindex automatic part combining
298 @cindex part combiner
299 @cindex combining parts
300
301 Automatic part combining is used to merge two parts of music onto
302 a staff.  It is aimed at typesetting orchestral scores.  When the
303 two parts are identical for a period of time, only one is shown.
304 In places where the two parts differ, they are typeset as separate
305 voices, and stem directions are set automatically.  Also, solo and
306 @emph{a due} parts are identified and can be marked.
307
308 The syntax for part combining is
309
310 @example
311 \partcombine @var{musicexpr1} @var{musicexpr2}
312 @end example
313
314
315 The following example demonstrates the basic functionality of the
316 part combiner: putting parts on one staff, and setting stem
317 directions and polyphony.
318
319 @lilypond[quote,verbatim,ragged-right,fragment]
320 \new Staff \partcombine
321   \relative g' { g g a( b) c c r r }
322   \relative g' { g g r4 r e e g g }
323 @end lilypond
324
325 The first @code{g} appears only once, although it was specified
326 twice (once in each part).  Stem, slur, and tie directions are set
327 automatically, depending whether there is a solo or unisono.  The
328 first part (with context called @code{one}) always gets up stems,
329 and @q{Solo}, while the second (called @code{two}) always gets
330 down stems and @q{Solo II}.
331
332 If you just want the merging parts, and not the textual markings,
333 you may set the property @code{printPartCombineTexts} to false.
334
335 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
336 \new Staff <<
337   \set Staff.printPartCombineTexts = ##f
338   \partcombine
339     \relative g' { g a( b) r }
340     \relative g' { g r4 r f }
341 >>
342 @end lilypond
343
344 To change the text that is printed for solos or merging, you may
345 set the @code{soloText}, @code{soloIIText}, and @code{aDueText}
346 properties.
347
348 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
349 \new Staff <<
350   \set Score.soloText = #"ichi"
351   \set Score.soloIIText = #"ni"
352   \set Score.aDueText = #"tachi"
353   \partcombine
354     \relative g' { g4 g a( b) r }
355     \relative g' { g4 g r r f }
356 >>
357 @end lilypond
358
359 Both arguments to @code{\partcombine} will be interpreted as
360 @internalsref{Voice} contexts.  If using relative octaves,
361 @code{\relative} should be specified for both music expressions,
362 i.e.,
363
364 @example
365 \partcombine
366   \relative @dots{} @var{musicexpr1}
367   \relative @dots{} @var{musicexpr2}
368 @end example
369
370 @noindent
371 A @code{\relative} section that is outside of @code{\partcombine}
372 has no effect on the pitches of @var{musicexpr1} and
373 @var{musicexpr2}.
374
375 @seealso
376
377 Music Glossary:
378 @rglos{a due}.
379
380 Snippets:
381 @lsrdir{Simultaneous,Simultaneous-notes}.
382
383 Internals Reference:
384 @internalsref{PartCombineMusic},
385 @internalsref{Voice}.
386
387 @knownissues
388
389 When @code{printPartCombineTexts} is set, if the two voices play
390 the same notes on and off, the part combiner may typeset @code{a2}
391 more than once in a measure.
392
393 @code{\partcombine} cannot be inside @code{\times}.
394
395 @code{\partcombine} cannot be inside @code{\relative}.
396
397 Internally, the @code{\partcombine} interprets both arguments as
398 @code{Voice}s named @code{one} and @code{two}, and then decides
399 when the parts can be combined.  Consequently, if the arguments
400 switch to differently named @internalsref{Voice} contexts, the
401 events in those will be ignored.
402
403
404 @node Writing music in parallel
405 @subsubsection Writing music in parallel
406
407 @cindex Writing music in parallel
408 @cindex Interleaved music
409
410 Music for multiple parts can be interleaved:
411
412 @lilypond[quote,fragment,verbatim]
413 \parallelMusic #'(voiceA voiceB) {
414   r8 g'16[ c''] e''[ g' c'' e''] r8 g'16[ c''] e''[ g' c'' e''] |
415   c'2                               c'2                         |
416   r8 a'16[ d''] f''[ a' d'' f''] r8 a'16[ d''] f''[ a' d'' f''] |
417   c'2                               c'2                         |
418 }
419 \new StaffGroup <<
420   \new Staff \new Voice \voiceA
421   \new Staff \new Voice \voiceB
422 >>
423 @end lilypond
424
425 This works quite well for piano music.
426
427 @c  It would be nice if the first bar fit onto one 66-char line.
428 @c  Maybe simplify the example?  -gp
429 @lilypond[quote,verbatim]
430 music = {
431   \key c \major
432   \time 4/4
433   \parallelMusic #'(voiceA voiceB voiceC voiceD) {
434     % Bar 1
435     r8  g'16[ c''] e''[ g' c'' e'']
436       r8 g'16[ c''] e''[ g' c'' e''] |
437     c'2
438       c'2 |
439     r8  a16[ d'] f'[ a d' f']
440       r8  a16[ d'] f'[ a d' f'] |
441     c2
442       c2 |
443
444     % Bar 2
445     a'8 b'      c'' d''    e'' f''    g'' a'' |
446     d'4         d'         d'         d' |
447     c16 d e f   d e f g    e f g a    f g a b |
448     a,4         a,4        a,4        a,4 |
449
450     % Bar 3 ...
451   }
452 }
453
454 \score {
455   \new PianoStaff <<
456     \music
457     \new Staff <<
458       \voiceA \\
459       \voiceB
460     >>
461     \new Staff {
462       \clef bass
463       <<
464         \voiceC \\
465         \voiceD
466       >>
467     }
468   >>
469 }
470 @end lilypond
471
472 @seealso
473
474 Snippets:
475 @lsrdir{Simultaneous,Simultaneous-notes}.
476