]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tutorial.itely
patch::: 1.3.46.jcn1
[lilypond.git] / Documentation / user / tutorial.itely
index 35b5dc0cae68c40333fcec48184e7e70e50365ee..4d9e32e2f17ebbd73d483cb951c4aea4c01454d5 100644 (file)
@@ -1,17 +1,17 @@
 
+@node Tutorial
 @chapter Tutorial
 
 
-@node Tutorial, , , Top
 @menu
-* Introduction::                  Introduction
-* The first tune::                The first tune
-* Lyrics and chords::             Lyrics and chords
-* Piano music::                   Piano music
-* end of tutorial::                       The end
+* Introduction::               Introduction
+* The first tune::             The first tune
+* Lyrics and chords::          Lyrics and chords
+* Piano music::                        Piano music
+* end of tutorial::            The end
 @end menu
 
-@node Introduction,  , , Tutorial
+@node Introduction
 @section Introduction
 
   
@@ -30,7 +30,7 @@ subdirectory @file{input/tutorial/}.  It is recommended that you
 experiment with writing Mudela input yourself, to get a feel for
 how LilyPond behaves.
 
-@node The first tune,  , , Tutorial
+@node The first tune
 @section The first tune
 
 
@@ -74,7 +74,7 @@ Enter it (or copy it, the filename is @file{menuet.ly}), compile it
 with LilyPond and view the output.  Details of this procedure may vary
 from system to system.  To create the output, one would issue the
 command `@code{ly2dvi menuet}'.  @file{ly2dvi} is a program that does
-the job of running LilyPond and TeX, handling of titles and
+the job of running LilyPond and @TeX{}, handling of titles and
 adjusting of page margins.
 
 If all goes well, the file @file{menuet.dvi} will be created.
@@ -114,7 +114,8 @@ By default, LilyPond will use definitions for a 20
 point@footnote{A point is the standard measure of length for
 printing.  One point is 1/72.27 inch.} high staff.  We want smaller
 output (16 point staff height), so we must import the settings for
-that size, which is done.@example 
+that size, which is done.
+@example 
 
         \score @{
  
@@ -147,28 +148,32 @@ as close as possible (graphically, on the staff) to the the preceding
 note.  If you add a high-quote an extra octave is added.  The lowered
 quote (a comma) will subtract an extra octave.  Because the first note
 has no predecessor, you have to give the (absolute) pitch of the note
-to start with.@example 
+to start with.
+@example 
 
         \sequential @{
  
 @end example 
   What follows is sequential music, i.e.,
-notes that are to be played and printed after each other.@example 
+notes that are to be played and printed after each other.
+@example 
 
         \time 3/4;
  
 @end example 
   This command changes the time signature of the current piece: a 3/4
 sign is printed.  This command is also used to generate bar lines in
-the right spots.@example 
+the right spots.
+@example 
 
         \key g;
  
 @end example 
- This command changes the current key to G-major.  Although this
 This command changes the current key to G-major.  Although this
 command comes after the @code{\time} command, in the output, the key
 signature comes before the time signature: LilyPond knows about music
-typesetting conventions. @example 
+typesetting conventions.
+@example 
 
         \repeat "volta" 2
  
@@ -183,7 +188,8 @@ alternatives---if there were any.
 @end example 
 The subject of the repeat is again sequential music.  Since
 @code{\sequential} is such a common construct, a shorthand is provided:
-just leave off @code{\sequential}, and the result is the same. @example 
+just leave off @code{\sequential}, and the result is the same.
+@example 
 
         d4
  
@@ -191,14 +197,16 @@ just leave off @code{\sequential}, and the result is the same. @example
  This is a note with pitch @code{d} (determined up to octaves).  The
 relative music was started with a @code{c''}, so the real pitch of this
 note is @code{d''}.  The @code{4} designates the duration of the note
-(it is a quarter note). @example 
+(it is a quarter note).
+@example 
 
         a b
  
 @end example 
 These are notes with pitch @code{a} and @code{b}.  Because their
 duration is the same as the @code{g}, there is no need to enter the
-duration (You may enter it anyway, eg. @code{a4 b4}) @example 
+duration (You may enter it anyway, e.g. @code{a4 b4})
+@example 
 
         d4 g, g |
  
@@ -228,32 +236,37 @@ In this case, a beam over 4 eighths is added.
 the beginning and ending note of the slur is marked with an opening and
 closing parenthesis respectively.  In the line shown above this is
 done for two slurs.  Slur markers (parentheses) are between
-the notes.@example 
+the notes.
+@example 
 
         a4 [b8 a] [g fis] 
  
 @end example 
 Automatic beaming can be overridden by inserting beam marks
-(brackets).  Brackets are put around notes you want beamed.@example 
+(brackets).  Brackets are put around notes you want beamed.
+@example 
 
         g2.  |
  
 @end example 
 A duration with augmentation dot  is notated
-with the duration number followed by a period.@example 
+with the duration number followed by a period.
+@example 
 
         @}
  
 @end example 
   This ends the sequential music to be repeated.  LilyPond will typeset
-a repeat bar.  @example 
+a repeat bar.
+@example 
 
         cis'4 b8 cis a4 |
  
 @end example 
  This line shows that Lily will print an accidental if that is
 needed: the first C sharp will be printed with an accidental, the
-second one without.  @example 
+second one without.
+@example 
 
         a8-. b-. cis-. d-. e-. fis-.
  
@@ -261,7 +274,8 @@ second one without.  @example
 You can enter articulation signs either in a verbose form using a
 shorthand.  Here we demonstrate the shorthand: it is formed by a dash
 and the the character for the articulation to use, e.g. `@code{-.}' for
