]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tutorial.itely
patch::: 1.3.137.jcn4
[lilypond.git] / Documentation / user / tutorial.itely
index 2160899c590386d964f33e1355e9342019c805bf..aa10de9e43b40588b7d16f43be06cf22a257381f 100644 (file)
@@ -4,13 +4,15 @@
 @chapter Tutorial
 
 @menu
-* Introduction::                   Introduction
-* Running LilyPond::               Getting started
-* The first tune::                 The first tune
-* Lyrics and chords::              Lyrics and chords
-* More movements::                 More than one movement in a file
-* A piano excerpt::                    Piano music
-* end of tutorial::                The end
+* Introduction::                Introduction
+* Running LilyPond::            Getting started
+* The first tune::              The first tune
+* Lyrics and chords::           Lyrics and chords
+* More movements ::             
+* A piano excerpt::             Piano music
+* An orchestral score::         
+* Part extraction::             
+* end of tutorial::             The end
 @end menu
 
 @node Introduction
@@ -157,7 +159,7 @@ settings and titling.
         ly2dvi test.ly
 @end example
 After some disk-activity, you should end up with a @file{.dvi} file.
-Ly2dvi is further described in the Chapter @ref{ly2dvi}.
+Ly2dvi is further described in the @ref{ly2dvi}.
 
 Secondly, you can generate PostScript directly. This is  useful if you
 can not or do not want to  run @TeX{} on your system. 
@@ -168,12 +170,13 @@ To obtain PS output, invoke LilyPond as follows:
 @end example
 
 You have to set some environment variables to view or print this
-output. More information can be found in the Section @ref{Invoking
+output. More information can be found in the @ref{Invoking
 LilyPond}.
 
 Finally, there is a script called lilypond-book, that allows you to
 freely mix LilyPond input with Texinfo or LaTeX input. For example, this
-manual was written using lilypond-book.
+manual was written using lilypond-book. lilypond-book is discussed in
+@ref{lilypond-book}.
 
 @unnumberedsubsec Windows
 
@@ -278,14 +281,14 @@ higher is @code{c''}.  One and two octaves below the central C is
 denoted by @code{c} and @code{c,} respectively.
 
 @cindex relative
-For pitches in a long piece you might have to type many quotes.  To
-remedy this, LilyPond has a ``relative'' octave entry mode.  In this
-mode, octaves of notes without quotes are chosen such that a note is
-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.
+For pitches in a long piece you might have to type many quotes. It is
+easy to make typing errors with this, so LilyPond has a special entry
+mode to remedy this.  In this ``relative'' octave mode, octaves of notes
+without quotes are chosen such that a note is 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 
 
         \sequential @{
@@ -476,8 +479,7 @@ The last brace ends the @code{\score} block.
 @node Lyrics and chords
 @section Lyrics and chords
 
-In this section we show how to typeset a song.@footnote{The author would
-welcome information about the origin of this song.}. This file is
+In this section we show how to typeset a song. This file is
 included as @file{flowing.ly}.
 
 @example 
@@ -524,9 +526,9 @@ accompaniment =\chords @{
 @end example 
 
 
-The result would look this@footnote{The titling and font size shown
+The result would look this.@footnote{The titling and font size shown
 may differ, since the titling in this document is not generated by
-@file{ly2dvi}.}.
+@file{ly2dvi}.}
 
 @center @strong{The river is flowing}
 @center Traditional 
@@ -931,7 +933,7 @@ not generated by ly2dvi, so details will differ.}
 
 @center @strong{Two miniatures}
 @flushright
-  Opus 1.
+Opus 1.
 @end flushright
 @flushleft
 @var{Up}
@@ -944,7 +946,7 @@ not generated by ly2dvi, so details will differ.}
   }
 @end lilypond
 @flushright
-  Opus 2.
+Opus 2.
 @end flushright
 @flushleft
 @var{Down}
@@ -1103,46 +1105,46 @@ under  the name @file{sammartini.ly}.
 @lilypond[verbatim]
 \include "paper16.ly";
 
-stemdown = \property Voice.Stem \override #'direction = #-1
-stemup = \property Voice.Stem \override #'direction = #1
-stemboth = \property Voice.Stem \revert #'direction  
+stemDown = \property Voice.Stem \override #'direction = #-1
+stemUp = \property Voice.Stem \override #'direction = #1
+stemBoth = \property Voice.Stem \revert #'direction  
 
 viola = \notes \relative c' \context Voice = viola {
        <c4-\f-\arpeggio g' c>
