1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
12 - unless you have a really good reason, use either
13 @l ilypond[quote,ragged-right,verbatim]
15 @l ilypond[quote,ragged-right,verbatim,fragment,relative=2]
17 Don't use any other relative=X commands (make it a non-fragment
18 example), and don't use fragment without relative=2.
19 - use "aes" and "ees" instead of "as" and "aes". I know it's not
20 correct Dutch naming, but let's not confuse people with this until
21 we get to the Basic notation chapter.
26 @c old info that will probably be removed.
28 @c * more details about running lilypond; error messages,
29 @c compiling/viewing (emacs?)
30 @c * where to go from First steps+More basics?
32 @c wherever possible, do not include index entries here; the
33 @c index should point to stuff in the reference manual. -gp
35 @c Your first LilyPond score in 10 minutes?
40 This tutorial starts with an introduction to the LilyPond music
41 language and how to produce printed music. After this first contact we
42 will explain how to create common musical notation.
45 Many people learn programs by trying and fiddling around with the
46 program. This is also possible with LilyPond. If you click on a
47 picture in the HTML version of this manual, you will see the exact
48 LilyPond input that was used to generate that image.
52 @lilypond[quote,ragged-right]
54 c-\markup { \bold \huge { Click here. } }
58 By cutting and pasting everything in the @qq{ly snippet} section, you have a
59 starting template for experiments. If you like learning in this way,
60 you will probably want to print out or bookmark the
61 @ref{Cheat sheet}, which is a table listing of the most common
62 commands for quick reference.
67 * Single staff notation::
68 * Multiple notes at once::
77 This section gives a basic introduction to working with LilyPond.
82 * Working on text files::
83 * How to read the tutorial::
87 @node Compiling a file
88 @subsection Compiling a file
90 The first example demonstrates how to start working with LilyPond. To
91 create sheet music, we write a text file that specifies the
92 notation. For example, if we write
101 the result looks like this
103 @c in this case we don't want verbatim
104 @lilypond[quote,ragged-right]
110 @strong{Warning:} Every piece of LilyPond input needs to have @strong{@{ curly
111 braces @}} placed around the input. The braces should also be
112 surrounded by a space unless they are at the beginning or end of a
113 line to avoid ambiguities. These may be omitted in some examples in this
114 manual, but don't forget them in your own music!
116 @cindex Case sensitive
117 In addition, LilyPond input is @strong{case sensitive}. @code{ @{ c d e @} }
118 is valid input; @code{ @{ C D E @} } will produce an error message.
122 @subheading Entering music and viewing output
124 In this section we will explain what commands to run
125 and how to view or print the output.
127 @subsubheading MacOS X
129 If you double click LilyPond.app, it will open with an example
130 file. Save it, for example, to @file{test.ly} on your Desktop, and
131 then process it with the menu command @samp{Compile > Typeset File}.
132 The resulting PDF file will be displayed on your screen.
134 Be warned that the first time you ever run lilypond will take a minute
135 or two because all of the system fonts have to be analyzed first.
137 For future use of LilyPond, you should begin by selecting "New"
140 @subsubheading Windows
142 On Windows, start up a text-editor@footnote{Any simple or
143 programmer-oriented editor with UTF-8 support will do, for example
144 Notepad. Do not use a word processor, since these insert formatting
145 codes that will confuse LilyPond.} and enter
153 Save it on the desktop as @file{test.ly} and make sure that it is not
154 called @file{test.ly.TXT}. Double clicking @file{test.ly} will process
155 the file and show the resulting PDF file.
160 Begin by opening a terminal window and starting a text editor. For
161 example, you could open an xterm and execute
162 @code{joe}@footnote{There are macro files for VIM addicts, and there
163 is a @code{LilyPond-mode} for Emacs addicts. If they have not been
164 installed already, refer to the file @file{INSTALL.txt}. These
165 easiest editing environment is @file{LilyPondTool}. See
166 @ref{Editor support} for more information.}. In your
167 text editor, enter the following input and save the file as
177 To process @file{test.ly}, proceed as follows
184 You will see something resembling
191 Interpreting music... [1]
192 Preprocessing graphical objects...
193 Calculating line breaks... [2]
194 Layout output to `test.ps'...
195 Converting to `test.pdf'...
199 @cindex Viewing music
202 The result is the file @file{test.pdf} which you can print or view
203 with the standard facilities of your operating system.@footnote{If
204 your system does not have any such tools installed, you can try
205 @uref{http://@/www@/.cs@/.wisc@/.edu/@/~ghost/,Ghostscript}, a freely
206 available package for viewing and printing PDF and PostScript files.}
209 @node Simple notation
210 @subsection Simple notation
212 LilyPond will add some notation elements automatically. In the next
213 example, we have only specified four pitches, but LilyPond has
214 added a clef, time signature, and rhythms.
216 @lilypond[quote,ragged-right,verbatim]
223 This behavior may be altered, but in most cases these automatic values
229 The easiest way to enter notes is by using @code{\relative} mode. In
230 this mode, the @rglos{interval} between the previous note and the
231 current note is assumed to be within a @rglos{fourth}. We begin by
232 entering the most elementary piece of music, a @rglos{scale}.
234 @lilypond[quote,ragged-right,verbatim]
241 The initial note is @rglos{middle C}. Each successive note
242 is within a fourth of the previous note -- in other words, the first
243 @samp{c} is the closest C to middle C. This is followed by the closest
244 D to the previous note. We can create melodies which have larger intervals:
246 @lilypond[quote,ragged-right,verbatim]
254 As you may notice, this example does not start on middle C. The first
255 note -- the @samp{d} -- is the closest D to middle C.
257 To add intervals that are larger than a fourth, we can raise the octave
258 by adding a single quote @code{'} (or apostrophe) to the note name. We can
259 lower the octave by adding a comma @code{,} to the note name.
261 @lilypond[quote,ragged-right,verbatim]
269 To change a note by two (or more!) octaves, we use multiple @code{''} or
270 @code{,,} -- but be careful that you use two single quotes @code{''} and
271 not one double quote @code{"}@tie{}! The initial value in
272 @code{\relative c'} may also be modified like this.
275 @subheading Durations (rhythms)
277 The @rglos{duration} of a note is specified by a number after the note
278 name. @samp{1} for a @rglos{whole note}, @samp{2} for a @rglos{half note},
279 @samp{4} for a @rglos{quarter note} and so on. Beams are added
282 @lilypond[quote,ragged-right,verbatim]
286 a16 a a a a32 a a a a64 a a a a a a a a2
291 If you do not specify a duration, the previous duration is used
292 for the next note. The duration of the first note defaults to a quarter.
294 To create @rglos{dotted notes}, add a dot @samp{.} to the duration number.
296 @lilypond[quote,ragged-right,verbatim]
306 A @rglos{rest} is entered just like a note with the name @samp{r}:
308 @lilypond[quote,ragged-right,verbatim]
316 @subheading Time signature
318 The @rglos{time signature}) can be set with the @code{\time} command:
320 @lilypond[quote,ragged-right,verbatim]
334 The @rglos{clef} can be set using the @code{\clef} command:
336 @lilypond[quote,ragged-right,verbatim]
350 @subheading All together
352 Here is a small example showing all these elements together:
354 @lilypond[quote,ragged-right,verbatim]
366 @item Entering pitches and durations
367 see @ref{Pitches} and @ref{Durations}.
370 @item Time signatures and other timing commands
371 see @ref{Time signature}.
378 @node Working on text files
379 @subsection Working on text files
381 LilyPond input files are treated like files in most programming languages:
382 they are case sensitive, white-space insensitive, expressions are
383 formed with curly braces @{ @}, and comments are denoted with @code{%} or
386 If the previous sentence sounds like nonsense, don't worry! We'll explain
387 what all these terms mean:
391 @cindex Case sensitive
392 @item @strong{Case sensitive}:
393 it matters whether you enter a letter
394 in lower case (i.e. @code{a, b, s, t}) or upper case (i.e.
395 @code{A, B, S, T}). Notes are lower case: @code{ @{ c d e @} }
396 is valid input; @code{ @{ C D E @} } will produce an error message.
398 @item @strong{Whitespace insensitive}:
399 it does not matter how many
400 spaces (or new lines) you add. @code{ @{ c d e @}} means the same thing
401 as @code{ @{ c @ @ @ @ @ d e @} } and
409 Of course, the previous example is hard to read. A good rule of thumb
410 is to indent code blocks with either a tab or two spaces:
417 @item @strong{Expressions:}
418 Every piece of LilyPond input needs to have
419 @strong{@{ curly braces @}} placed around the input. These braces tell
420 LilyPond that the input is a single music expression, just like
421 parenthesis @samp{()} in mathematics. The braces should
422 be surrounded by a space unless they are at the beginning or end of a
423 line to avoid ambiguities.
425 A function (such as @code{\relative @{ @}} ) also counts as a single
430 @cindex block comment
431 @item @strong{Comments}:
432 A comment is a remark for the human reader of the music input; it is
433 ignored while parsing, so it has no effect on the printed output.
434 There are two types of comments. The percent symbol @samp{%}
435 introduces a line comment; anything after @samp{%} on that line is
436 ignored. A block comment marks a whole section of music
437 input as a comment. Anything that is enclosed in @code{%@{} and @code{%@}} is
438 ignored. The following fragment shows possible uses for comments
441 % notes for twinkle twinkle follow
445 This line, and the notes below
446 are ignored, since they are in a
455 There are more tips for constructing input files in
456 @ref{Suggestions for writing LilyPond files}.
459 @node How to read the tutorial
460 @subsection How to read the tutorial
462 As we saw in @ref{Working on text files}, LilyPond input must be
463 surrounded by @{ @} marks or a @code{\relative c'' @{ ... @}}. For the
464 rest of this manual, most examples will omit this.
466 If you are reading the HTML documentation and wish to see the exact
467 exact LilyPond code that was used to create the example, simply click
468 on the picture. If you are not reading the HTML version, you could
469 copy and paste the displayed input, but you @strong{must} add the
470 @code{\relative c'' @{ @}} like this:
474 ... example goes here...
478 Why omit the braces? Most examples
479 in this manual can be inserted into the middle of a longer piece of
480 music. For these examples, it does not make sense to add
481 @code{\relative c'' @{ @}} -- you should not place a @code{\relative}
482 inside another @code{\relative}, so you would not be able to copy
483 a small documentation example and paste it inside a longer piece
487 @node Single staff notation
488 @section Single staff notation
490 This section introduces common notation that is used for one voice
494 * Relative note names::
495 * Accidentals and key signatures::
497 * Articulation and dynamics::
498 * Automatic and manual beams::
499 * Advanced rhythmic commands::
503 @node Relative note names
504 @subsection Relative note names
506 As we saw in @ref{Simple notation}, LilyPond calculates the pitch of
507 each note relative to the previous one@footnote{There is another mode of
508 entering pitches, @ref{Absolute note names}, but in practice relative
509 mode is much easier and safer to use.}. If no extra octave marks
510 (@code{'} and @code{,}) are added, it assumes that each pitch is within
511 a fourth of the previous note.
513 LilyPond examines pitches based on the note names -- in other words,
514 an augmented fourth is @emph{not} the same as a diminished fifth. If we
515 begin at a C, then an F-sharp will be placed a higher than the C, while
516 a G-flat will be placed lower than the C.
518 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
526 @item Relative octaves
527 see @ref{Relative octaves}.
529 see @ref{Octave check}.
535 @node Accidentals and key signatures
536 @subsection Accidentals and key signatures
538 @subheading Accidentals
540 A @rglos{sharp} pitch is made by adding @samp{is} to
541 the name, and a @rglos{flat} pitch by adding @samp{es}. As
542 you might expect, a @rglos{double sharp} or @rglos{double flat} is
543 made by adding @samp{isis} or @samp{eses}@footnote{This syntax
544 derived from note naming conventions in Nordic and Germanic languages,
545 like German and Dutch. To use other names for accidentals, see
546 @ref{Note names in other languages}.}
548 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
549 cis1 ees fisis, aeses
552 @cindex key signature, setting
553 @subheading Key signatures
555 The key signature is set with the command @code{\key} followed by
556 a pitch and @code{\major} or @code{\minor}.
558 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
567 @subheading Warning: key signatures and pitches
569 To determine whether to print an accidental, LilyPond examines the
570 pitches and the key signature. The key signature only effects
571 the @emph{printed} accidentals, not the actual pitches! This is a
572 feature that often causes confusion to newcomers, so let us explain it
575 LilyPond makes a sharp distinction between musical content and
576 layout. The alteration (flat, natural or sharp) of a note is part of
577 the pitch, and is therefore musical content. Whether an accidental (a
578 @emph{printed} flat, natural or sharp sign) is printed in front of the
579 corresponding note is a question of layout. Layout is something that
580 follows rules, so accidentals are printed automatically according to
581 those rules. The pitches in your music are works of art, so they will
582 not be added automatically, and you must enter what you want to hear.
586 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
592 No note has a printed accidental, but you must still add the @samp{is} to
593 @code{cis} and @code{fis}.
595 The code @samp{e} does not mean @qq{print a black dot just below the
596 first line of the staff.} Rather, it means: @qq{there is a note with
597 pitch E-natural.} In the key of A-flat major, it @emph{does} get an
600 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
605 Adding all alterations explicitly might require a little more effort
606 when typing, but the advantage is that transposing is easier, and
607 accidentals can be printed according to different conventions. See
608 @ref{Automatic accidentals} for some examples how accidentals can be printed
609 according to different rules.
615 see @ref{Accidentals} and @ref{Automatic accidentals}.
617 see @ref{Key signature}.
623 @subsection Ties and slurs
627 A @rglos{tie} is created by appending a tilde @samp{~} to the first
630 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
638 A @rglos{slur} is a curve drawn across many notes. The starting note
639 and ending note are marked with @samp{(} and @samp{)} respectively.
641 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
642 d4( c16) cis( d e c cis d) e( d4)
645 @cindex slurs, phrasing
646 @cindex phrasing slurs
647 @subheading Phrasing slurs
649 @cindex phrasing slurs
650 Slurs to indicate longer phrasing can be entered with @code{\(} and
651 @code{\)}. You can have both legato slurs and phrasing slurs at the
652 same time, but you cannot have simultaneous slurs or simultaneous
655 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
656 a8(\( ais b c) cis2 b'2 a4 cis,\)
661 @cindex slurs versus ties
662 @subheading Warnings: slurs vs. ties
664 A slur looks like a @rglos{tie}, but it has a different meaning. A
665 tie simply makes the first note longer, and can only be used on
666 pairs of notes with the same pitch. Slurs indicate the articulations
667 of notes, and can be used on larger groups of notes. Slurs and ties
670 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
671 c2~( c8 fis fis4 ~ fis2 g2)
682 see @ref{Phrasing slurs}.
687 @node Articulation and dynamics
688 @subsection Articulation and dynamics
693 @subheading Articulations
695 Common @rglos{articulations} can be added to a note using a dash @samp{-}
696 and a single character:
698 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
699 c-. c-- c-> c-^ c-+ c-_
703 @subheading Fingerings
704 Similarly, fingering indications can be added to a note using a dash
705 (@samp{-}) and the digit to be printed:
707 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
711 Articulations and fingerings are usually placed automatically, but you
712 can specify a direction using @samp{^} (up) or @samp{_} (down). You can
713 also use multiple articulations on the same note. However, in most cases
714 it is best to let LilyPond determine the articulation directions.
716 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
717 c_-^1 d^. f^4_2-> e^-_+
721 Dynamic signs are made by adding the markings (with a backslash) to
724 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
732 Crescendi and decrescendi are started with the commands @code{\<} and
733 @code{\>}. An ending dynamic, for example @code{\f}, will finish the
734 (de)crescendo, or the command @code{\!} can be used
736 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
744 see @ref{Articulations}.
746 see @ref{Fingering instructions}.
753 @node Automatic and manual beams
754 @subsection Automatic and manual beams
756 @cindex beams, by hand
757 All @rglos{beam}s are drawn automatically:
759 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
760 a8 ais d ees r d c16 b a8
764 If you do not like the automatic beams, they may be overridden
765 manually. Mark the first note to be beamed with @samp{[} and the last one
768 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
769 a8[ ais] d[ ees r d] a b
775 @item Automatic beams
776 see @ref{Automatic beams}.
778 see @ref{Manual beams}.
783 @node Advanced rhythmic commands
784 @subsection Advanced rhythmic commands
788 @cindex partial measure
789 @subheading Partial measure
791 A pickup (or @rglos{anacrusis}) is entered with the keyword
792 @code{\partial}. It is followed by a duration: @code{\partial 4} is
793 a quarter note pickup and @code{\partial 8} an eighth note.
795 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
804 Tuplets are made with the @code{\times} keyword. It takes two
805 arguments: a fraction and a piece of music. The duration of the piece
806 of music is multiplied by the fraction. Triplets make notes occupy
807 2/3 of their notated duration, so a triplet has 2/3 as its fraction
809 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
810 \times 2/3 { f8 g a }
812 \times 2/3 { f,8 g16 a g a }
819 @subheading Grace notes
821 Grace notes are created with the @code{\grace} command, although they
822 can also be created by prefixing a music expression with the
823 keyword @code{\appoggiatura} or @code{\acciaccatura}
825 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
826 c2 \grace { a32 b} c2
827 c2 \appoggiatura b16 c2
828 c2 \acciaccatura b16 c2
835 see @ref{Grace notes},
839 see @ref{Partial measures}.
844 @node Multiple notes at once
845 @section Multiple notes at once
847 This section introduces having more than one note at the same time:
848 multiple instruments, multiple staves for a single instrument (i.e. piano),
851 Polyphony in music refers to having more than one voice occurring in
852 a piece of music. Polyphony in LilyPond refers to having more than
853 one voice on the same staff.
856 * Music expressions explained::
859 * Single staff polyphony::
860 * Combining notes into chords::
864 @node Music expressions explained
865 @subsection Music expressions explained
867 In LilyPond input files, music is represented by @emph{music
868 expressions}. A single note is a music expression, although it is not
869 valid input all on its own.
871 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
875 Enclosing a group of notes in braces creates a new music expression:
877 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
881 Putting a group of music expressions (e.g. notes) in braces means that
882 are in sequence (i.e. each one follows the previous one). The result
883 is another music expression:
885 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
889 @subheading Simultaneous music expressions: multiple staves
891 This technique is useful for polyphonic music. To enter music
892 with more voices or more staves, we combine expressions in
893 parallel. To indicate that two voices should play at the same time
894 simple enter a simultaneous combination of music expressions. A
895 @q{simultaneous} music expression is formed by enclosing expressions inside
896 @code{<<} and @code{>>}. In the following example, three sequences (all
897 containing two separate notes) are combined simultaneously:
899 @lilypond[quote,ragged-right,verbatim]
909 Note that we have indented each level of the input with a different
910 amount of space. LilyPond does not care how much (or little) space there
911 is at the beginning of a line, but indenting LilyPond code like this makes
912 it much easier for humans to read.
914 @subheading Simultaneous music expressions: single staff
916 To determine the number of staves in a piece, LilyPond looks at the first
917 exression. If it is a single note, there is one staff; if there is a
918 simultaneous expression, there is more than one staff.
920 @lilypond[quote,ragged-right,verbatim]
923 << { e f } { c <<b d>> } >>
928 @cindex music expression
929 @subheading Analogy: mathematical expressions
931 This mechanism is similar to mathematical
932 formulas: a big formula is created by composing small formulas. Such
933 formulas are called expressions, and their definition is recursive so
934 you can make arbitrarily complex and large expressions. For example,
943 ((1 + 2) * 3) / (4 * 5)
946 This is a sequence of expressions, where each expression is contained
947 in the next (larger) one. The simplest expressions are numbers, and larger
948 ones are made by combining expressions with operators (like @samp{+},
949 @samp{*} and @samp{/}) and parentheses. Like mathematical expressions,
950 music expressions can be nested arbitrarily deep, which is necessary
951 for complex music like polyphonic scores.
954 @node Multiple staves
955 @subsection Multiple staves
957 As we saw in @ref{Music expressions explained}, LilyPond input files
958 are constructed out of music expressions. If the score begins with
959 simultaneous music expressions, LilyPond creates multiples staves. However,
960 it is easier to see what happens if we create each staff explicitly.
962 To print more than one staff, each piece of music that makes up a
963 staff is marked by adding @code{\new Staff} before it. These
964 @code{Staff} elements are then combined in parallel with @code{<<} and
967 @lilypond[quote,ragged-right,verbatim]
970 \new Staff { \clef treble c }
971 \new Staff { \clef bass c,, }
976 The command @code{\new} introduces a @q{notation context.} A notation
977 context is an environment in which musical events (like notes or
978 @code{\clef} commands) are interpreted. For simple pieces, such
979 notation contexts are created automatically. For more complex pieces, it
980 is best to mark contexts explicitly.
982 There are several types of contexts. @code{Score}, @code{Staff},
983 and @code{Voice} handle melodic notation, while @code{Lyrics} sets lyric
984 texts and @code{ChordNames} prints chord names.
986 In terms of syntax, prepending @code{\new} to a music expression
987 creates a bigger music expression. In this way it resembles the minus
988 sign in mathematics. The formula @math{(4+5)} is an expression, so
989 @math{-(4+5)} is a bigger expression.
991 Time signatures entered in one staff affects all other staves, but
992 the key signature of one staff does @emph{not} affect other
993 staves@footnote{This behavior may be changed if desired; see
994 @ref{Changing defaults} for details.}.
996 @lilypond[quote,ragged-right,verbatim]
999 \new Staff { \clef treble \time 3/4 c }
1000 \new Staff { \clef bass \key d \major c,, }
1009 @subsection Piano staves
1011 @cindex staff switch, manual
1012 @cindex cross staff voice, manual
1013 Piano music is typeset in two staves connected by a brace. Printing
1014 such a staff is similar to the polyphonic example in @ref{Multiple staves},
1015 but now this entire expression is inserted inside a @code{PianoStaff}:
1024 Here is a small example
1026 @lilypond[quote,ragged-right,verbatim]
1029 \new Staff { \time 2/4 c4 e g g, }
1030 \new Staff { \clef bass c,, c' e c }
1037 See @ref{Piano music}.
1041 @node Single staff polyphony
1042 @subsection Single staff polyphony
1045 @cindex multiple voices
1046 @cindex voices, more -- on a staff
1047 When different melodic lines are combined on a single staff they are
1048 printed as polyphonic voices; each voice has its own stems, slurs and
1049 beams, and the top voice has the stems up, while the bottom voice has
1052 Entering such parts is done by entering each voice as a sequence (with
1053 @code{@{...@}}) and combining these simultaneously, separating the
1054 voices with @code{\\}
1056 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
1063 For polyphonic music typesetting, spacer rests can also be convenient;
1064 these are rests that do not print. They are useful for filling up
1065 voices that temporarily do not play. Here is the same example with a
1066 spacer rest (@samp{s}) instead of a normal rest (@samp{r}),
1068 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
1076 Again, these expressions can be nested arbitrarily.
1078 @lilypond[quote,fragment,verbatim,relative=2,fragment]
1086 { <c g>1 ~ <c g>4 } \\
1094 See @ref{Basic polyphony}.
1098 @node Combining notes into chords
1099 @subsection Combining notes into chords
1102 Chords can be made by surrounding pitches with single angle brackets. Angle
1103 brackets are the symbols @samp{<} and @samp{>}.
1105 @lilypond[quote,fragment,verbatim,relative=2,fragment]
1106 r4 <c e g>4 <c f a>2
1109 You can combine markings like beams and ties with chords. They must
1110 be placed outside the angled brackets
1112 @lilypond[quote,fragment,verbatim,relative=2,fragment]
1113 r4 <c e g>8[ <c f a>]~ <c f a>2
1116 @lilypond[quote,fragment,verbatim,relative=2,fragment]
1117 r4 <c e g>8\>( <c e g> <c e g>4 <c f a>\!)
1124 This section introduces vocal music and simple song sheets.
1132 @node Printing lyrics
1133 @subsection Printing lyrics
1137 Consider a simple melody:
1139 @lilypond[quote,ragged-right,verbatim]
1146 The lyrics can be set to these notes, combining both with the
1147 @code{\addlyrics} keyword. Lyrics are entered by separating each
1148 syllable with a space.
1150 @lilypond[quote,ragged-right,verbatim]
1156 \addlyrics { One day this shall be free }
1161 @cindex extender line
1162 This melody ends on a @rglos{melisma}, a single syllable (@q{free})
1163 sung to more than one note. This is indicated with an @emph{extender
1164 line}. It is entered as two underscores @code{__}:
1166 @lilypond[quote,ragged-right,verbatim]
1172 \addlyrics { One day this shall be free __ }
1176 Similarly, hyphens between words can be entered as two dashes,
1177 resulting in a centered hyphen between two syllables
1179 @c no ragged-right here because otherwise the hypens get lost.
1180 @lilypond[quote,verbatim]
1186 \addlyrics { A -- le -- gri -- a }
1192 More options, such as putting multiple stanzas below a melody, are
1193 discussed in @ref{Vocal music}.
1198 @subsection A lead sheet
1204 @c TODO: revise this, \chords { } is shorter and more intuitive.
1205 @c I need help for this. -gp
1207 In popular music it is common to denote accompaniment with chord names.
1208 Such chords can be entered like notes,
1210 @lilypond[quote,ragged-right,verbatim]
1211 \chordmode { c2 f4. g8 }
1215 Now each pitch is read as the root of a chord instead of a note.
1216 This mode is switched on with @code{\chordmode}
1218 Other chords can be created by adding modifiers after a colon. The
1219 following example shows a few common modifiers
1221 @lilypond[quote,verbatim,ragged-right]
1222 \chordmode { c2 f4:m g4:maj7 gis1:dim7 }
1225 For lead sheets, chords are not printed on staves, but as names on a
1226 line for themselves. This is achieved by using @code{\chords} instead
1227 of @code{\chordmode}. This uses the same syntax as @code{\chordmode},
1228 but renders the notes in a @code{ChordNames} context, with the
1231 @lilypond[quote,verbatim,ragged-right]
1232 \chords { c2 f4.:m g4.:maj7 gis8:dim7 }
1236 When put together, chord names, lyrics and a melody form
1237 a lead sheet, for example,
1239 @lilypond[quote,verbatim,ragged-right]
1240 % this melody needs to be changed. See my new example in 2.4.1. -gp
1242 \chords { r2 c:sus4 f }
1244 r4 c' \times 2/3 { f g g }
1245 \times 2/3 { g4( a2) }
1247 \addlyrics { I want to break free __ }
1251 A complete list of modifiers and other options for layout can be found
1256 @section Final touches
1258 This is the final section of the tutorial; it demonstrates how to add the
1259 final touches to simple pieces, and provides an introduction to the rest
1265 * Absolute note names::
1266 * Organizing pieces with identifiers::
1267 * After the tutorial::
1268 * How to read the manual::
1272 @node Version number
1273 @subsection Version number
1276 The @code{\version} statement marks for which version of LilyPond the file
1277 was written. To mark a file for version 2.10.1, place
1284 at the top of your LilyPond file.
1286 These annotations make future upgrades of LilyPond go more
1287 smoothly. Changes in the syntax are handled with a special program,
1288 @file{convert-ly} (see @ref{Updating files with convert-ly}), and it uses
1289 @code{\version} to determine what rules to apply.
1293 @subsection Adding titles
1295 The title, composer, opus number, and similar information are entered
1296 in the @code{\header} block. This exists outside of the main
1297 music expression; the @code{\header} block is usually placed underneath
1298 the @ref{Version number}.
1309 @dots{} music @dots{}
1313 When the file is processed, the title and composer are printed above
1314 the music. More information on titling can be found in @ref{Creating
1318 @node Absolute note names
1319 @subsection Absolute note names
1321 So far we have always used @code{\relative} to define pitches. This is
1322 the easiest way to enter most music, but another way of defining pitches
1323 exists: absolute mode.
1325 If you omit the @code{\relative}, LilyPond treats all pitches as
1326 absolute values. A @code{c'} will always mean middle C, a @code{b} will
1327 always mean the note one step below middle C, and a @code{g,} will
1328 always mean the note on the bottom staff of the bass clef.
1330 @lilypond[quote,verbatim,ragged-right]
1338 Here is a four-octave scale:
1340 @lilypond[quote,verbatim,ragged-right]
1355 As you can see, writing a melody in the treble clef involves a lot of
1356 quote ' marks. Consider this fragment from Mozart:
1358 @lilypond[quote,verbatim,ragged-right]
1362 cis''8. d''16 cis''8 e''4 e''8
1363 b'8. cis''16 b'8 d''4 d''8
1367 All these quotes makes the input less readable and it is a source of
1368 errors. With @code{\relative}, the previous example is much easier
1371 @lilypond[quote,verbatim,ragged-right]
1375 cis8. d16 cis8 e4 e8
1380 If you make a mistake with an octave mark (@code{'} or @code{,}) while
1381 working in @code{\relative} mode, it is very obvious -- many notes will
1382 be in the wrong octave. When working in absolute mode, a single mistake
1383 will not be as visible, and will not be as easy to find.
1385 However, absolute mode is useful for music which has large intervals, and
1386 is extremely useful for computer-generated LilyPond files.
1389 @node Organizing pieces with identifiers
1390 @subsection Organizing pieces with identifiers
1392 When all of the elements discussed earlier are combined to produce
1393 larger files, the music expressions get a lot bigger. In polyphonic
1394 music with many staves, the input files can become very confusing. We can
1395 reduce this confusion by using @emph{identifiers}.
1397 Identifiers (also known as variables or macros), we can break up
1398 complex music expressions. An identifier is assigned as follows
1401 namedMusic = @{ @dots{} @}
1404 The contents of the music expression @code{namedMusic} can be used
1405 later by placing a backslash in front of the name
1406 (@code{\namedMusic}, just like a normal LilyPond command). Identifiers
1407 must be defined @emph{before} the main music expression.
1409 @lilypond[quote,verbatim,ragged-right]
1410 violin = \new Staff { \relative c'' {
1413 cello = \new Staff { \relative c {
1426 The name of an identifier should have alphabetic characters only: no
1427 numbers, underscores, or dashes.
1429 It is possible to use variables for many other types of objects in the
1435 aFivePaper = \paper @{ paperheight = 21.0 \cm @}
1438 Depending on its contents, the identifier can be used in different
1439 places. The following example uses the above variables:
1450 @node After the tutorial
1451 @subsection After the tutorial
1453 After finishing the tutorial, you should probably try writing a
1454 piece or two. Start with one of the @ref{Templates} and
1455 add notes. If you need any notation that was not covered in the
1456 tutorial, look at the Notation Reference, starting with
1457 @ref{Basic notation}. If you want to write for an instrument
1458 ensemble which is not covered in the templates,
1459 take a look at @ref{Extending the templates}.
1461 Once you have written a few short pieces, read the rest of
1462 the Learning Manual (chapters 3-5). There's nothing wrong
1463 with reading them now, of course! However, the rest of the
1464 Learning Manual assumes that you are familiar with
1465 LilyPond input. You may wish to skim these chapters right
1466 now, and come back to them after you have more experience.
1469 @node How to read the manual
1470 @subsection How to read the manual
1472 As we saw in @ref{How to read the tutorial}, many examples in the
1473 tutorial omitted a @code{\relative c'' @{ ... @}} around the printed
1476 In the rest of the manual, we are much more lax about the
1477 printed examples: sometimes they may have omitted a
1478 @code{\relative c'' @{ ... @}}, but in other times a different initial
1479 pitch may be used (such as @code{c'} or @code{c,,}), and in some cases
1480 the whole example is in absolute note mode! However, ambiguities like
1481 this only exist where the pitches are not important. In any example
1482 where the pitch matters, we have explicitly stated our @code{\relative}
1483 our our absolute-mode @code{@{ @}}.
1485 If you are still confused about the exact LilyPond input that was
1486 used in an example, read the HTML version (if you are not already doing
1487 so) and click on the picture of the music. This will display the exact
1488 input that LilyPond used to generate this manual.