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