]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tutorial.itely
patch::: 1.4.1.jcn1
[lilypond.git] / Documentation / user / tutorial.itely
index 085b7865cec9492255797c9fff4934f42b5a4977..241034151bb44072f95255c6ae65139b505f3825 100644 (file)
@@ -8,6 +8,7 @@
   
 @menu
 * First steps::                 Music language of LilyPond
+* Simple legend::               Small table of music language symbols
 * Running LilyPond::            Printing music
 * The first tune::              The first tune
 * Lyrics and chords::           Lyrics and chords
@@ -47,8 +48,15 @@ produce most complex music with LilyPond.
 @c @node Music language of LilyPond
 @c @section Music language of LilyPond
 
-This section shows how easy making music with LilyPond actually is.  If
-you have not used LilyPond before, this section is for you.
+This section shows how easy writing music with LilyPond actually is.  If
+you have not seen LilyPond input source before, this section is for you.
+
+The next section has a table (see @ref{Simple legend}) of all symbols
+that are introduced here, you may want to keep an eye on that.
+
+Writing music with LilyPond is explained below by a number of small
+examples.  Each example has a small piece of text; the LilyPond input
+that you should type, with the resulting music printed below it.
 
 You get a simple note by typing its note name, from @code{a} through
 @code{g}:
@@ -57,6 +65,7 @@ You get a simple note by typing its note name, from @code{a} through
 @example
 c d e f g a b
 @end example
+
 @lilypond[fragment]
 \property Score.timing = ##f
 \property Staff.TimeSignature = \turnOff
@@ -72,12 +81,16 @@ whole note, ``@code{2}'' for a halve note, and so on:
 @example
 a1 a2 a4 a16 a32
 @end example
+
+@c missing clef seems to raise more questions than actual pitch of notes,
+@c as these are snippets anyway
 @lilypond[fragment]
 \property Score.timing = ##f
 \property Staff.TimeSignature = \turnOff
 \property Staff.noAutoBeaming = ##t
-\property Staff.Clef = \turnOff
+%\property Staff.Clef = \turnOff
 \transpose c'' { a1 a2 a4 a16 a32 }
+s16_" "
 @end lilypond
 @end quotation
 @separate
@@ -88,26 +101,32 @@ If you don't specify a duration, the previous duration is used:
 @example
 a a a2 a
 @end example
+
+@c missing clef seems to raise more questions than actual pitch of notes,
+@c as these are snippets anyway
 @lilypond[fragment]
 \property Score.timing = ##f
 \property Staff.TimeSignature = \turnOff
-\property Staff.Clef = \turnOff
+%\property Staff.Clef = \turnOff
 \transpose c'' { a a a2 a }
+s16_" "
 @end lilypond
 @end quotation
 @separate
 
-A sharp is made by adding ``@code{is}'', a flat by adding ``@code{es}'':
+A sharp (@texisharp{}) is made by adding ``@code{is}'', a flat
+(@texiflat{}) by adding ``@code{es}'':
 
 @quotation
 @example
 cis1 ees fisis aeses
 @end example
+
 @lilypond[fragment]
 \property Score.timing = ##f
 \property Staff.TimeSignature = \turnOff
-\property Staff.Clef = \turnOff
 \transpose c'' { cis1 ees fisis aeses }
+s16_" "
 @end lilypond
 @end quotation
 @separate
@@ -117,37 +136,64 @@ Add a dot ``@code{.}'' after the duration to get a dotted note:
 @example
 a2. a4 a8. a16
 @end example
+
+@c missing clef seems to raise more questions than actual pitch of notes,
+@c as these are snippets anyway
 @lilypond[fragment]
 \property Score.timing = ##f
 \property Staff.TimeSignature = \turnOff
-\property Staff.Clef = \turnOff
+%\property Staff.Clef = \turnOff
 \transpose c'' { a2. a4 a8. a16 }
+s16_" "
 @end lilypond
 @end quotation
 @separate
 
-The meter (or time signature) can be set the ``@code{\time}'' command:
+The meter (or time signature) can be set with the ``@code{\time}'' command:
 
 @quotation
 @example
 \time 3/4
+\time 6/8
+\time 4/4
 @end example