-       \stemdown g'8. b,16
+       \stemDown g'8. b,16
        s1 s2. r4
        g
 }
 
 oboes = \notes \relative c'' \context Voice = oboe {
-       \stemup s4  g8. b,16 c8 r <e'8.^\p g> <f16 a>
+       \stemUp s4  g8. b,16 c8 r <e'8.^\p g> <f16 a>
        \grace <e8( g> <d4 f> <c2 e> \times 2/3 { <d8 \< f> <e g> <f a> }
        <
          { \times 2/3 { a8 g c } \! c2 }
          \context Voice = oboeTwo {
-               \stemdown
+               \stemDown
                \grace {
                  \property Grace.Stem \override #'direction = #-1
                  [f,16 g] }
                f8 e e2
        } >
-       \stemboth
+       \stemBoth
        \grace <c,8( e> <)b8. d8.-\trill> <c16 e> | 
        [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r  |
        [<c16( e>  < )e8. g>] <c8 e,>
 }
 
 hoomPah  =  \repeat unfold 8
-  \notes  \transpose c' { c8 \stemdown c'8 \stemup }
+  \notes  \transpose c' { c8 \stemDown c'8 \stemUp }
 
 bassvoices = \notes \relative c' {
        c4 g8. b,16
        \autochange Staff \hoomPah
        \translator Staff = down
