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