]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/learning/common-notation.itely
Doc whitespace: process most files.
[lilypond.git] / Documentation / learning / common-notation.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.12.0"
11
12 @ignore
13 Tutorial guidelines:  (different from policy.txt!)
14 - unless you have a really good reason, use either
15     @lilypond[verbatim,quote]
16   or
17     @lilypond[verbatim,quote,relative=2]
18
19   Don't use any other relative=X commands.
20
21 - use "aes" and "ees" instead of "as" and "es".  I know it's not
22   correct Dutch naming, but let's not confuse people with this
23   until we get to the Basic notation chapter.
24
25 - Add "Music Glossary: @rglos{foo}" to the *top* of the relevant
26   portions of the tutorial.
27
28 @end ignore
29
30
31 @node Common notation
32 @chapter Common notation
33
34 This chapter explains how to create beautiful printed music
35 containing common musical notation, following the material in
36 @ref{Tutorial}.
37
38 @menu
39 * Single staff notation::
40 * Multiple notes at once::
41 * Songs::
42 * Final touches::
43 @end menu
44
45
46 @node Single staff notation
47 @section Single staff notation
48
49 This section introduces common notation that is used for one voice
50 on one staff.
51
52 @menu
53 * Accidentals and key signatures::
54 * Ties and slurs::
55 * Articulation and dynamics::
56 * Adding text::
57 * Automatic and manual beams::
58 * Advanced rhythmic commands::
59 @end menu
60
61
62 @node Accidentals and key signatures
63 @subsection Accidentals and key signatures
64
65 @warning{New users are often confused by these -- please read the
66 warning at the bottom of this page, especially if you are not
67 familiar with music theory!}
68
69 @subheading Accidentals
70
71 @cindex accidentals
72 @cindex accidentals and key signatures
73 @cindex sharp
74 @cindex double sharp
75 @cindex sharp, double
76 @cindex flat
77 @cindex double flat
78 @cindex flat, double
79
80 @funindex es
81 @funindex is
82 @funindex eses
83 @funindex isis
84
85 Music Glossary: @rglos{sharp}, @rglos{flat}, @rglos{double sharp},
86 @rglos{double flat}, @rglos{accidental}.
87
88 A @notation{sharp} pitch is made by adding @code{is} to the name,
89 and a @notation{flat} pitch by adding @code{es}.  As you might
90 expect, a @notation{double sharp} or @notation{double flat} is
91 made by adding @code{isis} or @code{eses}.  This syntax is derived
92 from note naming conventions in Nordic and Germanic languages,
93 like German and Dutch.  To use other names for
94 @notation{accidentals}, see @ruser{Note names in other languages}.
95
96 @lilypond[verbatim,quote,relative=2]
97 cis1 ees fisis, aeses
98 @end lilypond
99
100 @cindex key signature, setting
101 @subheading Key signatures
102
103 @cindex key signature
104 @cindex major
105 @cindex minor
106 @cindex accidentals and key signature
107 @cindex content vs. layout
108 @cindex layout vs. content
109
110 @funindex \key
111 @funindex key
112 @funindex \major
113 @funindex major
114 @funindex \minor
115 @funindex minor
116
117 Music Glossary: @rglos{key signature}, @rglos{major},
118 @rglos{minor}.
119
120 The @notation{key signature} is set with the command @code{\key}
121 followed by a pitch and @code{\major} or @code{\minor}.
122
123 @lilypond[verbatim,quote,relative=2]
124 \key d \major
125 a1
126 \key c \minor
127 a
128 @end lilypond
129
130 @smallspace
131
132 @subheading Warning: key signatures and pitches
133
134 Music Glossary: @rglos{accidental}, @rglos{key signature},
135 @rglos{pitch}, @rglos{flat}, @rglos{natural}, @rglos{sharp},
136 @rglos{transposition}.
137
138 To determine whether to print an @notation{accidental}, LilyPond
139 examines the pitches and the @notation{key signature}.  The key
140 signature only affects the @emph{printed} accidentals, not the
141 note's @notation{pitch}!  This is a feature that often causes
142 confusion to newcomers, so let us explain it in more detail.
143
144 LilyPond makes a sharp distinction between musical content and
145 layout.  The alteration (@notation{flat}, @notation{natural sign} or
146 @notation{sharp}) of a note is part of the pitch, and is therefore
147 musical content.  Whether an accidental (a @emph{printed} flat,
148 natural or sharp sign) is printed in front of the corresponding
149 note is a question of layout.  Layout is something that follows
150 rules, so accidentals are printed automatically according to those
151 rules.  The pitches in your music are works of art, so they will
152 not be added automatically, and you must enter what you want to
153 hear.
154
155 In this example:
156
157 @lilypond[verbatim,quote,relative=2]
158 \key d \major
159 d cis fis
160 @end lilypond
161
162 @noindent
163 No note has a printed accidental, but you must still add
164 @code{is} and type @code{cis} and @code{fis} in the input file.
165
166 The code @code{b} does not mean @qq{print a black dot just on
167 the middle line of the staff.}  Rather, it means @qq{there is a
168 note with pitch B-natural.}  In the key of A-flat major, it
169 @emph{does} get an accidental:
170
171 @lilypond[verbatim,quote,relative=2]
172 \key aes \major
173 b
174 @end lilypond
175
176 If the above seems confusing, consider this: if you were playing a
177 piano, which key would you hit?  If you would press a black key,
178 then you @emph{must} add @code{-is} or @code{-es} to the note
179 name!
180
181 Adding all alterations explicitly might require a little more
182 effort when typing, but the advantage is that
183 @notation{transposing} is easier, and accidentals can be printed
184 according to different conventions.  For some examples of how
185 accidentals can be printed according to different rules, see
186 @ruser{Automatic accidentals}.
187
188
189 @seealso
190 Notation Reference: @ruser{Note names in other languages},
191 @ruser{Accidentals}, @ruser{Automatic accidentals},
192 @ruser{Key signature}.
193
194 Music Glossary: @rglos{Pitch names}.
195
196
197 @node Ties and slurs
198 @subsection Ties and slurs
199
200 @cindex tie
201 @cindex slur
202 @cindex slur, phrasing
203 @cindex phrasing slur
204
205 @funindex ~
206 @funindex ( ... )
207 @funindex \( ... \)
208
209 @subheading Ties
210
211
212 Music Glossary: @rglos{tie}.
213
214 A @notation{tie} is created by appending a tilde @code{~} to the
215 first note being tied.
216
217 @lilypond[verbatim,quote,relative=2]
218 g4~ g c2~
219 c4 ~ c8 a8 ~ a2
220 @end lilypond
221
222 @subheading Slurs
223
224
225 Music Glossary: @rglos{slur}.
226
227 A @notation{slur} is a curve drawn across many notes.  The
228 starting note and ending note are marked with @code{(} and
229 @code{)} respectively.
230
231 @lilypond[verbatim,quote,relative=2]
232 d4( c16) cis( d e c cis d) e( d4)
233 @end lilypond
234
235 @subheading Phrasing slurs
236
237 Music Glossary: @rglos{slur}, @rglos{phrasing}.
238
239 Slurs to indicate longer @notation{phrasing} can be entered with
240 @code{\(} and @code{\)}.  You can have both @notation{slurs}
241 and phrasing slurs at the same time, but you cannot have
242 simultaneous slurs or simultaneous phrasing slurs.
243
244 @lilypond[verbatim,quote,relative=2]
245 a8(\( ais b c) cis2 b'2 a4 cis,\)
246 @end lilypond
247
248 @smallspace
249
250 @cindex slurs versus ties
251 @subheading Warnings: slurs vs. ties
252
253 Music Glossary: @rglos{articulation}, @rglos{slur}, @rglos{tie}.
254
255 A @notation{slur} looks like a @notation{tie}, but it has a
256 different meaning.  A tie simply makes the first note longer, and
257 can only be used on pairs of notes with the same pitch.  Slurs
258 indicate the @notation{articulation} of notes, and can be used on
259 larger groups of notes.  Slurs and ties can be nested.
260
261 @lilypond[verbatim,quote,relative=2]
262 c2~( c8 fis fis4 ~ fis2 g2)
263 @end lilypond
264
265
266 @seealso
267 Notation Reference: @ruser{Ties}, @ruser{Slurs},
268 @ruser{Phrasing slurs}.
269
270
271 @node Articulation and dynamics
272 @subsection Articulation and dynamics
273
274
275 @subheading Articulations
276
277 @cindex articulation
278 @cindex accent
279 @cindex staccato
280
281 Music Glossary: @rglos{articulation}.
282
283 Common @notation{articulations} can be added to a note using a
284 dash @code{-} and a single character:
285
286 @lilypond[verbatim,quote,relative=2]
287 c-. c-- c-> c-^ c-+ c-_
288 @end lilypond
289
290 @subheading Fingerings
291
292 @cindex fingering
293
294 @funindex ^
295 @funindex _
296
297 Music Glossary: @rglos{fingering}.
298
299 Similarly, @notation{fingering} indications can be added to a note
300 using a dash (@code{-}) and the digit to be printed:
301
302 @lilypond[verbatim,quote,relative=2]
303 c-3 e-5 b-2 a-1
304 @end lilypond
305
306 Articulations and fingerings are usually placed automatically, but
307 you can specify a direction by replacing the dash (@code{-}) with
308 @code{^} (up) or @code{_} (down).  You can also use multiple
309 articulations on the same note.  However, in most cases it is best
310 to let LilyPond determine the articulation directions.
311
312 @lilypond[verbatim,quote,relative=2]
313 c_-^1 d^. f^4_2-> e^-_+
314 @end lilypond
315
316 @subheading Dynamics
317
318 @cindex dynamics
319 @cindex decrescendo
320 @cindex crescendo
321
322 @funindex \f
323 @funindex \ff
324 @funindex \mp
325 @funindex \p
326 @funindex \mf
327 @funindex \pp
328 @funindex \<
329 @funindex <
330 @funindex \>
331 @funindex >
332 @funindex \!
333 @funindex !
334
335 Music Glossary: @rglos{dynamics}, @rglos{crescendo},
336 @rglos{decrescendo}.
337
338 @notation{Dynamic} signs are made by adding the markings (with a
339 backslash) to the note:
340
341 @lilypond[verbatim,quote,relative=2]
342 c\ff c\mf c\p c\pp
343 @end lilypond
344
345
346 @notation{Crescendi} and @notation{decrescendi} are started with
347 the commands @code{\<} and @code{\>}.  The next dynamics sign, for
348 example @code{\f}, will end the (de)crescendo, or the command
349 @code{\!} can be used:
350
351 @lilypond[verbatim,quote,relative=2]
352 c2\< c2\ff\> c2 c2\!
353 @end lilypond
354
355
356 @seealso
357 Notation Reference: @ruser{Articulations and ornamentations},
358 @ruser{Fingering instructions}, @ruser{Dynamics}.
359
360
361 @node Adding text
362 @subsection Adding text
363
364 @cindex text, adding
365 @cindex adding text
366 @cindex markup
367
368 @funindex \markup
369 @funindex markup
370
371 Text may be added to your scores:
372
373 @lilypond[verbatim,quote,relative=2]
374 c1^"espr" a_"legato"
375 @end lilypond
376
377 Extra formatting may be added with the @code{\markup} command:
378
379 @lilypond[verbatim,quote,relative=2]
380 c1^\markup{ \bold espr}
381 a1_\markup{
382   \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p
383 }
384 @end lilypond
385
386
387 @seealso
388 Notation Reference: @ruser{Writing text}.
389
390
391 @node Automatic and manual beams
392 @subsection Automatic and manual beams
393
394 @cindex beaming
395 @cindex automatic beams
396 @cindex manual beams
397 @cindex beams, automatic
398 @cindex beams, manual
399 @cindex beams, by hand
400
401 @funindex [ ... ]
402 @funindex [
403 @funindex ]
404 @funindex \autoBeamOff
405 @funindex autoBeamOff
406 @funindex \autoBeamOn
407 @funindex autoBeamOn
408
409 Music Glossary: @rglos{beam}.
410
411 All @notation{beams} are drawn automatically:
412
413 @lilypond[verbatim,quote,relative=2]
414 a8 ais d ees r d c16 b a8
415 @end lilypond
416
417 If you do not like the automatic beams, they may be overridden
418 manually.  To correct just an occasional beam mark the first note
419 to be beamed with @code{[} and the last one with @code{]}.
420
421 @lilypond[verbatim,quote,relative=2]
422 a8[ ais] d[ ees r d] a b
423 @end lilypond
424
425 If you want to turn off automatic beaming entirely or for an
426 extended section of music, use the command @code{\autoBeamOff}
427 to turn off automatic beaming and @code{\autoBeamOn} to turn it
428 on again.
429
430 @lilypond[verbatim,quote,relative=2]
431 \autoBeamOff
432 a8 c b4 d8. c16 b4
433 \autoBeamOn
434 a8 c b4 d8. c16 b4
435 @end lilypond
436
437
438 @seealso
439 Notation Reference: @ruser{Automatic beams}, @ruser{Manual beams}.
440
441
442 @node Advanced rhythmic commands
443 @subsection Advanced rhythmic commands
444
445 @subheading Partial measure
446
447 @cindex pickup
448 @cindex anacrusis
449 @cindex partial measure
450
451 @funindex \partial
452 @funindex partial
453
454 Music Glossary: @rglos{anacrusis}.
455
456 A pickup (or @notation{anacrusis}) is entered with the keyword
457 @code{\partial}.  It is followed by a duration: @code{\partial 4}
458 is a quarter note pickup and @code{\partial 8} an eighth note.
459
460 @lilypond[verbatim,quote,relative=2]
461 \partial 8
462 f8 c2 d
463 @end lilypond
464
465 @subheading Tuplets
466
467 @cindex tuplets
468 @cindex triplets
469
470 @funindex \times
471 @funindex times
472
473 Music Glossary: @rglos{note value}, @rglos{triplet}.
474
475 @notation{Tuplets} are made with the @code{\times} keyword.  It
476 takes two arguments: a fraction and a piece of music.  The
477 duration of the piece of music is multiplied by the fraction.
478 Triplets make notes occupy 2/3 of their notated duration, so a
479 @notation{triplet} has 2/3 as its fraction
480
481 @lilypond[verbatim,quote,relative=2]
482 \times 2/3 { f8 g a }
483 \times 2/3 { c r c }
484 \times 2/3 { f,8 g16[ a g a] }
485 \times 2/3 { d4 a8 }
486 @end lilypond
487
488 @subheading Grace notes
489
490 @cindex grace notes
491 @cindex acciaccatura
492 @cindex appoggiatura
493
494 @funindex \grace
495 @funindex grace
496 @funindex \acciaccatura
497 @funindex acciaccatura
498 @funindex \appoggiatura
499 @funindex acciaccatura
500
501 Music Glossary: @rglos{grace notes}, @rglos{acciaccatura},
502 @rglos{appoggiatura}.
503
504 @notation{Grace notes} are created with the @code{\grace} command,
505 although they can also be created by prefixing a music expression
506 with the keyword @code{\appoggiatura} or @code{\acciaccatura}:
507
508 @lilypond[verbatim,quote,relative=2]
509 c2 \grace { a32[ b] } c2
510 c2 \appoggiatura b16 c2
511 c2 \acciaccatura b16 c2
512 @end lilypond
513
514
515 @seealso
516 Notation Reference: @ruser{Grace notes}, @ruser{Tuplets},
517 @ruser{Upbeats}.
518
519
520 @node Multiple notes at once
521 @section Multiple notes at once
522
523 This section introduces having more than one note at the same
524 time: multiple instruments, multiple staves for a single
525 instrument (i.e. piano), and chords.
526
527 Polyphony in music refers to having more than one voice occurring
528 in a piece of music.  Polyphony in LilyPond refers to having more
529 than one voice on the same staff.
530
531 @menu
532 * Music expressions explained::
533 * Multiple staves::
534 * Staff groups::
535 * Combining notes into chords::
536 * Single staff polyphony::
537 @end menu
538
539
540 @node Music expressions explained
541 @subsection Music expressions explained
542
543 @cindex music expression
544 @cindex expression, music
545 @cindex compound music expression
546 @cindex music expression, compound
547
548 In LilyPond input files, music is represented by @emph{music
549 expressions}.  A single note is a music expression:
550
551 @lilypond[verbatim,quote,relative=2]
552 a4
553 @end lilypond
554
555 Enclosing a note in braces creates a @emph{compound music
556 expression}.  Here we have created a compound music expression
557 with two notes:
558
559 @lilypond[verbatim,quote,relative=2]
560 { a4 g4 }
561 @end lilypond
562
563 Putting a group of music expressions (e.g. notes) in braces means
564 that they are in sequence (i.e. each one follows the previous
565 one).  The result is another music expression:
566
567 @lilypond[verbatim,quote,relative=2]
568 { { a4 g } f g }
569 @end lilypond
570
571 @subheading Analogy: mathematical expressions
572
573 This mechanism is similar to mathematical formulas: a big formula
574 is created by composing small formulas.  Such formulas are called
575 expressions, and they can contain other expressions, so you can
576 make arbitrarily complex and large expressions.  For example,
577
578 @example
579 1
580
581 1 + 2
582
583 (1 + 2) * 3
584
585 ((1 + 2) * 3) / (4 * 5)
586 @end example
587
588 This is a sequence of expressions, where each expression is
589 contained in the next (larger) one.  The simplest expressions are
590 numbers, and larger ones are made by combining expressions with
591 operators (like @code{+}, @code{*} and @code{/}) and parentheses.
592 Like mathematical expressions, music expressions can be nested
593 arbitrarily deep, which is necessary for complex music like
594 polyphonic scores.
595
596
597 @subheading Simultaneous music expressions: multiple staves
598
599 @cindex multiple staves
600 @cindex staves, multiple
601 @cindex polyphony
602 @cindex combining expressions in parallel
603 @cindex parallel expressions
604 @cindex expressions, parallel
605 @cindex relative notes and simultaneous music
606 @cindex relative notes and parallel expressions
607 @cindex simultaneous music and relative notes
608 @cindex parallel expressions and relative notes
609
610 @funindex <<
611 @funindex >>
612 @funindex << ... >>
613
614 Music Glossary: @rglos{polyphony}.
615
616 This technique is useful for @notation{polyphonic} music.  To
617 enter music with more voices or more staves, we combine
618 expressions in parallel.  To indicate that two voices should play
619 at the same time, simply enter a simultaneous combination of music
620 expressions.  A @q{simultaneous} music expression is formed by
621 enclosing expressions inside @code{<<} and @code{>>}.  In the
622 following example, three sequences (all containing two separate
623 notes) are combined simultaneously:
624
625 @lilypond[verbatim,quote]
626 \relative c'' {
627   <<
628     { a4 g }
629     { f e }
630     { d b }
631   >>
632 }
633 @end lilypond
634
635 Note that we have indented each level of the input with a
636 different amount of space.  LilyPond does not care how much (or
637 little) space there is at the beginning of a line, but indenting
638 LilyPond code like this makes it much easier for humans to read.
639
640 @warning{each note is relative to the previous note in
641 the input, not relative to the @code{c''} in the initial
642 @code{@bs{}relative} command.}
643
644
645 @subheading Simultaneous music expressions: single staff
646
647 To determine the number of staves in a piece, LilyPond looks at
648 the beginning of the first expression.  If there is a single note,
649 there is one staff; if there is a simultaneous expression, there
650 is more than one staff.  The following example shows a complex
651 expression, but as it begins with a single note it will be set
652 out on a single staff.
653
654 @lilypond[verbatim,quote]
655 \relative c'' {
656   c2 <<c e>>
657   << { e f } { c <<b d>> } >>
658 }
659 @end lilypond
660
661 @node Multiple staves
662 @subsection Multiple staves
663
664 @cindex multiple staves
665 @cindex staves, multiple
666 @cindex context
667 @cindex context, notation
668 @cindex notation context
669
670 @funindex \new Staff
671 @funindex new Staff
672 @funindex Staff
673 @funindex \new
674 @funindex new
675 @funindex Score
676 @funindex Voice
677 @funindex Lyrics
678 @funindex ChordNames
679
680 LilyPond input files are constructed out of music expressions, as
681 we saw in @ref{Music expressions explained}.  If the score begins
682 with simultaneous music expressions, LilyPond creates multiples
683 staves.  However, it is easier to see what happens if we create
684 each staff explicitly.
685
686 To print more than one staff, each piece of music that makes up a
687 staff is marked by adding @code{\new Staff} before it.  These
688 @code{Staff} elements are then combined in parallel with @code{<<}
689 and @code{>>}:
690
691 @lilypond[verbatim,quote]
692 \relative c'' {
693   <<
694     \new Staff { \clef treble c }
695     \new Staff { \clef bass c,, }
696   >>
697 }
698 @end lilypond
699
700 The command @code{\new} introduces a @q{notation context.}  A
701 notation context is an environment in which musical events (like
702 notes or @code{\clef} commands) are interpreted.  For simple
703 pieces, such notation contexts are created automatically.  For
704 more complex pieces, it is best to mark contexts explicitly.
705
706 There are several types of contexts.  @code{Score}, @code{Staff},
707 and @code{Voice} handle melodic notation, while @code{Lyrics} sets
708 lyric texts and @code{ChordNames} prints chord names.
709
710 In terms of syntax, prepending @code{\new} to a music expression
711 creates a bigger music expression.  In this way it resembles the
712 minus sign in mathematics.  The formula @math{(4+5)} is an
713 expression, so @math{-(4+5)} is a bigger expression.
714
715 Time signatures entered in one staff affect all other staves by
716 default.  On the other hand, the key signature of one staff does
717 @emph{not} affect other staves.  This different default behavior
718 is because scores with transposing instruments are more common
719 than polyrhythmic scores.
720
721 @lilypond[verbatim,quote]
722 \relative c'' {
723   <<
724     \new Staff { \clef treble \key d \major \time 3/4 c }
725     \new Staff { \clef bass c,, }
726   >>
727 }
728 @end lilypond
729
730
731
732
733 @node Staff groups
734 @subsection Staff groups
735
736 @cindex piano staff
737 @cindex staff, piano
738 @cindex choir staff
739 @cindex staff, choir
740 @cindex grand staff
741 @cindex staff, grand
742 @cindex staff group
743
744 @funindex PianoStaff
745 @funindex GrandStaff
746 @funindex ChoirStaff
747
748 Music Glossary: @rglos{brace}.
749
750 Piano music is typeset in two staves connected by a
751 @notation{brace}.
752 Printing such a staff is similar to the polyphonic example in
753 @ref{Multiple staves}.  However, now this entire expression is
754 inserted inside a @code{PianoStaff}:
755
756 @example
757 \new PianoStaff <<
758   \new Staff @dots{}
759   \new Staff @dots{}
760 >>
761 @end example
762
763 Here is a small example:
764
765 @lilypond[verbatim,quote]
766 \relative c'' {
767   \new PianoStaff <<
768     \new Staff { \time 2/4 c4 e g g, }
769     \new Staff { \clef bass c,, c' e c }
770   >>
771 }
772 @end lilypond
773
774 Other staff groupings are introduced with @code{\new GrandStaff},
775 suitable for orchestral scores, and @w{@code{\new ChoirStaff}},
776 suitable for vocal scores.  These staff groups each form another
777 type of context, one that generates the brace at the left end of
778 every system and also controls the extent of bar lines.
779
780
781 @seealso
782 Notation Reference: @ruser{Keyboard and other multi-staff
783 instruments},
784 @ruser{Displaying staves}.
785
786
787 @node Combining notes into chords
788 @subsection Combining notes into chords
789
790 @cindex chords
791 @cindex note durations in chords
792
793 @funindex <
794 @funindex >
795 @funindex < ... >
796
797 Music Glossary: @rglos{chord}.
798
799 We saw earlier how notes can be combined into @notation{chords} by
800 indicating they are simultaneous by enclosing them in double angle
801 brackets.  However, the normal way of indicating a chord is to
802 surround the pitches with @emph{single} angle brackets.  Note that
803 all the notes in a chord must have the same duration, and that the
804 duration is placed after the closing bracket.
805
806 @lilypond[verbatim,quote,relative=2]
807 r4 <c e g>4 <c f a>2
808 @end lilypond
809
810 Think of chords as almost equivalent to single notes:
811 almost everything you can attach to a single note can be attached
812 to a chord, and everything must go @emph{outside} the angle
813 brackets.  For example, you can combine markings like beams and
814 ties with chords.  They must be placed outside the angle brackets.
815
816 @lilypond[verbatim,quote,relative=2]
817 r4 <c e g>8[ <c f a>]~ <c f a>2
818 r4 <c e g>8( <c e g>\> <c e g>4 <c f a>\!)
819 @end lilypond
820
821
822 @node Single staff polyphony
823 @subsection Single staff polyphony
824
825 @cindex polyphony
826 @cindex multiple voices
827 @cindex voices, more on one staff
828 @cindex single staff polyphony
829 @cindex spacer rest
830 @cindex rest, spacer
831
832 @funindex << ... \\ ... >>
833 @funindex <<
834 @funindex \\
835 @funindex >>
836
837 Polyphonic music in lilypond, while not difficult, uses concepts
838 that we haven't discussed yet, so we're not going to introduce
839 them here. Instead, the following sections introduce these concepts
840 and explain them thoroughly.
841
842 @seealso
843 Learning Manual: @ref{Voices contain music}.
844
845 Notation Reference: @ruser{Simultaneous notes}.
846
847 @node Songs
848 @section Songs
849
850 This section introduces vocal music and simple song sheets.
851
852 @menu
853 * Setting simple songs::
854 * Aligning lyrics to a melody::
855 * Lyrics to multiple staves::
856 @end menu
857
858
859 @node Setting simple songs
860 @subsection Setting simple songs
861
862 @cindex lyrics
863 @cindex songs
864
865 @funindex \addlyrics
866 @funindex addlyrics
867
868 Music Glossary: @rglos{lyrics}.
869
870 Here is the start of the melody to a nursery
871 rhyme, @notation{Girls and boys come out to play}:
872
873 @lilypond[verbatim,quote]
874 \relative c'' {
875   \key g \major
876   \time 6/8
877   d4 b8 c4 a8 d4 b8 g4
878 }
879 @end lilypond
880
881 The @notation{lyrics} can be set to these notes, combining both
882 with the @code{\addlyrics} keyword.  Lyrics are entered by
883 separating each syllable with a space.
884
885 @lilypond[verbatim,quote]
886 <<
887   \relative c'' {
888     \key g \major
889     \time 6/8
890     d4 b8 c4 a8 d4 b8 g4
891   }
892   \addlyrics {
893     Girls and boys come out to play,
894   }
895 >>
896 @end lilypond
897
898 Note the curly brackets delimiting both the music and the lyrics.
899 It is essential that the final syllable is separated from the
900 terminating curly bracket by a space or a newline, or it will be
901 assumed to be part of the syllable, giving rise to an obscure
902 error, see @rprogram{Apparent error in ../ly/init.ly}.
903
904 Note also the double angle brackets @w{@code{<< ... >>}} around the
905 whole piece to show that the music and lyrics are to occur at the
906 same time.
907
908 @node Aligning lyrics to a melody
909 @subsection Aligning lyrics to a melody
910
911 @cindex melisma
912 @cindex extender line
913 @cindex hyphens
914 @cindex underscore
915 @cindex lyrics, aligning
916 @cindex aligning lyrics
917 @cindex lyrics, multi-syllable words
918 @cindex words with multiple syllables in lyrics
919
920 Music Glossary: @rglos{melisma}, @rglos{extender line}.
921
922 The next line in the nursery rhyme is @notation{The moon doth
923 shine as bright as day}.  Let's extend it:
924
925 @lilypond[verbatim,quote]
926 <<
927   \relative c'' {
928     \key g \major
929     \time 6/8
930     d4 b8 c4 a8 d4 b8 g4
931     g8 a4 b8 c b a d4 b8 g4.
932   }
933   \addlyrics {
934     Girls and boys come out to play,
935     The moon doth shine as bright as day;
936   }
937 >>
938 @end lilypond
939
940 We see the extra lyrics do not align properly with the notes.  The
941 word @notation{shine} should be sung on two notes, not one.  This
942 is called a @notation{melisma}, a single syllable sung to more
943 than one note.  There are several ways to spread a syllable over
944 multiple notes, the simplest being to add a slur across them, for
945 details, see @ref{Ties and slurs}:
946
947 @lilypond[verbatim,quote]
948 <<
949   \relative c'' {
950     \key g \major
951     \time 6/8
952     d4 b8 c4 a8 d4 b8 g4
953     g8 a4 b8 c( b) a d4 b8 g4.
954   }
955   \addlyrics {
956     Girls and boys come out to play,
957     The moon doth shine as bright as day;
958   }
959 >>
960 @end lilypond
961
962 The words now line up correctly with the notes, but the automatic
963 beaming for the notes above @notation{shine as} does not look right.
964 We can correct this by inserting manual beaming commands to override
965 the automatic beaming here, for details, see @ref{Automatic and
966 manual beams}.
967
968 @lilypond[verbatim,quote]
969 <<
970   \relative c'' {
971     \key g \major
972     \time 6/8
973     d4 b8 c4 a8 d4 b8 g4
974     g8 a4 b8 c([ b]) a d4 b8 g4.
975   }
976   \addlyrics {
977     Girls and boys come out to play,
978     The moon doth shine as bright as day;
979   }
980 >>
981 @end lilypond
982
983 As an alternative to using slurs, the melismata may be indicated
984 in just the lyrics by using an underscore @code{_} for each note
985 that should be included in the melisma:
986
987 @lilypond[verbatim,quote]
988 <<
989   \relative c'' {
990     \key g \major
991     \time 6/8
992     d4 b8 c4 a8 d4 b8 g4
993     g8 a4 b8 c[ b] a d4 b8 g4.
994   }
995   \addlyrics {
996     Girls and boys come out to play,
997     The moon doth shine _ as bright as day;
998   }
999 >>
1000 @end lilypond
1001
1002 If a syllable extends over several notes or a single very long
1003 note an @notation{extender line} is usually drawn from the
1004 syllable extending under all the notes for that syllable.  It is
1005 entered as two underscores @code{__}.  Here is an example from the
1006 first three bars of @notation{Dido's Lament}, from Purcell's
1007 @notation{Dido and Ã†neas}:
1008
1009 @lilypond[verbatim,quote]
1010 <<
1011   \relative c'' {
1012     \key g \minor
1013     \time 3/2
1014     g2 a bes bes( a)
1015     b c4.( bes8 a4. g8 fis4.) g8 fis1
1016   }
1017   \addlyrics {
1018     When I am laid,
1019     am laid __ in earth,
1020   }
1021 >>
1022 @end lilypond
1023
1024 None of the examples so far have involved words containing more
1025 than one syllable.  Such words are usually split one syllable to a
1026 note, with hyphens between syllables.  Such hyphens are entered as
1027 two dashes, resulting in a centered hyphen between the syllables.
1028 Here is an example showing this and everything we have learned so
1029 far about aligning lyrics to notes.
1030
1031 @c no ragged-right here because otherwise the hyphens get lost,
1032 @c but the example is long enough to avoid looking strange.
1033 @lilypond[verbatim,quote,noragged-right]
1034 <<
1035   \relative c' {
1036     \key g \major
1037     \time 3/4
1038     \partial 4
1039     d4 g4 g a8( b) g4 g4
1040     b8( c) d4 d e4 c2
1041   }
1042   \addlyrics {
1043     A -- way in a __ man -- ger,
1044     no __ crib for a bed, __
1045   }
1046 >>
1047 @end lilypond
1048
1049 Some lyrics, especially those in Italian, require the opposite:
1050 setting more than one syllable to a single note.  This is
1051 achieved by linking the syllables together with a single
1052 underscore @code{_} (with no spaces), or enclosing them in quotes.
1053 Here's an example from Rossini's @notation{Figaro}, where
1054 @notation{al} has to be sung on the same note as the @notation{go} of
1055 @notation{Largo} in Figaro's aria @notation{Largo al factotum}:
1056
1057 @c no ragged-right here because otherwise the hyphens get lost,
1058 @c but the example is long enough to avoid looking strange.
1059 @lilypond[verbatim,quote,noragged-right]
1060 <<
1061   \relative c' {
1062     \clef bass
1063     \key c \major
1064     \time 6/8
1065     c4.~ c8 d b c([ d]) b c d b c
1066   }
1067   \addlyrics {
1068     Lar -- go_al fac -- to -- tum del -- la cit -- tà
1069   }
1070 >>
1071 @end lilypond
1072
1073
1074 @seealso
1075 Notation Reference: @ruser{Vocal music}.
1076
1077
1078 @node Lyrics to multiple staves
1079 @subsection Lyrics to multiple staves
1080
1081 @cindex lyrics and multiple staves
1082 @cindex multiple staves and lyrics
1083
1084 The simple approach using @code{\addlyrics} can be used for
1085 placing lyrics under more than one staff.  Here is an
1086 example from Handel's @notation{Judas Maccabæus}:
1087
1088 @lilypond[verbatim,quote]
1089 <<
1090   \relative c'' {
1091     \key f \major
1092     \time 6/8
1093     \partial 8
1094     c8 c([ bes]) a a([ g]) f f'4. b, c4.~ c4
1095   }
1096   \addlyrics {
1097     Let flee -- cy flocks the hills a -- dorn, __
1098   }
1099   \relative c' {
1100     \key f \major
1101     \time 6/8
1102     \partial 8
1103     r8 r4. r4 c8 a'([ g]) f f([ e]) d e([ d]) c bes'4
1104   }
1105   \addlyrics {
1106     Let flee -- cy flocks the hills a -- dorn,
1107   }
1108 >>
1109 @end lilypond
1110
1111 Scores any more complex than this simple example are better
1112 produced by separating out the score structure from the notes and
1113 lyrics with variables.  These are discussed in @ref{Organizing
1114 pieces with variables}.
1115
1116
1117 @seealso
1118 Notation Reference: @ruser{Vocal music}.
1119
1120
1121 @node Final touches
1122 @section Final touches
1123
1124 This is the final section of the tutorial; it demonstrates how to
1125 add the final touches to simple pieces, and provides an
1126 introduction to the rest of the manual.
1127
1128 @menu
1129 * Organizing pieces with variables::
1130 * Version number::
1131 * Adding titles::
1132 * Absolute note names::
1133 * After the tutorial::
1134 @end menu
1135
1136
1137 @node Organizing pieces with variables
1138 @subsection Organizing pieces with variables
1139
1140 @cindex variables
1141 @cindex variables, defining
1142 @cindex identifiers
1143 @cindex macros
1144 @cindex assigning variables
1145 @cindex using variables
1146 @cindex variables, using
1147 @cindex variables, characters allowed in
1148 @cindex characters allowed in variables
1149
1150 When all of the elements discussed earlier are combined to produce
1151 larger files, the music expressions get a lot bigger.  In
1152 polyphonic music with many staves, the input files can become very
1153 confusing.  We can reduce this confusion by using
1154 @emph{variables}.
1155
1156 With variables (also known as identifiers or macros), we can break
1157 up complex music expressions.  A variable is assigned as
1158 follows:
1159
1160 @example
1161 namedMusic = @{ @dots{} @}
1162 @end example
1163
1164 The contents of the music expression @code{namedMusic} can be used
1165 later by placing a backslash in front of the name
1166 (@code{\namedMusic}, just like a normal LilyPond command).
1167
1168 @lilypond[verbatim,quote]
1169 violin = \new Staff {
1170   \relative c'' {
1171     a4 b c b
1172   }
1173 }
1174 cello = \new Staff {
1175   \relative c {
1176     \clef bass
1177     e2 d
1178   }
1179 }
1180 {
1181   <<
1182     \violin
1183     \cello
1184   >>
1185 }
1186 @end lilypond
1187
1188 @noindent
1189 The name of a variable must have alphabetic characters only, no
1190 numbers, underscores, or dashes.
1191
1192 Variables must be defined @emph{before} the main music
1193 expression, but may be used as many times as required anywhere after
1194 they have been defined.  They may even be used in a later definition
1195 of another variable, giving a way of shortening the input if a
1196 section of music is repeated many times.
1197
1198 @lilypond[verbatim,quote]
1199 tripletA = \times 2/3 { c,8 e g }
1200 barA = { \tripletA \tripletA \tripletA \tripletA }
1201
1202 \relative c'' {
1203  \barA \barA
1204 }
1205 @end lilypond
1206
1207 Variables may be used for many other types of objects in
1208 the input.  For example,
1209
1210 @example
1211 width = 4.5\cm
1212 name = "Wendy"
1213 aFivePaper = \paper @{ paperheight = 21.0 \cm @}
1214 @end example
1215
1216 Depending on its contents, the variable can be used in different
1217 places.  The following example uses the above variables:
1218
1219 @example
1220 \paper @{
1221   \aFivePaper
1222   line-width = \width
1223 @}
1224 @{
1225   c4^\name
1226 @}
1227 @end example
1228
1229
1230 @node Version number
1231 @subsection Version number
1232
1233 @cindex versioning
1234 @cindex version
1235 @cindex version number
1236 @cindex upgrades
1237 @cindex future upgrades
1238 @cindex updating files
1239 @cindex files, updating
1240
1241 @funindex \version
1242 @funindex version
1243 @funindex convert-ly
1244
1245 The @code{\version} statement records the version of LilyPond that
1246 was used to write the file:
1247
1248 @example
1249 \version @w{"@version{}"}
1250 @end example
1251
1252 @noindent
1253 By convention, this is placed at the top of your LilyPond file.
1254
1255 These annotations make future upgrades of LilyPond go more
1256 smoothly.  Changes in the syntax are handled with a special
1257 program, @command{convert-ly}, and it uses @code{\version} to
1258 determine what rules to apply.  For details, see
1259 @rprogram{Updating files with convert-ly}.
1260
1261
1262 @node Adding titles
1263 @subsection Adding titles
1264
1265 @cindex title
1266 @cindex headers
1267 @cindex header block
1268
1269 @funindex \header
1270 @funindex header
1271
1272 The title, composer, opus number, and similar information are
1273 entered in the @code{\header} block.  This exists outside of the
1274 main music expression; the @code{\header} block is usually placed
1275 underneath the version number.
1276
1277 @example
1278 \version @w{"@version{}"}
1279 \header @{
1280   title = "Symphony"
1281   composer = "Me"
1282   opus = "Op. 9"
1283 @}
1284
1285 @{
1286   @dots{} music @dots{}
1287 @}
1288 @end example
1289
1290 When the file is processed, the title and composer are printed
1291 above the music.  More information on titling can be found in
1292 @ruser{Creating titles}.
1293
1294
1295 @node Absolute note names
1296 @subsection Absolute note names
1297
1298 @cindex note names
1299 @cindex note names, absolute
1300 @cindex absolute mode
1301 @cindex absolute values for pitches
1302 @cindex pitches, absolute values
1303 @cindex absolute note names
1304
1305 So far we have always used @code{\relative} to define pitches.
1306 This is the easiest way to enter most music, but another way of
1307 defining pitches exists: absolute mode.
1308
1309 If you omit the @code{\relative}, LilyPond treats all pitches as
1310 absolute values.  A @code{c'} will always mean middle C, a
1311 @code{b} will always mean the note one step below middle C, and a
1312 @code{g,} will always mean the note on the bottom staff of the
1313 bass clef.
1314
1315 @lilypond[verbatim,quote]
1316 {
1317   \clef bass
1318   c' b g, g,
1319   g, f, f c'
1320 }
1321 @end lilypond
1322
1323 Here is a four-octave scale:
1324
1325 @lilypond[verbatim,quote]
1326 {
1327   \clef bass
1328   c, d, e, f,
1329   g, a, b, c
1330   d e f g
1331   a b c' d'
1332   \clef treble
1333   e' f' g' a'
1334   b' c'' d'' e''
1335   f'' g'' a'' b''
1336   c'''1
1337 }
1338 @end lilypond
1339
1340 As you can see, writing a melody in the treble clef involves a lot
1341 of quote @code{'} marks.  Consider this fragment from Mozart:
1342
1343 @lilypond[verbatim,quote]
1344 {
1345   \key a \major
1346   \time 6/8
1347   cis''8. d''16 cis''8 e''4 e''8
1348   b'8. cis''16 b'8 d''4 d''8
1349 }
1350 @end lilypond
1351
1352 All these quotes makes the input less readable and they are a source
1353 of errors.  With @code{\relative}, the previous example is much
1354 easier to read and type:
1355
1356 @lilypond[verbatim,quote]
1357 \relative c'' {
1358   \key a \major
1359   \time 6/8
1360   cis8. d16 cis8 e4 e8
1361   b8. cis16 b8 d4 d8
1362 }
1363 @end lilypond
1364
1365 If you make a mistake with an octave mark (@code{'} or @code{,})
1366 while working in @code{\relative} mode, it is very obvious -- many
1367 notes will be in the wrong octave.  When working in absolute mode,
1368 a single mistake will not be as visible, and will not be as easy
1369 to find.
1370
1371 However, absolute mode is useful for music which has large
1372 intervals, and is extremely useful for computer-generated LilyPond
1373 files.
1374
1375
1376
1377 @node After the tutorial
1378 @subsection After the tutorial
1379
1380 After finishing the tutorial, you should probably try writing a
1381 piece or two.  Start by adding notes to one of the
1382 @ref{Templates}.  If you need any notation that was not covered in
1383 the tutorial, look at the Notation Reference, starting with
1384 @ruser{Musical notation}.  If you want to write for an instrument
1385 ensemble that is not covered in the templates, take a look at
1386 @ref{Extending the templates}.
1387
1388 Once you have written a few short pieces, read the rest of the
1389 Learning Manual (chapters 3-5).  There's nothing wrong with
1390 reading it now, of course!  However, the rest of the Learning
1391 Manual assumes that you are familiar with LilyPond input.  You may
1392 wish to skim these chapters right now, and come back to them after
1393 you have more experience.
1394
1395 In this tutorial and in the rest of the Learning Manual, there is a
1396 paragraph @strong{See also} at the end of each section, which contains
1397 cross-references to other sections: you should not follow these
1398 cross-references at first reading; when you have read all of the
1399 Learning Manual, you may want to read some sections again and follow
1400 cross-references for further reading.
1401
1402 If you have not done so already, @emph{please} read
1403 FIXME FIXME FIXME
1404 @c @ref{About the documentation}.
1405 There is a lot of information about LilyPond, so
1406 newcomers often do not know where they should look for help.  If
1407 you spend five minutes reading that section carefully, you might
1408 save yourself hours of frustration looking in the wrong places!
1409