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