+
+@c a clef here may lead to confusion
 @lilypond[fragment]
+\property Staff.Clef = \turnOff
 \time 3/4
-s2_" "
+s4_" "
+\time 6/8
+s4_" "
+\time 4/4
+s16_" "
 @end lilypond
 @end quotation
 @separate
 
-The clef is set using ``@code{\clef}'':
+The clef can be set using the ``@code{\clef}'' command:
 
+@c what is more common name treble or violin?
+@c in Dutch, its violin.
 @quotation
 @example
+\clef violin
 \clef bass
+\clef alto
+\clef tenor
 @end example
+
 @lilypond[fragment]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\clef violin
+s4_" "
 \clef bass
-s2_" "
+s4_" "
+\clef alto
+s4_" "
+\clef tenor
+s16_" "
 @end lilypond
 @end quotation
 @separate
@@ -168,17 +214,29 @@ LilyPond then knows that music follows (and not lyrics, for example):
 @end quotation
 @separate
 
-Actually, this piece of music is ready to be printed.  This is done by
-combining the music with a printing command.
+At this point, the piece of music is ready to be printed.  This is done
+by combining the music with a printing command.
 
 The printing command is the so-called ``@code{\paper}'' block.  You will
 see later that the \paper block is necessary to customize all kinds of
 printing specifics.  The music and the \paper block are combined by
-enclosing them in ``@code{\score @{ ... @}}''.  This is a full LilyPond
-source file:
+enclosing them in ``@code{\score @{ ... @}}''.  This is what a full
+LilyPond source file looks like:
 
 @quotation
-@lilypond[verbatim]
+@example
+\score @{
+  \notes @{
+     \time 3/4
+     \clef bass
+     c2 e4 g2.
+     f4 e d c2.
+  @}
+  \paper @{ @}
+@}
+@end example
+
+@lilypond
 \score {
   \notes {
      \time 3/4
@@ -186,41 +244,58 @@ source file:
      c2 e4 g2.
      f4 e d c2.
   }
-  \paper { }
+  \paper { linewidth = 60 * \staffspace }
 }
 @end lilypond
 @end quotation
 @separate
 
+
+We continue with the introduction of the remaining musical constructs.
+
+@c maybe legend here?
+
 Rests are entered just like notes with the name ``@code{r}'':
 
 @quotation
 @example
 r2 r4 r8 r16
 @end example
+
 @lilypond[fragment]
-  \property Score.timing = ##f
-  \property Staff.TimeSignature = \turnOff
-  % \property Staff.Clef = \turnOff
-  % \property Staff.whichBar = #""
-  r2 r4 r8 r16
+\property Score.timing = ##f
+\property Staff.Clef = \turnOff
+\property Staff.TimeSignature = \turnOff
+r2 r4 r8 r16
+s16_" "
 @end lilypond
 @end quotation
 @separate
 
