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