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