]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/learning/tutorial.itely
use trap to remove tmp directory on failure to avoid hiding mpost
[lilypond.git] / Documentation / learning / tutorial.itely
index 61a27a404f9ab74b98705a854ae018b112f02bf0..6752a3bc409366b9317e494245a37decb959741a 100644 (file)
@@ -4,10 +4,13 @@
     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
 
     When revising a translation, copy the HEAD committish of the
-    version that you are working on.  See TRANSLATION for details.
+    version that you are working on.  For details, see the Contributors'
+    Guide, node Updating translation committishes..
 @end ignore
 
-@c \version "2.12.0"
+@include included/generating-output.itexi
+
+@c \version "2.14.0"
 
 @node Tutorial
 @chapter Tutorial
 This chapter gives a basic introduction to working with LilyPond.
 
 @menu
-* Compiling a file::            
-* How to write input files::    
-* How to read the manuals::     
+* Compiling a file::
+* How to write input files::
+* Dealing with errors::
+* How to read the manuals::
 @end menu
 
 @node Compiling a file
 @section Compiling a file
 
-FIXME: insert text
+This section introduces @qq{compiling}---the processing of
+LilyPond input files (written by you) to produce output files.
 
 @menu
-* Entering input::              
-* MacOS X::                     
-* Windows::                     
-* Command-line::                
+* Entering input::
+* MacOS X::
+* Windows::
+* Command-line::
 @end menu
 
 @node Entering input
@@ -40,23 +45,21 @@ FIXME: insert text
 @cindex example, first
 @cindex case sensitive
 
-@qq{Compiling} is the term used for processing an input file
-in LilyPond format to produce a file which can be printed and
-(optionally) a MIDI file which can be played.  LilyPond input
-files are simple text files.  The first example
-shows what a simple input file looks like.
+@qq{Compiling} is the term used for processing an input file in
+LilyPond format to produce output file(s).  Output files are
+generally PDF (for printing or viewing), MIDI (for playing), and
+PNG (for online use).  LilyPond input files are simple text files.
 
-To create sheet music, we write an input file that specifies the
-notation.  For example, if we write:
+This example shows a simple input file:
 
 @example
+\version "@w{@version{}}"
 @{
   c' e' g' e'
 @}
 @end example
 
-@noindent
-the result looks like this:
+The graphical output is:
 
 @c  in this case we don't want verbatim
 @lilypond[quote]
@@ -68,33 +71,26 @@ the result looks like this:
 @warning{Notes and lyrics in LilyPond input must always be
 surrounded by @w{@strong{@{ curly braces @}}}.  The braces
 should also be surrounded by a space unless they are at the
-beginning or end of a line to avoid ambiguities.  The braces may
+beginning or end of a line to avoid ambiguities.  They may
 be omitted in some examples in this manual, but don't forget them
 in your own music!  For more information about the display of
 examples in the manual, see @ref{How to read the manuals}.}
 
 In addition, LilyPond input is @strong{case sensitive}.
-@w{@code{@{ c d e @}}} is valid input; @w{@code{@{ C D E @}}} will
+@w{@samp{@{ c d e @}}} is valid input; @w{@samp{@{ C D E @}}} will
 produce an error message.
 
 
 @smallspace
 
-@subheading Viewing output
+@subheading Producing output
 
-@c TODO: move index entries
 @cindex PDF file
 @cindex viewing music
 @cindex text editors
-@cindex running LilyPond under MacOS X
-@cindex MacOS X, running LilyPond
-@cindex running LilyPond under Windows
-@cindex Windows, running LilyPond
-@cindex running LilyPond under Unix
-@cindex Unix, running LilyPond
 
-Producing output depends on your operating system and the
-program(s) you use.
+The method of producing output depends on your operating system
+and the program(s) you use.
 
 @itemize
 
@@ -116,9 +112,9 @@ program(s) you use.
 
 @end itemize
 
-There are several other text editors available with better support
-for LilyPond.  For more information, see
-@rweb{Alternate input}.
+There are several other text editors available with specific
+support for LilyPond.  For more information, see
+@rweb{Easier editing}.
 
 @warning{The first time you ever run LilyPond, it may take a
 minute or two because all of the system fonts have to be analyzed
@@ -128,110 +124,38 @@ first.  After this, LilyPond will be much faster!}
 @node MacOS X
 @subsection MacOS X
 
