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