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