-       \stemdown [c8 c'8] r4
+       \stemDown [c8 c'8] r4
        <g d'> r4
-       < {\stemup r2 <e4 c'> <c8 g'> }
-         \context Voice = reallyLow  {\stemdown g2 ~ | g4 c8 } >
+       < {\stemUp r2 <e4 c'> <c8 g'> }
+         \context Voice = reallyLow  {\stemDown g2 ~ | g4 c8 } >
 }
 
 \score {
@@ -1166,7 +1168,7 @@ If it looks like incomprehensible gibberish to you, then you are right.
 This example has been doctored to have as many quirks as possible.
 
 @example
- stemdown =  \property Voice.Stem \override #'direction = #-1
+ stemDown =  \property Voice.Stem \override #'direction = #-1
 @end example
 
 As you can see, this example features more voices on one staff. To make
@@ -1189,7 +1191,7 @@ setting remains in effect until it is reverted.
 @end example
 
 This statement reverts the old setting. If you do this, the effect of a
-@code{\stemdown} or @code{\stemup} is neutralised.
+@code{\stemDown} or @code{\stemUp} is neutralised.
 
 @code{\override} and @code{\revert} function like a stack: you can push
 values onto the grob-setting-stack with @code{\override} and you pop
@@ -1232,7 +1234,7 @@ note.
 signifying an arpeggio.
 
 @example 
-   \stemdown
+   \stemDown
 @end example 
 
 
@@ -1260,9 +1262,9 @@ 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 
-\stemup s4  g8. b,16 c8 r <e'8.-\p g> <f16 a> 
+\stemUp s4  g8. b,16 c8 r <e'8.-\p g> <f16 a> 
 @end example 
-@code{\stemup} is a reference to the @code{\property \override} command
+@code{\stemUp} is a reference to the @code{\property \override} command
 defined above.   .
 @example 
 \grace <e8 g> < d4 f> <c2 e> 
@@ -1350,11 +1352,11 @@ the @code{f}.
 @end example 
 This ends the two-part section.
 @example 
-\stemboth
+\stemBoth
 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |  
 @end example
 @cindex trill
-@cindex stemboth
+@cindex stemBoth
 
 @code{\stemBoth} ends the forced stem directions. From here, stems are
 positioned as if it were single part music.
@@ -1434,11 +1436,377 @@ to the page layout of this document.
 
 * font-size, cadenza. rhythmic staff, multi-stanza.
 
+* Simple part combining in a Hymn
 
-* Orchestral: demonstrate Hara-Kiri, part combining, part extraction,
-scores, transposition, instrument names,
 
-]
+@node An orchestral score
+@section An orchestral score
+
+If you've come this far, you should have seen enough LilyPond source to
+feel comfortable with an orchestral score.  We will not go through the
+input line by line, but only indicate and explain the new elements.
+
+This orchestral score example consists of three input files.  In the
+first file, @file{os-music.ly}, we define the music for all instruments.
+This file is to be used by the other two files, as you will see below.
+If you run lilypond on this file, no output will be produced.
+
+
+@example
+% os-music.ly
+\header @{
+  title = "Zo, goed lieverd?";
+  subtitle = "How's, this babe?";
+  composer = "JCN";
+  opus = "1";
+  piece = "Laid back";
+@}
+global = @{
+  \time 2/4;
+  \skip 2*4; \bar "|.";
+@}
+Key = \notes \key as \major;
+flautoI = \notes\relative c'' @{
+  f8 g f g f g f g
+  bes as bes as bes as bes as
+@}
+flautoII = \notes\relative c'' @{
+  as8 bes as bes R1 d4 ~ d
+@}
+tromboI = \notes\relative c'' @{
+  c4. c8 c8 c4. es4 R1*1/2 es4
+@}
+tromboII = \notes\relative c'' @{
+  as4. as8 as8 as4. R1*1/2 as4 es'
+@}
+timpani = \notes\relative c, @{
+  \times 2/3 @{ f4 f f @}
+  \times 4/5 @{ as8 as as as as @}
+@}
+corno = \notes\relative c' @{
+   bes4 d f, bes d f, bes d
+@}
+@end example
+
+Things to note here are the definition of @code{\global} where we define
+meter, and set the end bar.  And the separate definition of @code{\Key}
+that we will use all staffs except staffs for transposing instruments. 
+
+The second file, @file{os-score.ly} reads the definitions of the first
+(@file{os-music.ly}), and defines the @code{\score} block for the full
+conductor's score.
+
+@example
+% os-score.ly
+\include "os-music.ly";
+\include "paper13.ly";
+
+#(set! point-and-click #t)
+#(define text-flat '((font-relative-size . -2)
+         (music "accidentals--1")))
+
+\score @{
+  <
+    \global
+    \context StaffGroup = woodwind <
+      \context Staff = flauti <
+       \property Staff.midiInstrument = #"flute"
+       \property Staff.instrument = "2 Flauti"
+       \property Staff.instr = "Fl."
+        \Key
+       \context Voice=one @{ \voiceOne \flautoI @}
+       \context Voice=two @{ \voiceTwo \flautoII @}
+      >
+    >
+    \context StaffGroup = timpani <
+      \context Staff = timpani <
+       \property Staff.midiInstrument = #"timpani"
+       \property Staff.instrument = #'(lines "Timpani" "(C-G)")
+       \property Staff.instr = #"Timp."
+       \clef bass;
+        \Key
+       \timpani
+      >
+    >
+    \context StaffGroup = brass <
+      \context Staff = trombe <
+       \property Staff.midiInstrument = #"trumpet"
+       \property Staff.instrument = #`(lines "2 Trombe" "(C)")
+       \property Staff.instr = #`(lines "Tbe." "(C)")
+        \Key
+       \context Voice=one \partcombine Voice
+         \context Thread=one \tromboI
+         \context Thread=two \tromboII
+      >
+      \context Staff = corni <
+        \property Staff.midiInstrument = #"french horn"
+       \property Staff.instrument = #`(lines "Corno"
+          (rows "(E" ,text-flat ")"))
+       \property Staff.instr = #`(lines "Cor."
+          (rows "(E" ,text-flat ")"))
+       \property Staff.transposing = #3
+       \notes \key bes \major;
+       \context Voice=one \corno
+      >
+    >
+  >
+  \paper @{
+    indent = 15 * \staffspace;
+    linewidth = 60 * \staffspace;
+    textheight = 90 * \staffspace;
+    \translator@{
+      \ThreadContext
+      \consists "Rest_engraver";
+    @}
+    \translator@{
+      \VoiceContext
+      \remove "Rest_engraver";    
+    @}
+    \translator@{
+      \HaraKiriStaffContext
+    @}
+    \translator @{
+      \OrchestralScoreContext
+      BarNumber \override #'padding = #3
+    @}
+  @}
+  \midi @{
+    \tempo 4 = 75;
+  @}
+@}
+@end example
+
+@center @strong{Zo, goed lieverd?}
+@sp 1
+@center How's, this babe?
+@flushright
+Opus 1.
+@end flushright
+@flushleft
+@sc{Laid back}
+@end flushleft
+
+@lilypondfile{os-score.ly}
+
+First, we need to include the music definitions we made in
+@file{os-music.ly}.
+@example
+\include "os-music.ly";
+@end example
+
+In a large orchestral score like this you're bound to make some small
+mistakes, so we enable point and click (See @ref{Point and click})
+editing.
+@example
+#(set! point-and-click #t)
+@end example
+
+We need a flat sign in text to name the tuning of the french horn, so we
+predefine it with bit of scheme markup text (See @ref{Text markup}).
+@example
+#(define text-flat '((font-relative-size . -2)
+         (music "accidentals--1")))
+@end example
+
+Of course, all staffs are simultaneous and use the same global settings.
+@example
+  <
+    \global
+@end example
+
+Then, we start a new staff group for the woodwind section (just the
+flutes in this case).  Immediately after that, we start the staff for
+the two flutes, that also play simultaneously.
+@example
+    \context StaffGroup = woodwind <
+      \context Staff = flauti <
+@end example
+
+We specify the intrument for MIDI output (see @ref{MIDI instrument
+names}).
+@example
+       \property Staff.midiInstrument = #"flute"
+@end example
+
+And define the intrument names to be printed in the margin,
+@code{instrument} for the first line of the score, @code{instr} for the
+rest of the score.
+@example
+       \property Staff.instrument = "2 Flauti"
+       \property Staff.instr = "Fl."
+@end example
+
+The flutes play in the default key.
+@example
+        \Key
+@end example
+
+Last come the actual flute parts.  Remember that we're still in
+simultaneous mode.  We name both voices differently, so that LilyPond
+will actually create two Voice contexts.  The flute parts are simple, so
+we specify manually which voice is which: @code{\voiceOne} forces the
+direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
+directions down.
+@example
+       \context Voice=one @{ \voiceOne \flautoI @}
+       \context Voice=two @{ \voiceTwo \flautoII @}
+@end example
+
+We close the flutes staff and woodwind staff group.
+@example
+      >
+    >
+@end example
+
+The timpani staff only shows a new piece of scheme markup, it sets two
+lines of text.
+@example
+       \property Staff.instrument = #'(lines "Timpani" "(C-G)")
+@end example
+
+For the trumpets we use the automatic part combiner (see @ref{Automatic
+part combining}) to combine the two simultaneous trumpet parts onto the
+trumpet staff.  Each trumpet gets its own Thread context, which must be
+named @code{one} and @code{two}).  The part combiner makes these two
+threads share a Voice when they're similar, and splits the threads up
+when they're different.
+@example
+       \context Voice=one \partcombine Voice
+         \context Thread=one \tromboI
+         \context Thread=two \tromboII
+@end example
+
+The french horn has the most complex scheme markup name, made up of two
+lines of text.  The second line has two elements (rows), the @code{E}
+and the flat sign @code{text-flat} that we defined before.
+@example
+       \property Staff.instrument = #`(lines "Corno"
+          (rows "(E" ,text-flat ")"))
+@end example
+
+The french horn is to be tuned in E-flat, so we tell the MIDI backend to
+transpose this staff by three steps.
+@example
+       \property Staff.transposing = #3
+@end example
+
+Therefore, it has a different key.
+@example
+       \notes \key bes \major;
+@end example
+
+We specify a big indent for the first line and a small linewith for this
+tuturial.
+@example
+    indent = 15 * \staffspace;
+    linewidth = 60 * \staffspace;
+@end example
+
+Because we have a Thread representing one instument, we move the
+need the @code{Rest_engraver} from Voice to Thread level.
+@example
+    \translator@{
+      \ThreadContext
+      \consists "Rest_engraver";
+    @}
+    \translator@{
+      \VoiceContext
+      \remove "Rest_engraver";    
+    @}
+@end example
+
+In orchestral scores, it often happens that one instrument has only
+rests during one line of the score.  The @code{HaraKiriStaffContext} can
+be used as a regular @code{StaffContext} drop-in and will take care of
+the automatic removing of empty staffs.
+@example
+    \translator@{
+      \HaraKiriStaffContext
+    @}
+@end example
+
+We want bar numbering at score level and want to move the bar number a
+few staff spaces up.
+@example
+    \translator @{
+      \OrchestralScoreContext
+      BarNumber \override #'padding = #3
+    @}
+@end example
+
+@node Part extraction
+@section Part extraction
+
+The third file, @file{os-flute-2.ly} also reads the definitions of the
+first (@file{os-music.ly}), and defines the @code{\score} block for the
+second flute part.
+
+@example
+\include "os-music.ly";
+\include "paper16.ly";
+
+\score @{
+  \context Staff <
+    \property Staff.midiInstrument = #"flute"
+    \global
+    \Key
+    \flautoII
+  >
+  \header @{
+    instrument = "Flauto II";
+  @}
+  \paper @{
+    linewidth = 80 * \staffspace;
+    textheight = 200 * \staffspace;
+    \translator @{
+      \OrchestralScoreContext
+      skipBars = ##t
+    @}
+  @}
+  \midi @{
+    \tempo 4 = 75;
+  @}
+@}
+@end example
+
+@center @strong{Zo, goed lieverd?}
+@sp 1
+@center How's, this babe?
+@center @emph{Flauto II}
+@flushright
+Opus 1.
+@end flushright
+@flushleft
+@sc{Laid back}
+@end flushleft
+@lilypondfile{os-flute-2.ly}
+
+
+Because we separated the music definitions from the @code{\score}
+instantiations, we can easily define a second score from the music of
+the second flute.  This then is the part for the second flute player.
+Of course, we make separate parts for all individual instruments.
+
+In this individual part the second flute has a whole staff for itself,
+so we don't want to force stem or tie directions.
+@example
+    \flautoII
+@end example
+
+The @code{\header} definitions were also read from @file{os-music.ly},
+but we need to set the instrument for this particular score.
+@example
+  \header @{
+    instrument = "Flauto II";
+  @}
+@end example
+
+In the conductor's full score, all bars with rests are printed, but for
+the individual parts, we want to contract pieces of consecutive empty
+bars.
+@example
+      skipBars = ##t
+@end example
 
 @node  end of tutorial
 @section The end