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