+@c Tim wants to move this quotes example just before the: quotes-don't-work
+@c score, but we'd need to remove quotes from the other two (key and
+@c tie) examples...
+
+@c better to have this just before the `octaves are bad' snipped
+@c but we'd need to remove the ', from \key and tie 
 To raise a note by an octave, add a high quote @code{'} (apostrophe) to
 the note name, to lower a note one octave, add a ``low quote'' @code{,}
 (a comma).  The central C is @code{c'}:
-@c huh, why exactly was central C == c'?
 
 @quotation
-@lilypond[verbatim,fragment]
-c'4 c'' c''' c,
+@example
+c'4 c'' c''' \clef bass c c,
+@end example
+
+@lilypond[fragment]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+c'4 c'' c''' \clef bass c c,
 @end lilypond
 @end quotation
 @separate
 
-A tie is created by entering a tilde ``@code{~})'' between the notes to
+A tie is created by entering a tilde ``@code{~}'' between the notes to
 be tied.  A tie between two notes means that the second note must not be
 played separately, but just makes the first note sound longer:
 
@@ -233,7 +308,15 @@ g'4 ~ g' a'2 ~ a'4
 
 The key signature is set with the command ``@code{\key}'':
 @quotation
-@lilypond[fragment,verbatim]
+@example
+\key d \major
+g'1
+\key c \minor
+g'
+@end example
+
+@lilypond[fragment]
+\property Staff.TimeSignature = \turnOff
 \key d \major
 g'1
 \key c \minor
@@ -241,30 +324,51 @@ g'
 @end lilypond
 @end quotation
 
+
 @c bit on the long/complex/scary taste
+@c cheating a bit: two lines makes for a friendlier look
 This example shows notes, ties, octave marks, and rests in action.
 Don't worry about all the quotes.
 
 @quotation
-@lilypond[verbatim]
+@example
+\score @{
+  \notes @{
+    \time 4/4
+    \clef violin
+    \key d \minor
+    r4 r8 d''8 cis''4 e''
+    d''8 a'4. ~ a' b'8
+    cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
+    cis''2 r2
+  @}
+  \paper @{ @}
+@}
+@end example
+
+@lilypond
 \score {
   \notes {
     \time 4/4
-    \clef treble
+    \clef violin
     \key d \minor
     r4 r8 d''8 cis''4 e''
-    d''8 a'4. ~ a'  b'8
+    d''8 a'4. ~ a' b'8
     cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
     cis''2 r2
   }
-  \paper { }
+  \paper { linewidth = 50*\staffspace }
 }
 @end lilypond
 @end quotation
 
-There is one interesting point to note in this example: accidentals
-don't have to be marked explicitly.  You just enter the pitch, and
-LilyPond determines wether or not to print an accidental.
+@c accidentals...
+There are some interesting points to note in this example.  Firstly,
+accidentals (sharps and flats) don't have to be marked explicitly: you
+just enter the note name, and LilyPond determines whether or not to
+print an accidental.  Secondly, bar lines and beams are drawn
+automatically.  Thirdly, LilyPond calculates line breaks for you; it
+doesn't matter where you make new lines in the source file.
 
 The example also indicates that a piece of music written in a high
 register needs lots of quotes.  This makes the input a bit unreadable,
@@ -286,10 +390,19 @@ You must also give a note from which relative starts, in this case
 
 If you type no octaviation quotes, relative mode chooses the note that
 is closest to the previous one, which is often just the one you need.
-For example, @code{c f} goes up, and @code{c g} goes down:
+@c don't use commas or quotes in this sentence
+For example: @code{c f} goes up; @code{c g} goes down:
 
 @quotation
-@lilypond[verbatim]
+@example
+\relative c'' @{
+  c f c g c
+@}
+@end example
+
+@lilypond[fragment]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
 \relative c'' {
   c f c g c
 }
@@ -297,11 +410,26 @@ For example, @code{c f} goes up, and @code{c g} goes down:
 @end quotation
 @separate
 
-You can make a large interval by adding octaviation quotes.  For example,
-@code{c f,} goes down, and @code{c g'} goes up:
+@c needed better, maybe even redundant explanation
+@c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
+@c in eerste instantie drong het `relative' niet door zonder extra uitleg.
+You can make a large interval by adding octaviation quotes.  Note that
+quotes or commas do not determine the absolote height of a note;
+the height of a note is relative to the previous one.
+@c don't use commas or quotes in this sentence
+For example: @code{c f,} goes down; @code{f, f} are both the same;
+@code{c c'} are the same; and @code{c g'} goes up:
 
 @quotation
-@lilypond[verbatim]
+@example
+\relative c'' @{
+  c f, f c' c g' c,
+@}
+@end example
+
+@lilypond[fragment]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
 \relative c'' {
   c f, f c' c g' c,
 }
@@ -310,12 +438,12 @@ You can make a large interval by adding octaviation quotes.  For example,
 @separate
 
 A slur is drawn across many notes, and indicates bound articulation
-(legato).  The starting note and ending note with a ``@code{(}'' and a
-``@code{)}'' respectively:
+(legato).  The starting note and ending note are marked with a
+``@code{(}'' and a ``@code{)}'' respectively:
 
 @quotation
 @lilypond[fragment,relative 1, verbatim]
-c8( cis d ) e 
+d4( )c16( cis d e c cis d )e( )d4
 @end lilypond
 @end quotation
 @separate
@@ -342,22 +470,22 @@ and @code{]}:
 @end quotation
 @separate
 
