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