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