1 @c -*- coding: utf-8; mode: texinfo; -*-
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.
15 This chapter gives a basic introduction to working with LilyPond.
19 * How to write input files::
20 * How to read the manuals::
23 @node Compiling a file
24 @section Compiling a file
36 @subsection Entering input
40 @cindex example, first
41 @cindex case sensitive
43 @qq{Compiling} is the term used for processing an input file in
44 LilyPond format to produce output file(s). Output files are
45 generally PDF (for printing or viewing), MIDI (for playing), and
46 PNG (for online use). LilyPond input files are simple text files.
48 This example shows a simple input file:
56 The graphical output is:
58 @c in this case we don't want verbatim
65 @warning{Notes and lyrics in LilyPond input must always be
66 surrounded by @w{@strong{@{ curly braces @}}}. The braces
67 should also be surrounded by a space unless they are at the
68 beginning or end of a line to avoid ambiguities. They may
69 be omitted in some examples in this manual, but don't forget them
70 in your own music! For more information about the display of
71 examples in the manual, see @ref{How to read the manuals}.}
73 In addition, LilyPond input is @strong{case sensitive}.
74 @w{@code{@{ c d e @}}} is valid input; @w{@code{@{ C D E @}}} will
75 produce an error message.
80 @subheading Producing output
82 @c TODO: move index entries
86 @cindex running LilyPond under MacOS X
87 @cindex MacOS X, running LilyPond
88 @cindex running LilyPond under Windows
89 @cindex Windows, running LilyPond
90 @cindex running LilyPond under Unix
91 @cindex Unix, running LilyPond
93 The method of producing output depends on your operating system
94 and the program(s) you use.
99 @ref{MacOS X, @sourceimage{logo-macosx,,,}}
100 @ref{MacOS X, MacOS X} (graphical)
103 @ref{Windows, @sourceimage{logo-windows,,,}}
104 @ref{Windows, Microsoft Windows} (graphical)
107 @ref{Command-line, @sourceimage{logo-linux,,,}
108 @sourceimage{logo-freebsd,,,}
109 @sourceimage{logo-macosx,,,}
110 @sourceimage{logo-windows,,,}
112 @ref{Command-line, All operating systems} (command-line)
116 There are several other text editors available with specific
117 support for LilyPond. For more information, see
118 @rweb{Alternate input}.
120 @warning{The first time you ever run LilyPond, it may take a
121 minute or two because all of the system fonts have to be analyzed
122 first. After this, LilyPond will be much faster!}
128 @warning{These instructions assume that you are using the LilyPond
129 application. If you are using any of the programs described in
130 @rweb{Alternate input}, please consult the documentation for
131 those programs if you have any problems.}
134 @subsubheading Step 1. Create your @file{.ly} file
136 Double click the @command{LilyPond.app}, an example file will open.
138 @sourceimage{Learning_Macos_welcome,,,}
140 From the menus along the top left of your screen, select
141 @w{@code{File > Save}}.
143 @sourceimage{Learning_Macos_Save_menu,,,}
145 Choose a name for your file, for example @file{test.ly}.
147 @sourceimage{Learning_Macos_Save_file_with_name,,,}
150 @subsubheading Step 2. Compile (with LilyPad)
152 From the same menus, select
153 @w{@code{Compile > Tyepset}}.
155 @sourceimage{Learning_Macos_Typeset_menu,,,}
157 A new window will open showing a progress log of the compilation
158 of the file you have just saved.
160 @sourceimage{Learning_Macos_Compiling_log,,,}
163 @subsubheading Step 3. View output
165 Once the compilation has finished, a PDF file will be created with
166 the same name as the original file and will be automatically
167 opened in the default PDF viewer and displayed on your screen.
169 @sourceimage{Learning_Macos_pdf_output,,,}
172 @subsubheading Other commands
174 To create new files for LilyPond, begin by selecting
175 @w{@code{File > New}}
177 @sourceimage{Learning_Macos_New_menu,,,}
179 or @w{@code{File > Open}} to open and edit existing files you have
182 @sourceimage{Learning_Macos_Open_menu,,,}
184 You must save any new edits you make to your file before you
185 @w{@code{Compile > Tyepset}} and if the PDF file is not displayed
186 check the window with the progress log for any errors.
188 If you are not using the defualt Preview PDF viewer that comes
189 with the Mac Operating system and you have the PDF file generated
190 from a previous compilation open, then any further compilations
191 may fail to generate an update PDF until you close the original.
197 @warning{These instructions assume that you are using the built-in
198 LilyPad editor. If you are using any of the programs described in
199 @rweb{Alternate input}, please consult the documentation for
200 those programs if you have any problems compiling a file.}
203 @subsubheading Step 1. Create your @file{.ly} file
205 Double-click the @command{LilyPond.app}, an example file will open.
207 @sourceimage{Learning_Win7_Welcome_File_Whole,,,}
209 From the menus that appear alonbg the top of the example file,
210 select @w{@code{File > Save as}}. Do not use the @w{@code{File > Save}}
211 for the example file as this will not work until you have given it a
212 valid Lilypong file name.
214 @sourceimage{Learning_Win7_Save_Menu,,,}
216 Choose a name for your file, for example @file{test.ly}.
218 @sourceimage{Learning_Win7_Save_File_With_Name,,,}
221 @subsubheading Step 2a. Compile (with drag-and-drop)
223 Depending on what you prefer, to compile your file either:
225 Drag-and-drop the file directly onto the LilyPond icon.
227 @sourceimage{Learning_Win7_Open_Dragndrop,,,}
229 Right-click on the file and from the pop-up context menu choose
230 @w{@code{Open with > LilyPond}}.
232 @sourceimage{Learning_Win7_Open_Context_Menu,,,}
235 @subsubheading Step 2b. Compile (with double-clicking)
237 Or simply double-click the @file{test.ly}.
240 @subsubheading Step 3. View output
242 During the compilation of the @file{test.ly} file, a command window
243 will, very briefly open and then close. Three additional files will
244 have been created during this process.
246 @sourceimage{Learning_Win7_All_Files_Created,,,}
248 The PDF file contains the engraved @file{test.ly} file.
250 @sourceimage{Learning_Win7_Pdf_Output,,,}
253 @subsubheading Other commands
255 To create a new file, begin by selecting @w{@code{File > New}} from
256 within any previously created file.
258 @sourceimage{Learning_Win7_New_Menu,,,}
261 or @w{@code{File > Open}} to open and edit any files you have saved
264 @sourceimage{Learning_Win7_Open_Menu,,,}
266 You must save any new edits you make before you compile it and if the
267 PDF file is not created, check the log file that will have been created
268 during the compilation attempt, for any errors.
270 @sourceimage{Learning_Win7_Log_File,,,}
272 This log file is overwritten each time you compile your LilyPond file.
274 The PS file is used internally by LilyPond to create the PDF file and
275 can be ignored. It also gets overwritten each time you compile your
278 If you are viewing your file in a PDF viewer, then you must close the
279 PDF if you wish to make a new compilation as it may fail to create
280 the new PDF while it is still being viewed.
284 @subsection Command-line
286 @warning{These instructions assume that you are familiar with
287 command-line programs. If you are using any of the programs
288 described in @rweb{Alternate input}, please consult the
289 documentation for those programs if you have any problems
293 @subsubheading Step 1. Create your @file{.ly} file
295 Create a text file called @file{test.ly} and enter:
304 @subsubheading Step 2. Compile (with command-line)
306 To process @file{test.ly}, proceed as follows:
313 You will see something resembling:
317 GNU LilyPond @version{}
320 Interpreting music...
321 Preprocessing graphical objects...
322 Finding the ideal number of pages...
323 Fitting music on 1 page...
325 Layout output to `test.ps'...
326 Converting to `test.pdf'...
329 @subsubheading Step 3. View output
331 You may view or print the resulting @file{text.pdf}.
334 @node How to write input files
335 @section How to write input files
341 * Working on input files::
345 @node Simple notation
346 @subsection Simple notation
348 @cindex simple notation
349 @cindex notation, simple
351 LilyPond will add some notation elements automatically. In the
352 next example, we have only specified four pitches, but LilyPond
353 has added a clef, time signature, and rhythms.
355 @lilypond[verbatim,quote]
362 This behavior may be altered, but in most cases these automatic
369 @cindex relative mode
370 @cindex quote, single
372 @cindex accidentals and relative mode
373 @cindex relative mode, and accidentals
380 Music Glossary: @rglos{pitch}, @rglos{interval},
381 @rglos{scale}, @rglos{middle C}, @rglos{octave},
384 The easiest way to enter notes is by using @code{\relative} mode.
385 In this mode, the octave is chosen automatically by assuming the
386 following note is always to be placed closest to the previous
387 note, i.e., it is to be placed in the octave which is within three
388 staff spaces of the previous note. We begin by entering the most
389 elementary piece of music, a @notation{scale}, in which every note
390 is within just one staff space of the previous note.
392 @lilypond[verbatim,quote]
393 % set the starting point to middle C
400 The initial note is @notation{middle C}. Each successive note is
401 placed closest to the previous note -- in other words, the first
402 @code{c} is the closest C to middle C. This is followed by the
403 closest D to the previous note. We can create melodies which have
404 larger intervals, still using only @code{\relative} mode:
406 @lilypond[verbatim,quote]
414 It is not necessary for the first note of the melody to start on
415 the note which specifies the starting pitch. In the previous
416 example, the first note -- the @code{d} -- is the closest D to
419 By adding (or removing) quotes @code{'} or commas @code{,} from
420 the @code{@w{\relative c' @{}} command, we can change the starting
423 @lilypond[verbatim,quote]
424 % one octave above middle C
430 Relative mode can be confusing initially, but is the easiest way
431 to enter most melodies. Let us see how this relative calculation
432 works in practice. Starting from a B, which is on the middle line
433 in a treble clef, you can reach a C, D and E within 3 staff spaces
434 going up, and an A, G and F within 3 staff spaces going down. So
435 if the note following a B is a C, D or E it will be assumed to be
436 above the B, and an A, G or F will be assumed to be below.
438 @lilypond[verbatim,quote]
440 b c % c is 1 staff space up, so is the c above
441 b d % d is 2 up or 5 down, so is the d above
442 b e % e is 3 up or 4 down, so is the e above
443 b a % a is 6 up or 1 down, so is the a below
444 b g % g is 5 up or 2 down, so is the g below
445 b f % f is 4 up or 3 down, so is the f below
449 Exactly the same happens even when any of these notes are
450 sharpened or flattened. @notation{Accidentals} are
451 @strong{totally ignored} in the calculation of relative position.
452 Precisely the same staff space counting is done from a note at any
453 other position on the staff.
455 To add intervals that are larger than three staff spaces, we can
456 raise the @notation{octave} by adding a single quote @code{'} (or
457 apostrophe) to the note name. We can lower the octave by adding a
458 comma @code{,} to the note name.
460 @lilypond[verbatim,quote]
468 To change a note by two (or more!) octaves, we use multiple
469 @code{''} or @code{,,} -- but be careful that you use two single
470 quotes @code{''} and not one double quote @code{"}@tie{}! The
471 initial value in @code{@w{\relative c'}} may also be modified like
473 @c " - keeps quotes in order for context-sensitive editor -td
475 @subheading Durations (rhythms)
477 @cindex note durations
484 @cindex notating durations
486 Music Glossary: @rglos{beam}, @rglos{duration},
487 @rglos{whole note}, @rglos{half note}, @rglos{quarter note},
490 The @notation{duration} of a note is specified by a number after
491 the note name: @code{1} for a @notation{whole note}, @code{2} for
492 a @notation{half note}, @code{4} for a @notation{quarter note} and
493 so on. @notation{Beams} are added automatically.
495 If you do not specify a duration, the previous duration is used
496 for the next note. The duration of the first note defaults to a
499 @lilypond[verbatim,quote]
503 a16 a a a a32 a a a a64 a a a a a a a a2
507 To create @notation{dotted notes}, add a dot @code{.} to the
508 duration number. The duration of a dotted note must be stated
509 explicitly (i.e., with a number).
511 @lilypond[verbatim,quote]
522 @cindex notating rests
524 Music Glossary: @rglos{rest}.
526 A @notation{rest} is entered just like a note with the name
529 @lilypond[verbatim,quote]
537 @subheading Time signature
539 @cindex time signature
544 Music Glossary: @rglos{time signature}.
546 The @notation{time signature} can be set with the @code{\time}
549 @lilypond[verbatim,quote]
572 Music Glossary: @rglos{clef}.
574 The @notation{clef} can be set using the @code{\clef} command:
576 @lilypond[verbatim,quote]
590 @subheading All together
592 Here is a small example showing all these elements together:
594 @lilypond[verbatim,quote]
605 Notation Reference: @ruser{Writing pitches},
606 @ruser{Writing rhythms}, @ruser{Writing rests},
607 @ruser{Time signature}, @ruser{Clef}.
610 @node Working on input files
611 @subsection Working on input files
614 @cindex braces, curly
617 @cindex comment, line
618 @cindex block comment
619 @cindex comment, line
620 @cindex case sensitive
621 @cindex whitespace insensitive
626 @funindex %@{ ... %@}
628 LilyPond input files are similar to source files in many common
629 programming languages. They are case sensitive, and white-space
630 is generally ignored. Expressions are formed with curly braces
631 @{ @}, and comments are denoted with @code{%} or
632 @w{@code{%@{ ... %@}}}.
634 If the previous sentences sound like nonsense, don't worry! We'll
635 explain what all these terms mean:
640 @strong{Case sensitive}:
641 it matters whether you enter a letter in lower case (e.g.
642 @w{@code{a, b, s, t}}) or upper case (e.g. @w{@code{A, B, S, T}}).
643 Notes are lower case: @w{@code{@{ c d e @}}} is valid input;
644 @w{@code{@{ C D E @}}} will produce an error message.
647 @strong{Whitespace insensitive}:
648 it does not matter how many spaces (or tabs or new lines) you add.
649 @w{@code{@{ c d e @}}} means the same thing as
650 @w{@code{@{ c @tie{}} @tie{} @tie{} d e @}} and:
658 Of course, the previous example is hard to read. A good rule of
659 thumb is to indent code blocks with either a tab or two spaces:
667 However, whitespace @emph{is} required to separate many syntactical
668 elements from others. In other words, whitespace can always be
669 @emph{added}, but it cannot be @emph{eliminated}. As missing
670 whitespace can give rise to strange errors it is advisable to
671 always insert whitespace before and after every syntactic element,
672 for example, before and after every curly brace.
675 @strong{Expressions}:
676 every piece of LilyPond input needs to have @strong{@{ curly
677 braces @}} placed around the input. These braces tell LilyPond
678 that the input is a single music expression, just like parentheses
679 @code{()} in mathematics. The braces should be surrounded by a
680 space unless they are at the beginning or end of a line to avoid
683 A LilyPond command followed by a simple expression in braces (such
684 as @w{@code{\relative @{ @}}}) also counts as a single music
689 @cindex block comment
692 a comment is a remark for the human reader of the music input; it
693 is ignored while parsing, so it has no effect on the printed
694 output. There are two types of comments. The percent symbol
695 @code{%} introduces a line comment; anything after @code{%} on
696 that line is ignored. By convention, a line comment is placed
697 @emph{above} the code it refers to.
701 % this comment refers to the Bs
705 A block comment marks a whole section of music input as a comment.
706 Anything that is enclosed in @code{%@{} and @code{%@}} is ignored.
707 However, block comments do not @q{nest}. This means that you
708 cannot place a block comment inside another block comment. If you
709 try, the first @code{%@}} will terminate @emph{both} block
710 comments. The following fragment shows possible uses for
714 % notes for twinkle twinkle follow
718 This line, and the notes below are ignored,
719 since they are in a block comment.
728 @node How to read the manuals
729 @section How to read the manuals
735 * Clickable examples::
736 * Keyboard navigation::
737 * Overview of manuals::
741 @node Omitting braces
742 @subsection Omitting braces
745 @cindex how to read the manual
746 @cindex manual, reading
747 @cindex reading the manual
748 @cindex examples, clickable
749 @cindex clickable examples
750 @cindex tips for constructing files
752 @cindex constructing files, tips
753 @cindex files, tips for constructing
755 LilyPond input must be surrounded by @{ @} marks or a
756 @code{@w{\relative c'' @{ ... @}}}, as we saw in @ref{Working on
757 input files}. For the rest of this manual, most examples will
758 omit this. To replicate the examples, you may copy and paste the
759 displayed input, but you @strong{must} add the
760 @code{@w{\relative c'' @{ @}}} like this:
764 ... example goes here...
768 Why omit the braces? Most examples in this manual can be inserted
769 into the middle of a longer piece of music. For these examples,
770 it does not make sense to add @code{@w{\relative c'' @{ @}}} --
771 you should not place a @code{\relative} inside another
772 @code{\relative}! If we included @code{@w{\relative c'' @{ @}}}
773 around every example, you would not be able to copy a small
774 documentation example and paste it inside a longer piece of your
775 own. Most people want to add material to an existing piece, so we
776 format the manual this way.
779 @node Clickable examples
780 @subsection Clickable examples
782 @warning{This features is only available in the HTML manuals.}
784 Many people learn programs by trying and fiddling around with the
785 program. This is also possible with LilyPond. If you click on a
786 picture in the HTML version of this manual, you will see the exact
787 LilyPond input that was used to generate that image. Try it on
793 c-\markup { \bold \huge { Click here. } }
797 By cutting and pasting everything in the @qq{ly snippet} section,
798 you have a starting template for experiments. To see exactly the
799 same output (line-width and all), copy everything from @qq{Start
800 cut-&-pastable section} to the bottom of the file.
803 @node Keyboard navigation
804 @subsection Keyboard navigation
806 @warning{This features is only available in the HTML manuals.}
808 @c TODO: once this is figured out, insert it here.
810 We are currently working on this feature.
813 @node Overview of manuals
814 @subsection Overview of manuals
816 There is a lot of documentation for LilyPond. New users are
817 sometimes confused about what part(s) they should read, and
818 occasionally skip over reading vital portions.
820 @warning{Please do not skip over important parts of the
821 documentation. You will find it much harder to understand later
827 @strong{Before trying to do @emph{anything}}: read the Learning
828 manual's @ref{Tutorial}, and @ref{Common notation}. If you
829 encounter musical terms which you do not recognize, please look
830 them up in the @rglosnamed{Top, Glossary}.
833 @strong{Before trying to write a complete piece of music}: read
834 the Learning manual's @ref{Fundamental concepts}. After that, you
835 may want to look in relevant sections of the
836 @rusernamed{Top, Notation reference}.
839 @strong{Before trying to change the default output}: read the
840 Learning manual's @ref{Tweaking output}.
843 @strong{Before undertaking a large project}: read Usage document's
844 @rprogram{Suggestions for writing files}.