-staccato as shown above.  @example 
+staccato as shown above.
+@example 
 
         fis a, r8 cis8
  
@@ -278,7 +292,8 @@ an invisible rest by using the special notename `@code{s}'.
 command `@code{\fermata}' is not part of the core of the language (most
 of the other discussed elements are), but it is a shorthand for a more
 complicated description of a fermata.  @code{\fermata} names that
-description and is therefore called an @emph{identifier}. @example 
+description and is therefore called an @emph{identifier}.
+@example 
 
         @}
  
@@ -318,7 +333,7 @@ symbols and their placement is @emph{generated} from a high-level musical
 description.  In other words,  LilyPond would be best
 described by `music compiler' or `music to notation compiler'.
 
-@node Lyrics and chords, , , Tutorial
+@node Lyrics and chords
 @section Lyrics and chords
 
 In this section we show how to typeset a song of unknown
@@ -346,8 +361,8 @@ text = \lyrics @{
 
 accompaniment =\chords @{
         r8
-        c2-3- f-3-.7 d-min es4 c8-min r8
-        c2-min f-min7 g-7^3.5 c-min @}
+        c2:3- f:3-.7 d:min es4 c8:min r8
+        c2:min f:min7 g:7^3.5 c:min @}
 
 \score @{
         \simultaneous @{
@@ -383,6 +398,7 @@ may differ, since the titling in this document is not generated by
 \include "paper16.ly"
 melody = \notes \relative c' {
         \partial 8;
+       \key c \minor;
         g8 |
         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
         c4 c8 d [es () d] c4 | d4 es8 d c4.
@@ -396,8 +412,8 @@ text = \lyrics {
 
 accompaniment =\chords {
         r8
-        c2-3- f-3-.7 d-min es4 c8-min r8
-        c2-min f-min7 g-7^3.5 c-min }
+        c2:3- f:3-.7 d:min es4 c8:min r8
+        c2:min f:min7 g:7^3.5 c:min }
 
 \score {
         \simultaneous {
@@ -417,7 +433,8 @@ accompaniment =\chords {
 }
 @end mudela
 
-Again, we will dissect the file line by line.@example 
+Again, we will dissect the file line by line.
+@example 
 
         \header @{
  
@@ -436,12 +453,14 @@ with a string.  (which is unquoted, in this case). Then comes the
 equal sign `@code{=}'.  After the equal sign comes the expression you
 want to store.  In this case, you want to put in strings.  The
 information has to be quoted here, because it contains spaces. The
-assignment is finished with a semicolon.@example 
+assignment is finished with a semicolon.
+@example 
 
         \include "paper16.ly"
  
 @end example 
-Smaller size for inclusion in a book.@example 
+Smaller size for inclusion in a book.
+@example 
 
         melody = \notes \relative c' @{
  
@@ -452,26 +471,33 @@ give names to the different parts of music, and use the names to
 construct the music within the score block.
 
 @example 
-
         \partial 8;
 @end example 
 
-The piece starts with an anacrusis of one eighth.  @example 
+The piece starts with an anacrusis of one eighth.
+@example
+       \key c \minor
+@end example
+The key is C minor: we have three flats.
+
+@example 
 
         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
         c4 c8 d [es () d] c4 | d4 es8 d c4.
         \bar "|.";
  
 @end example 
+
 We use explicit beaming.  Since this is a song,  we will turn automatic
-beams off, and use explicit beaming where needed.@example 
+beams off, and use explicit beaming where needed.
+@example 
 
         @}
  
 @end example 
 This ends the definition of @code{melody}.  Note that there are no
-semicolons after assignments at top level.@example 
+semicolons after assignments at top level.
+@example 
 
         text = \lyrics @{
  
@@ -480,11 +506,12 @@ Another identifier assignment.  This one is for the lyrics.
 Lyrics are formed by syllables that have duration, and not by
 notes. To make LilyPond parse words as syllables,  switch it  into
 lyrics mode with @code{\lyrics}.  Again, the brace after @code{\lyrics}
-is a shorthand for @code{\sequential @{}. @example 
+is a shorthand for @code{\sequential @{}.
+@example 
 
-        The4 ri -- ver is flo- __ wing,  flo -- wing and gro -- wing, the
-        ri- ver is flo- __ wing down to the sea.
-        @}
+  The4 ri -- ver is flo- __ wing,  flo -- wing and gro -- wing, the
+  ri- ver is flo- __ wing down to the sea.
+@}
  
 @end example 
 The syllables  themselves are  separated by spaces.  You can get syllable
@@ -505,9 +532,10 @@ of the chords you want, instead of the notes comprising the chord.
         r8
  
 @end example 
-There is no accompaniment during the anacrusis.@example 
+There is no accompaniment during the anacrusis.
+@example 
 
-        c2-3- f-3-.7
+        c2:3- f:3-.7
  
 @end example 
 A chord is started by  the tonic of the chord. The
@@ -515,22 +543,25 @@ first one lasts a half note.  An unadorned note creates a major
 triad, while a minor triad is wanted.  @code{3-} modifies the third to
 be small. @code{7} modifies (adds) a seventh, which is small by default
 to create the @code{f a c es} chord.  Multiple modifiers must be
-separated by a dot.@example 
+separated by a dot.
+@example 
 
-        d-min es4 c8-min r8
+        d:min es4 c8:min r8
  
 @end example 
 Some modifiers have predefined names, eg. @code{min} is  the same as
-@code{3-}, so @code{d-min} is a minor @code{d} chord.@example 
+@code{3-}, so @code{d-min} is a minor @code{d} chord.
+@example 
 
-        c2-min f-min7 g-7^3.5 c-min @}
+        c2:min f:min7 g:7^3.5 c:min @}
  
 @end example 
 A named modifier @code{min} and a normal modifier @code{7} do not have
 to be separated by a dot.  Tones from a chord are removed with chord
 subtractions.  Subtractions are started with a caret, and they are
-also separated by dots.  In this example, @code{g-7^3.5} produces a
-minor seventh.  The brace ends the sequential music. @example 
+also separated by dots.  In this example, @code{g:7^3.5} produces a
+minor seventh.  The brace ends the sequential music.
+@example 
 
         \score @{
                 \simultaneous @{
@@ -538,7 +569,8 @@ minor seventh.  The brace ends the sequential music. @example
 @end example 
 We assemble the music in the @code{\score} block.  Melody, lyrics and
 accompaniment have to sound at the same time, so they should be
-@code{\simultaneous}.@example 
+@code{\simultaneous}.
+@example 
 
         %\accompaniment
  
@@ -546,7 +578,8 @@ accompaniment have to sound at the same time, so they should be
 Chord mode generates notes grouped in @code{\simultaneous} music.  If
 you remove the comment sign, you can see the chords in normal
 notation: they will be printed as note heads on a separate
-staff. @example 
+staff.
+@example 
 
         \context ChordNames \accompaniment
  
@@ -570,7 +603,8 @@ two arguments.  The first is the name of a interpretation context.
 The name is a string, it can be quoted with double quotes).  The
 second argument is the music that should be interpreted in this
 context.  For the previous line, we could have written @code{\context
-Staff \accompaniment}, and get the same effect.@example 
+Staff \accompaniment}, and get the same effect.
+@example 
 
         \addlyrics
  
@@ -581,7 +615,8 @@ pieces of music (usually a melody and lyrics, in that order) and
 aligns the syllables of the second piece under the notes of the
 first piece.  If you would reverse the order, the notes would be
 aligned on the lyrics, which is not very useful. (Besides, it looks
-silly.)@example 
+silly.)
+@example 
 
         \context Staff = mel @{
  
@@ -591,7 +626,8 @@ This is the argument of @code{\addlyrics}.  We instantiate a
 before the ``note heads'' version of the accompaniment, the
 accompaniment will be on a nameless staff.  The melody has to be on a
 different staff as the accompaniment.  This is accomplished by giving
-the melody staff a different name.@example 
+the melody staff a different name.
+@example 
 
         \property Staff.noAutoBeaming = "1"
  
@@ -599,14 +635,16 @@ the melody staff a different name.@example
 An interpretation context has variables that tune its behaviour.  One
 of the variables is @code{noAutoBeaming}.  If set and non-zero (i.e.,
 true) LilyPond will not try to put automatic beaming on the current
-staff.@example 
+staff.
+@example 
 
         \property Staff.automaticMelismata = "1"
  
 @end example 
 Similarly, we  don't want to print a  syllable when there is
 a slur. This sets up the Staff context to signal slurs while
-@code{\addlyrics} is processed. @example 
+@code{\addlyrics} is processed.
+@example 
 
           \melody
         @}
@@ -615,7 +653,8 @@ a slur. This sets up the Staff context to signal slurs while
 Finally, we put the melody on the current staff.  Note that the
 @code{\property} directives and @code{\melody} are grouped in sequential
 music,  so the property settings are done before the melody is
-processed.  @example 
+processed.
+@example 
 
         \context Lyrics \text
  
@@ -623,12 +662,14 @@ processed.  @example
 The second argument of @code{\addlyrics} is the text. The text also
 should not land on a Staff, but on a interpretation context for
 syllables, extenders, hyphens etc.  This context is called
-Lyrics.@example 
+Lyrics.
+@example 
 
         @}
  
 @end example 
-This ends @code{\simultaneous}.@example 
+This ends @code{\simultaneous}.
+@example 
 
         \midi  @{ @}
  
@@ -637,20 +678,22 @@ This makes the music go to a MIDI file.  MIDI is great for
 checking music you enter.  You listen to the MIDI file: if you hear
 something unexpected, it's probably a typing error.  @code{\midi} is an
 `output definition', a declaration that specifies how to output music
-analogous to @code{\paper @{ @}}.@example 
+analogous to @code{\paper @{ @}}.
+@example 
 
         \paper @{ linewidth = 10.0\cm; @}
  
 @end example 
 We also want notation output.  The linewidth is short so the piece
-will be set in two lines. @example 
+will be set in two lines.
+@example 
 
         @}
  
 @end example 
 End the score block.
 
-@node Piano music, , , Tutorial
+@node Piano music
 @section Piano music
 
 Our third subject is a piece piano music.  The fragment in the input
@@ -720,7 +763,8 @@ bassvoices = \notes \relative c' {
 
 If it looks like incomprehensible gibberish to you@dots{} Then you are
 right.  The author has doctored this example to have as many quirks in
-one system as possible.@example 
+one system as possible.
+@example 
 viola = \notes \relative c'  \context Voice = viola @{ 
 @end example 
 In this example, you can see multiple parts on a staff.  Each part is
@@ -729,12 +773,14 @@ stems and dynamics (among others).  The name of this context is
 @code{Voice}.  For each part we have to make sure that there is
 precisely one Voice context@footnote{If @code{\context} would not
 have been specified explicitly, three @code{Voice} contexts would be
-created: one for each note  in the first chord.}.@example 
+created: one for each note  in the first chord.}.
+@example 
 <c4-\f g' c> 
 @end example 
 @code{<} and @code{>} are short hands for @code{\simultaneous @{} and
 @code{@}}. So the expression enclosed in @code{<} and @code{>} is a
-chord.  @code{\f} places a forte symbol  under the chord.@example 
+chord.  @code{\f} places a forte symbol  under the chord.
+@example 
 \property Voice.verticalDirection = \down 
 @end example 
 @code{verticalDirection} is a property of the voice context. It
@@ -742,7 +788,8 @@ controls the directions of stems, articulations marks and other
 symbols.
   If @code{verticalDirection} is set to @code{\down}
 (identifier for the integer -1) the stems go down,
-@code{\up} (identifier for the integer 1) makes the stems go up.@example 
+@code{\up} (identifier for the integer 1) makes the stems go up.
+@example 
         g'8. b,16 
 @end example 
 Relative octaves work a little differently with chords.  The starting
@@ -754,13 +801,15 @@ note of the previous chord (the central C).
 s1 s2. r4 
 @end example 
 @code{s} is a `spacer' rest.  It does not print anything,  but it does
-have the duration of a rest.   @example 
+have the duration of a rest.
+@example 
 oboes = \notes \relative c'' \context Voice = oboe @{ 
 @end example 
 Now comes a part for two oboes.  They play homophonically, so we
 print the notes as one voice that makes chords. Again, we insure that
 these notes are indeed processed by precisely one context with
-@code{\context}.@example 
+@code{\context}.
+@example 
 \stemup s4  g8. b,16 c8 r <e'8.-\p g> <f16 a> 
 @end example 
 @code{\stemup} is an identifier reference.  It is shorthand for
@@ -781,35 +830,41 @@ Tuplets are made with the @code{\times} keyword.  It takes two
 arguments: a fraction and a piece of music.  The duration of the
 second argument is multiplied by the first argument.  Triplets make
 notes occupy 2/3 of their notated duration, so in this case the
-fraction is 2/3. @example 
+fraction is 2/3.
+@example 
 @{ <d8 \< f> <e g> <f a> @} 
 @end example 
 The piece of music to be `tripletted' is sequential music containing
 three notes.  On the first chord (the @code{d}), a crescendo is started
-with @code{\<}.@example 
+with @code{\<}.
+@example 
 < 
 @end example 
 At this point, the homophonic music splits into two rhythmically
 different parts.  We can't use a sequence of chords to enter this, so
 we make a `chord' of sequences to do it.  We start with the upper
-voice, which continues with upward stems: @example 
+voice, which continues with upward stems:
+@example 
  @{ \times 2/3 @{ a8 g c @} \! c2 @} 
 @end example 
 The crescendo is ended at the half note by the escaped exclamation
-mark `@code{\!}'.  @example 
+mark `@code{\!}'.
+@example 
 \context Voice = oboeTwo @{
 \stemdown 
 @end example 
 We can't share stems with the other voice, so we have to create a new
 @code{Voice} context.  We give it the name @code{oboeTwo} to distinguish
-it from the other context.  Stems go down in this voice. @example 
+it from the other context.  Stems go down in this voice.
+@example 
 \grace @{  
 @end example 
 When a grace section is processed, a @code{Grace} context is
 created. This context acts like a miniature score of its own.  It has
 its own time bookkeeping, and you can make notes, beams, slurs
 etc. Here fiddle with a property and make a beam.  The argument of
-@code{\grace} is sequential music.@example 
+@code{\grace} is sequential music.
+@example 
 \property Grace.verticalDirection = \down
 [f,16 g] @} 
 @end example 
@@ -824,7 +879,8 @@ the @code{f}.
   f8 e e2
 @} > 
 @end example 
-This ends the two-part section. @example 
+This ends the two-part section.
+@example 
 \stemboth
 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |  
 @end example 
@@ -832,7 +888,8 @@ This ends the two-part section. @example
 positioned as if it were single part music.
 
 The bass has a little hoom-pah melody to demonstrate parts switching
-between staffs.  Since it is repetitive, we use identifiers:@example 
+between staffs.  Since it is repetitive, we use identifiers:
+@example 
 hoomPah  = \notes \transpose c' @{ 
 @end example 
 Transposing can be done with @code{\transpose}.  It takes two
@@ -847,7 +904,8 @@ mode will leave the contents of @code{\hoomPah} alone.  We can use it
 without having to worry about getting the motive in a wrong
 octave@footnote{@code{hoomPah = \relative @dots{}} would be more
 intuitive to use, but that would not let me plug @code{\transpose}
-:-).}.@example 
+:-).}.
+@example 
 c8 \translator Staff = top \stemdown  
 @end example 
 We assume that the first note will be put in the lower staff.  After
@@ -855,11 +913,13 @@ that note we switch to the upper staff with @code{\translator}.  To be
 precise, this @code{\translator} entry switches the current voice to a
 @code{Staff} named @code{top}. So we have to name the upper staff
 `@code{top}'.  Stem directions are set to avoid interfering with the
-oboe voices.  @example 
+oboe voices.
+@example 
 c'8 \translator Staff = bottom \stemup @} 
 @end example 
 Then a note is put on the upper staff, and we switch again.  We have
-to name the lower staff `@code{bottom}'. @example 
+to name the lower staff `@code{bottom}'.
+@example 
 hoomPahHoomPah = @{ [\hoomPah \hoomPah] @} 
 @end example 
 Put two of these fragments in sequence, and beam them.@example 
@@ -869,17 +929,21 @@ c4 g8. b,16
 \hoomPahHoomPah 
 @end example 
 Entering the bass part is easy: the hoomPahHoomPah variable is
-referenced four times.@example 
+referenced four times.
+@example 
 \context Voice = reallyLow  @{\stemdown g2 ~ | g4 c8 @} > 
 @end example 
-After skipping some lines, we see @code{~}.  This mark makes ties.@example 
+After skipping some lines, we see @code{~}.  This mark makes ties.
+@example 
 \context PianoStaff 
 @end example 
 For piano music, a special context is needed to get cross staff
-beaming right.  It is called @code{PianoStaff}.@example 
+beaming right.  It is called @code{PianoStaff}.
+@example 
 \context Staff = bottom < \time 2/2; \clef bass; 
 @end example 
-The bottom staff must have a different clef.@example 
+The bottom staff must have a different clef.
+@example 
 indent = 0.0; 
 @end example 
 To make some more room on the line, the first (in this case the only)
@@ -893,7 +957,7 @@ parts.
 
 [TODO: demonstrate Hara-Kiri with scores and  part extraction.]
 
-@node  end of tutorial, , , Tutorial
+@node  end of tutorial
 @section The end        
          
 That's all folks.  From here, you can either try fiddling with input