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