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