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