-@warning{These instructions assume that you are using the built-in
-LilyPad editor.  If you are using any of the programs described in
-@rweb{Alternate input}, please consult the documentation for
-those programs if you have any problems compiling a file.}
-
-
-If you double click @command{LilyPond.app}, it will open with an
-example file.  Save it, for example, to @file{test.ly} on your
-Desktop, and then process it with the menu command
-@w{@code{Compile > Typeset File}}.  The resulting PDF file will be
-displayed on your screen.
+@cindex running LilyPond under MacOS X
+@cindex MacOS X, running LilyPond
 
-For future use of LilyPond, you should begin by selecting @q{New}
-or @q{Open}.  You must save your file before typesetting it.  If
-any errors occur in processing, please see the log window.
+@lilypadOSX
 
-@c FIXME: add screenshots
 
 @node Windows
 @subsection Windows
 
-@warning{These instructions assume that you are using the built-in
-LilyPad editor.  If you are using any of the programs described in
-@rweb{Alternate input}, please consult the documentation for
-those programs if you have any problems compiling a file.}
-
-On Windows, if you double-click in the LilyPond icon on the
-Desktop, it will open a simple text editor with an example file.
-Save it, for example, to @file{test.ly} on your Desktop and then
-double-click on the file to process it (the file icon looks like a
-note).  After some seconds, you will get a file @file{test.pdf} on
-your desktop.  Double-click on this PDF file to view the typeset
-score.  An alternative method to process the @file{test.ly} file
-is to drag and drop it onto the LilyPond icon using your mouse
-pointer.
-
-To edit an existing @file{.ly} file, right-click on it and
-select @qq{Edit source}.  To get an empty file to start from, run
-the editor as described above and use @qq{New} in
-the @qq{File} menu, or right-click on the desktop and select
-@qq{New..Text Document}, change its name to a name of your choice
-and change the file extension to @code{.ly}.  Double-click the
-icon to type in your LilyPond source code as before.
-
-Double-clicking the file does not only result in a PDF file, but
-also produces a @file{.log} file that contains some information on
-what LilyPond has done to the file.  If any errors occur, please
-examine this file.
-
-@c FIXME: add screenshots
+@cindex running LilyPond under Windows
+@cindex Windows, running LilyPond
+
+@lilypadWindows
 
 
 @node Command-line
 @subsection Command-line
 
