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