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