-@warning{These instructions assume that you are using commond unix
-command-line programs.  If you are using any of the programs
-described in @rweb{Alternate input}, please consult the
-documentation for those programs if you have any problems
-compiling a file.}
-
-
-Create a text file called @file{test.ly} and enter:
-
-@example
-@{
-  c' e' g' e'
-@}
-@end example
-
-To process @file{test.ly}, proceed as follows:
-
-@example
-lilypond test.ly
-@end example
-
-@noindent
-You will see something resembling:
-
-@example
-lilypond test.ly
-GNU LilyPond @version{}
-Processing `test.ly'
-Parsing...
-Interpreting music...
-Preprocessing graphical objects...
-Finding the ideal number of pages...
-Fitting music on 1 page...
-Drawing systems...
-Layout output to `test.ps'...
-Converting to `test.pdf'...
-@end example
-
-You may view or print the resulting @file{text.pdf}.
+@cindex running LilyPond under Unix
+@cindex Unix, running LilyPond
 
+@lilypadCommandLine
 
 @node How to write input files
 @section How to write input files
 
-FIXME: insert text
+This section introduces some basic LilyPond syntax to help get you
+started writing input files.
 
 @menu
-* Simple notation::             
-* Working on input files::      
+* Simple notation::
+* Working on input files::
 @end menu
 
 
@@ -310,8 +234,8 @@ example, the first note -- the @code{d} -- is the closest D to
 middle C.
 
 By adding (or removing) quotes @code{'} or commas @code{,} from
-the @code{@w{\relative c' @{}} command, we can change the starting
-octave:
+the @q{@w{@code{@bs{}relative c'}}} command, we can change the
+starting octave:
 
 @lilypond[verbatim,quote]
 % one octave above middle C
@@ -360,9 +284,7 @@ comma @code{,} to the note name.
 @noindent
 To change a note by two (or more!) octaves, we use multiple
 @code{''} or @code{,,} -- but be careful that you use two single
-quotes @code{''} and not one double quote @code{"}@tie{}!  The
-initial value in @code{@w{\relative c'}} may also be modified like
-this.
+quotes @code{''} and not one double quote @code{"}@tie{}!
 @c " - keeps quotes in order for context-sensitive editor -td
 
 @subheading Durations (rhythms)
@@ -387,7 +309,7 @@ so on.  @notation{Beams} are added automatically.
 
 If you do not specify a duration, the previous duration is used
 for the next note.  The duration of the first note defaults to a
-quarter.
+quarter note.
 
 @lilypond[verbatim,quote]
 \relative c'' {
@@ -403,7 +325,7 @@ explicitly (i.e., with a number).
 
 @lilypond[verbatim,quote]
 \relative c'' {
-  a a a4. a8
+  a4 a a4. a8
   a8. a16 a a8. a8 a4.
 }
 @end lilypond
@@ -421,7 +343,7 @@ A @notation{rest} is entered just like a note with the name
 
 @lilypond[verbatim,quote]
 \relative c'' {
-  a r r2
+  a4 r r2
   r8 a r4 r4. r8
 }
 @end lilypond
@@ -450,6 +372,33 @@ command:
 }
 @end lilypond
 
+@subheading Tempo marks
+
+@cindex tempo marks
+@cindex metronome marks
+
+@funindex \tempo
+@funindex tempo
+
+Music Glossary: @rglos{tempo indication}, @rglos{metronome}.
+
+The @notation{tempo indication} and @notation{metronome mark} can be
+set with the @code{\tempo} command:
+
+@lilypond[verbatim,quote]
+\relative c'' {
+  \time 3/4
+  \tempo "Andante"
+  a4 a a
+  \time 6/8
+  \tempo 4. = 96
+  a4. a
+  \time 4/4
+  \tempo  "Presto" 4 = 120
+  a4 a a a
+}
+@end lilypond
+
 
 @subheading Clef
 
@@ -468,13 +417,13 @@ The @notation{clef} can be set using the @code{\clef} command:
 
 @lilypond[verbatim,quote]
 \relative c' {
-  \clef treble
+  \clef "treble"
   c1
-  \clef alto
+  \clef "alto"
   c1
-  \clef tenor
+  \clef "tenor"
   c1
-  \clef bass
+  \clef "bass"
   c1
 }
 @end lilypond
@@ -486,10 +435,13 @@ Here is a small example showing all these elements together:
 
 @lilypond[verbatim,quote]
 \relative c, {
+  \clef "bass"
   \time 3/4
-  \clef bass
-  c2 e8 c' g'2.
-  f4 e d c4 c, r4
+  \tempo "Andante" 4 = 120
+  c2 e8 c'
+  g'2.
+  f4 e d
+  c4 c, r
 }
 @end lilypond
 
@@ -513,69 +465,95 @@ Notation Reference: @ruser{Writing pitches},
 @cindex case sensitive
 @cindex whitespace insensitive
 @cindex expressions
+@cindex versioning
+@cindex version
+@cindex version number
 
+@funindex \version
 @funindex { ... }
 @funindex %
 @funindex %@{ ... %@}
 
 LilyPond input files are similar to source files in many common
-programming languages.  They are case sensitive, and white-space
-is generally ignored.  Expressions are formed with curly braces
-@{ @}, and comments are denoted with @code{%} or
-@w{@code{%@{ ... %@}}}.
+programming languages.  They contain a version statement, are case
+sensitive, and white-space is generally ignored.  Expressions are
+formed with curly braces @w{@code{@{ @}}}, and comments are
+denoted with @code{%} or @w{@code{%@{ @dots{} %@}}}@tie{}.
 
 If the previous sentences sound like nonsense, don't worry!  We'll
 explain what all these terms mean:
 
 @itemize
 
+@item
+@strong{Version statement}:
+Every LilyPond file should contain a version statement.  A version
+statement is a line that describes the version of LilyPond for which
+the file was written, as in the following example:
+
+@example
+\version "@w{@version{}}"
+@end example
+
+By convention, the version statement is placed at the top of the
+LilyPond file.
+
+The version statement is important for at least two reasons.  First,
+it allows automatic updating of the input file as LilyPond syntax
+changes.  Second, it describes the version of LilyPond needed to
+compile the file.
+
+If the version statement is omitted from an input file, LilyPond will print
+a warning during the compilation of the file.
+
 @item
 @strong{Case sensitive}:
 it matters whether you enter a letter in lower case (e.g.
-@w{@code{a, b, s, t}}) or upper case (e.g.  @w{@code{A, B, S, T}}).
-Notes are lower case: @w{@code{@{ c d e @}}} is valid input;
-@w{@code{@{ C D E @}}} will produce an error message.
+@w{@code{a, b, s, t}}) or upper case (e.g. @w{@code{A, B, S, T}}).
+Notes are lower case: @w{@samp{@{ c d e @}}} is valid input;
+@w{@samp{@{ C D E @}}} will produce an error message.
 
 @item
 @strong{Whitespace insensitive}:
 it does not matter how many spaces (or tabs or new lines) you add.
-@w{@code{@{ c d e @}}} means the same thing as
-@w{@code{@{ c @tie{}} @tie{} @tie{} d e @}} and:
+@w{@samp{@{ c4 d e @}}} means the same thing as
+@w{@samp{@{ c4 @tie{} @tie{} @tie{} d e @}}} and:
 
 @example
-@{ c                        d
+@{ c4                       d
                    e   @}
 @end example
 
 @noindent
 Of course, the previous example is hard to read.  A good rule of
-thumb is to indent code blocks with either a tab or two spaces:
+thumb is to indent code blocks with two spaces:
 
 @example
 @{
-  c d e
+  c4 d e
 @}
 @end example
 
-However, whitespace @emph{is} required to separate many syntactical
-elements from others.  In other words, whitespace can always be
-@emph{added}, but it cannot be @emph{eliminated}.  As missing
-whitespace can give rise to strange errors it is advisable to
-always insert whitespace before and after every syntactic element,
-for example, before and after every curly brace.
+However, whitespace @emph{is} required to separate many
+syntactical elements from others.  In other words, whitespace can
+always be @emph{added}, but not always @emph{eliminated}.  Since
+missing whitespace can give rise to strange errors, it is
+advisable to always insert whitespace before and after every
+syntactic element, for example, before and after every curly
+brace.
 
 @item
 @strong{Expressions}:
-every piece of LilyPond input needs to have @strong{@{ curly
-braces @}} placed around the input.  These braces tell LilyPond
-that the input is a single music expression, just like parentheses
-@code{()} in mathematics.  The braces should be surrounded by a
-space unless they are at the beginning or end of a line to avoid
-ambiguities.
+every piece of LilyPond input needs to have
+@strong{@{@tie{}curly@tie{}braces@tie{}@}} placed around the
+input.  These braces tell LilyPond that the input is a single
+music expression, just like parentheses @code{()} in mathematics.
+The braces should be surrounded by a space unless they are at the
+beginning or end of a line to avoid ambiguities.
 
 A LilyPond command followed by a simple expression in braces (such
-as @w{@code{\relative @{ @}}}) also counts as a single music
-expression.
+as @q{@w{@code{@bs{}relative c' @{ @dots{} @}}}}) also counts as a
+single music expression.
 
 @cindex comments
 @cindex line comment
@@ -611,28 +589,66 @@ comments:
   This line, and the notes below are ignored,
   since they are in a block comment.
 
-  f f e e d d c2
+  f4 f e e d d c2
 %@}
 @end example
 
 @end itemize
 
 
+@node Dealing with errors
+@section Dealing with errors
+
+@cindex troubleshooting
+
+Sometimes LilyPond doesn't produce the output you expect.  This
+section provides some links to help you solve the problems you
+might encounter.
+
+
+@menu
+* General troubleshooting tips::
+* Some common errors::
+@end menu
+
+@node General troubleshooting tips
+@subsection General troubleshooting tips
+
+Troubleshooting LilyPond problems can be challenging for
+people who are used to a graphical interface, because invalid
+input files can be created.  When this happens, a logical approach
+is the best way to identify and solve the problem.  Some guidelines
+to help you learn to do this are provided in @rprogram{Troubleshooting}.
+
+
+@node Some common errors
+@subsection Some common errors
+
+@cindex common errors
+@cindex errors, common
+
+There are a few common errors that are difficult to troubleshoot
+based simply on the error messages that are displayed.  These are
+described in @rprogram{Common errors}.
+
+
+
 @node How to read the manuals
 @section How to read the manuals
 
-FIXME: fluff here
+This section shows how to read the documentation efficiently, and
+also introduces some useful interactive features available in the
+online version.
 
 @menu
-* Omitting braces::             
-* Clickable examples::          
-* Keyboard navigation::         
-* Overview of manuals::         
+* Omitted material::
+* Clickable examples::
+* Overview of manuals::
 @end menu
 
 
-@node Omitting braces
-@subsection Omitting braces
+@node Omitted material
+@subsection Omitted material
 
 
 @cindex how to read the manual
@@ -645,34 +661,39 @@ FIXME: fluff here
 @cindex constructing files, tips
 @cindex files, tips for constructing
 
-LilyPond input must be surrounded by @{ @} marks or a
-@code{@w{\relative c'' @{ ... @}}}, as we saw in @ref{Working on
-input files}.  For the rest of this manual, most examples will
-omit this.  To replicate the examples, you may copy and paste the
-displayed input, but you @strong{must} add the
-@code{@w{\relative c'' @{ @}}} like this:
+LilyPond input must be surrounded by @code{@{ @}} marks or a
+@q{@w{@code{@bs{}relative c'' @{ @dots{} @}}}}, as we saw in
+@ref{Working on input files}.  For the rest of this manual, most
+examples will omit this.  To replicate the examples, you may copy
+and paste the displayed input, but you @strong{must} add the
+@q{@w{@code{@bs{}relative c'' @{ @dots{} @}}}} like this:
 
 @example
 \relative c'' @{
-  ... example goes here...
+  @dots{}example goes here@dots{}
 @}
 @end example
 
 Why omit the braces?  Most examples in this manual can be inserted
 into the middle of a longer piece of music.  For these examples,
-it does not make sense to add @code{@w{\relative c'' @{ @}}} --
-you should not place a @code{\relative} inside another
-@code{\relative}!  If we included @code{@w{\relative c'' @{ @}}}
-around every example, you would not be able to copy a small
-documentation example and paste it inside a longer piece of your
-own.  Most people want to add material to an existing piece, so we
-format the manual this way.
-
+it does not make sense to add
+@q{@w{@code{@bs{}relative c'' @{ @dots{} @}}}} -- you should not
+place a @code{\relative} inside another @code{\relative}!  If we
+included @q{@w{@code{@bs{}relative c'' @{ @dots{} @}}}} around
+every example, you would not be able to copy a small documentation
+example and paste it inside a longer piece of your own.  Most
+people want to add material to an existing piece, so we format the
+manual this way.
+
+Also, remember that every LilyPond file should have a
+@code{\version} statement.  Because the examples in the manuals
+are snippets, not files, the @code{\version} statement is omitted.
+But you should make a practice of including them in your files.
 
 @node Clickable examples
 @subsection Clickable examples
 
-@warning{This features is only available in the HTML manuals.}
+@warning{This feature is only available in the HTML manuals.}
 
 Many people learn programs by trying and fiddling around with the
 program.  This is also possible with LilyPond.  If you click on a
@@ -683,7 +704,7 @@ this image:
 @c no verbatim here
 @lilypond[quote]
 \relative c'' {
-  c-\markup { \bold \huge { Click here.  } }
+  c4-\markup { \bold \huge { Click here. } }
 }
 @end lilypond
 
@@ -693,15 +714,18 @@ same output (line-width and all), copy everything from @qq{Start
 cut-&-pastable section} to the bottom of the file.
 
 
-@node Keyboard navigation
-@subsection Keyboard navigation
+@ignore
+This is item 825
+
+@n ode Keyboard navigation
+@s ubsection Keyboard navigation
 
 @warning{This features is only available in the HTML manuals.}
 
 @c TODO: once this is figured out, insert it here.
 
 We are currently working on this feature.
-
+@end ignore
 
 @node Overview of manuals
 @subsection Overview of manuals
@@ -733,8 +757,8 @@ may want to look in relevant sections of the
 Learning manual's @ref{Tweaking output}.
 
 @item
-@strong{Before undertaking a large project}: read Usage document's
-@rprogram{Suggestions for writing files}.
+@strong{Before undertaking a large project}: read the Usage
+document's @rprogram{Suggestions for writing files}.
 
 @end itemize