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