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