-You can make more than one staff, by specifying @code{\context Staff} before 
-snippets of music, and combining those snippets in @code{<} and
-@code{>}, as is demonstrated here:
+To print more than one staff, each piece of music that makes up a staff
+is marked by adding @code{\context Staff} before it.  These staffs can
+be grouped inside @code{<} and @code{>}, as is demonstrated here:
 
 @quotation
 @lilypond[fragment,verbatim]
 <
-  \context Staff = staffA { \clef treble c'' }
+  \context Staff = staffA { \clef violin c'' }
   \context Staff = staffB { \clef bass c }
 >
 @end lilypond
 @end quotation
 
-Here, @code{staffA} and @code{staffB} are names that you give them to
-the staff. For now, it doesn't matter what names you give them, as long
-as they are different.
+In this example, @code{staffA} and @code{staffB} are names that are
+given to the staffs.  For now, it doesn't matter what names you give, as
+long as each staff has a unique name.
 
 @separate
 
@@ -369,7 +497,7 @@ We can typeset a melody with two staffs now:
   \notes 
   < \context Staff = staffA {
       \time 3/4
-      \clef treble
+      \clef violin
       \relative c'' { e2 ( d4 c2 b4 [a8 a] [b b] [g g] )a2. }  
     }
     \context Staff = staffB {
@@ -389,7 +517,15 @@ signature should be the same for all staffs.
 
 @separate
 
-Dynamic signs are made by adding the markings after the note
+Common accents can be added to a note using @code{-.}, @code{--}, @code{->}:
+@quotation
+@lilypond[verbatim,relative 1]
+c-. c-- c->
+@end lilypond
+@end quotation
+@separate
+
+Dynamic signs are made by adding the markings to the note:
 @quotation
 @lilypond[verbatim,relative 1]
 c-\ff c-\mf
@@ -401,7 +537,7 @@ Crescendi are started with the commands @code{\<}  and @code{\>}. The
 command @code{\!} finishes a crescendo on the following.
 @quotation
 @lilypond[verbatim,relative 1]
-c2  \< \! c2-\ff \> c2  \! c2
+c2\<  \!c2-\ff  \>c2  \!c2
 @end lilypond
 @end quotation
 @separate
@@ -409,21 +545,24 @@ c2  \< \! c2-\ff \> c2  \! c2
 Chords can be made by surrounding notes with @code{<} and @code{>}:
 @quotation
 @lilypond[relative 0, fragment,verbatim]
-  r4  <c e g> <c f a> 
+r4 <c e g> <c f a> 
 @end lilypond
 @end quotation
 @separate
 
+@ignore
 @c te diepzinnig?
-
+@c hmm, te losjes, iig
 In general, @code{ < @var{stuff} > } is used when @var{stuff} all
 happens at the same time, like in chords, or (like in the two-staff
 example above) in a bunch of stacked staffs.
+@end ignore
 
-Of course, you can combine beams and ties with chords:
+Of course, you can combine beams and ties with chords.  Notice that
+beam and tie markings are placed outside the chord markers:
 @quotation
 @lilypond[relative 0, fragment,verbatim]
- r4  [<c8 e g>   <c8 f a>] ~ <c8 f a>
+r4 [<c8 e g> <c8 f a>] ~ <c8 f a>
 @end lilypond
 @end quotation
 
@@ -485,28 +624,144 @@ with the basics.  It deals with some of the more advanced features of
 LilyPond. Topics include lyrics, chords, orchestral scores and parts,
 fine tuning output, polyphonic music, and integrating text and music.
 
+
+@c refer to this section
+@node Simple legend
+@section Simple legend
+
+
+@c need texinfo-4.0a or later for this
+
+
+@c both Tim and my father came independently with a request for a
+@c `legend' like this.
+
+@c what should be in it?
+
+
+
+@quotation
+@multitable @columnfractions .10 .20 .40
+
+@item @code{[]}
+@tab beam
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+[a8 b]
+@end lilypond
+
+@item @code{~}
+@tab tie
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+d ~ d
+@end lilypond
+
+@item @code{()}
+@tab slur
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+c( d )e
+@end lilypond
+@item @code{'}
+@tab raise octave
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+a a'
+@end lilypond
+
+@item @code{,}
+@tab lower octave
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+c c,
+@end lilypond
+
+@item @code{<>}
+@tab chord
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+\context Voice { <a c> }
+@end lilypond
+
+@item @code{\< \!}
+@tab crescendo
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+a\< a \!a
+@end lilypond
+
+@item @code{\> \!}
+@tab decrescendo
+@tab
+@lilypond[fragment, relative 1]
+\property Score.timing = ##f
+\property Staff.TimeSignature = \turnOff
+\property Staff.noAutoBeaming = ##t
+\property Staff.Clef = \turnOff
+a\> a \!a
+@end lilypond
+
+@end multitable
+@end quotation
+
+
+
 @node Running LilyPond
 @section Running LilyPond
 
-You make music notation with LilyPond as follows: first you edit a text
-file containing a description of the notes. Then you run LilyPond on the
+You write music with LilyPond as follows: first you edit a text file
+containing a description of the notes.  Then you run LilyPond on the
 file. This leaves you with an output file, which you can view or print.
 
 In this section we explain how to run LilyPond, and view or print the
-output.  If you want to test your setup of LilyPond, or try to run an
-example file yourself, then read this section. Otherwise, you can skip
-to the next section, which explains how to
-write LilyPond input.
+output.  If you have not used LilyPond before, want to test your setup
+of LilyPond, or try to run an example file yourself, then read this
+section.
 
-The instructions that follow are for Unix. Windows instructions are
-given at the end of this section. Start with opening a terminal window,
-and start up a text editor.  For example, start an xterm and execute
-@code{joe}.   Enter the following
-input, and save the file as @file{test.ly}.
+The instructions that follow are for running LilyPond on Unix-like
+systems.  Some additional instructions for running LilyPond on Windows
+are given at the end of this section.
 
+You begin with opening a terminal window, and start up a text editor.
+For example, open an xterm and execute @code{joe}.  In your text editor,
+enter the following input, and save the file as @file{test.ly}:
 
-If this code looks intimidating you, then don't worry, we explain all
-about it in the next section.
+@quotation
+@example
+\score @{
+  \notes @{ c'4 e' g' @}
+@} 
+@end example
+@end quotation
 
 @cindex ly2dvi
 
@@ -552,8 +807,9 @@ produce a window with some music notation on your screen:
   kghostview test.ps
 @end example
 @end quotation
-When you're satisfied with the result, you can print the PS file by
-clicking File/Print inside ghostview.
+If you are satisfied with the looks of the music displayed on your
+screen, you can print the PS file by clicking File/Print inside
+ghostview.
 
 The DVI file (@file{test.dvi}) contains the same sheet music in a
 different format. DVI files are more easily processed by the computer,
@@ -574,7 +830,7 @@ at @uref{http://www.ghostscript.com}.
 @cindex Printing output
 @cindex PostScript
 
-
+@unnumberedsubsec Windows users
 Windows users start the terminal by clicking on the LilyPond icon.
 Notepad is sufficient for editing the LilyPond file. Viewing the PS file
 can be done with @code{gsview32 test.ps}.  Viewing DVI files can be done
@@ -629,8 +885,9 @@ is included in the distribution as  @file{minuet.ly}.
         \bar "|."
     }
     \paper {
-       % standard settings are too wide for a book
-       linewidth = 14.0 \cm
+       % standard settings are too big and wide for a book
+       indent = 1.0 \cm
+       linewidth = 15.0 \cm
    }
 }
 @end lilypond
@@ -897,7 +1154,9 @@ bar, we must explicitely request one, using @code{"|."}.
 @example 
 
         \paper @{
-                linewidth = 14.0\cm
+                % standard settings are too big and wide for a book
+                indent = 1.0\cm
+                linewidth = 15.0\cm
         @}
  
 @end example 
@@ -1366,7 +1625,7 @@ The first thing it does, is running LilyPond on the input file. After
 some calculations, a @file{.tex} is produced. The contents
 of this file are very  low-level instructions.
 
-For example,  the following file (@file{miniatures.ly}) 
+For example, the following file (@file{miniatures.ly}) 
 
 @example
 \version "1.3.124"