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