]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tutorial.itely
* input/test/time-signature-double.ly: new file
[lilypond.git] / Documentation / user / tutorial.itely
index 9a05dff775e2dbd62176e9c466efdc799e996ef1..047f71dc60f0f7e0ec55b823d44093f19ffba283 100644 (file)
@@ -1,4 +1,4 @@
- @c -*-texinfo-*-
+@c -*-texinfo-*-
 
 @c TODO:
 @c   * LilyPond Lilypond lilypond (sometimes: the program)
@@ -54,9 +54,12 @@ c d e f g a b
 @noindent
 then the result looks like this:
 
-@lilypond[notime]
-\property Score.timing = ##f
-\transpose c'' { c d e f g a b }
+@c ?
+@c \transpose c c' { c d e f g a b }
+@c @lily pond[notime]
+@c \property Score.timing = ##f
+@lilypond[notime, relative=2]
+c d e f g a b
 @end lilypond
 
 We will continue with this format: First we show a snippet of input,
@@ -72,7 +75,7 @@ a1 a2 a4 a16 a32
 @lilypond[notime]
 \property Score.timing = ##f
 \property Staff.autoBeaming = ##f
-\transpose c'' { a1 a2 a4 a16 a32 s16_" " }
+\transpose c c' { a1 a2 a4 a16 a32 s16_" " }
 @end lilypond
 
 If you don't specify a @rglos{duration}, the previous one is used: 
@@ -83,7 +86,7 @@ a4 a a2 a
 
 @lilypond[notime]
 \property Score.timing = ##f
-\transpose c'' { a a a2 a s16_" " }
+\transpose c c' { a a a2 a s16_" " }
 @end lilypond
 
 A @rglos{sharp} (@texisharp{}) is made by adding @samp{is}, a
@@ -97,7 +100,7 @@ cis1 ees fisis aeses
 
 @lilypond[notime]
 \property Score.timing = ##f
-\transpose c'' { cis1 ees fisis aeses s16_" " }
+\transpose c c' { cis1 ees fisis aeses s16_" " }
 @end lilypond
 
 Add a dot @samp{.} after the duration to get a @rglos{dotted note}:
@@ -108,7 +111,7 @@ a2. a4 a8. a16
 
 @lilypond[notime]
 \property Score.timing = ##f
-\transpose c'' { a2. a4 a8. a16 s16_" " }
+\transpose c c' { a2. a4 a8. a16 s16_" " }
 @end lilypond
 
 The @rglos{meter} (or @rglos{time signature}) can be set with the
@@ -345,7 +348,7 @@ You can also print from the command line by executing:
 
 To run LilyPond, input a text file, then run the command @code{ly2dvi} on
 that file.  The resulting files are either DVI or PostScript, and can
-be viewed with @code{xdvi} (unix) and ghostview (unix and windows)
+be viewed with @code{xdvi} (Unix) and ghostview (Unix and Windows)
 respectively.  The following table summarizes the constructs that were
 discussed in the previous two sections.
 
@@ -448,19 +451,26 @@ c'4 c'' c''' \clef bass c c,
 @end quotation
 @separate
 
-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; it just makes the first note sound longer:
-
+A tie is created by adding a tilde ``@code{~}'' to the first note
+being tied.
 @quotation
 @lilypond[fragment,verbatim]
-g'4 ~ g' a'2 ~ a'4
+g'4-~ g' a'2-~ a'4
 @end lilypond
 @end quotation
 @separate
+A tie is different from a slur. A tie simply makes the first note
+sound longer, and can only be used on pairs of notes with the same
+pitch. Slurs indicate the articulations of notes, and can be used on
+larger groups of notes. Slurs and ties are also nested in practice:
+@lilypond[fragment, relative=1]
+c2-~-( c8 fis fis4 ~ fis2 g2-)
+@end lilypond
+
 
-The key signature is set with the command ``@code{\key}''.  One caution:
-you need to specify whether the key is @code{\major} or @code{\minor}.
+The key signature is set with the command ``@code{\key}''.  One
+caution word of caution: you need to specify whether the key is
+@code{\major} or @code{\minor}.
 @quotation
 @example
 \key d \major
@@ -491,8 +501,8 @@ This example shows notes, ties, octave marks, and rests in action.
     \key d \minor
     \clef violin
     r4 r8 d''8 cis''4 e''
-    d''8 a'4. ~ a' b'8
-    cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
+    d''8 a'4.-~ a' b'8
+    cis''4 cis''8 cis'' bis'4 d''8 cis''-~
     cis''2 r2
   @}
   \paper @{ @}
@@ -506,8 +516,8 @@ This example shows notes, ties, octave marks, and rests in action.
     \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'' ~
+    d''8 a'4.-~ a' b'8
+    cis''4 cis''8 cis'' bis'4 d''8 cis''-~
     cis''2 r2
   }
   \paper { linewidth = 50*\staffspace }
@@ -692,7 +702,7 @@ A slur is drawn across many notes, and indicates bound articulation
 
 @quotation
 @lilypond[fragment,relative 1, verbatim]
-d4( )c16( cis d e c cis d )e( )d4
+d4-( c16-)-( cis d e c cis d e-)-( d4-)
 @end lilypond
 @end quotation
 @separate
@@ -711,17 +721,17 @@ phrasing), you can also make a phrasing slur with @code{\(} and
 
 @quotation
 @lilypond[fragment,relative 1, verbatim]
-a8(\( ais b ) c cis2 b'2 a4 cis, \) c
+a8-(-\( ais b  c-) cis2 b'2 a4 cis,  c-\)
 @end lilypond
 @end quotation
 @separate
 
 Beams are drawn automatically, but if you don't like the choices, you
-can enter beams by hand. Surround the notes to be grouped with @code{[}
-and @code{]}:
+can enter beams by hand. Mark the first note to be beamed with
+@code{[} and the last one with @code{]}:
 @quotation
 @lilypond[fragment,relative 1, verbatim]
-[a8 ais] [d es r d]
+a8-[ ais-] d-[ es r d-]
 @end lilypond
 @end quotation
 @separate
@@ -742,7 +752,10 @@ demonstrated here:
 
 In this example, @code{staffA} and @code{staffB} are names that are
 given to the staves.  It doesn't matter what names you give, as long
-as each staff has a different name.
+as each staff has a different name. If you give them the same name,
+LilyPond will assume that you only want one staff, and will but both
+pieces of music on the same staff.
+
 
 @separate
 
@@ -755,7 +768,7 @@ We can now typeset a melody with two staves:
   < \context Staff = staffA {
       \time 3/4
       \clef violin
-      \relative c'' { e2 ( d4 c2 b4 [a8 a] [b b] [g g] )a2. }  
+      \relative c'' { e2-( d4 c2 b4 a8-[ a-] b-[ b-] g-[ g-] a2.-) }  
     }
     \context Staff = staffB {
        \clef bass
@@ -791,85 +804,46 @@ c-\ff c-\mf
 @separate
 
 Crescendi and decrescendi are started with the commands @code{\<} and
-@code{\>}. The command @code{\!} finishes a crescendo on the following
-note.
+@code{\>}. The command @code{\!} finishes a crescendo on the note it
+is attached to.
 @quotation
 @lilypond[verbatim,relative 1]
-c2\<  \!c2-\ff  \>c2  \!c2
+c2-\<  c2-\!-\ff  c2-\>  c2-\!
 @end lilypond
 @end quotation
 @separate
 
-Chords can be made by surrounding notes with @code{<} and @code{>}:
+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>>4 <<c f a>>8
 @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 staves.
-@end ignore
 
 You can combine beams and ties with chords.  Beam and tie markings
 must be placed outside the chord markers:
 @quotation
 @lilypond[relative 0, fragment,verbatim]
-r4 [<c8 e g> <c8 f a>] ~ <c8 f a>
+r4 <<c e g>>8-[ <<c f a>>-]-~ <<c f a>>
 @end lilypond
 @end quotation
 
+@ignore
 When you want to combine chords with slurs and dynamics, technical
 detail crops up: you have type these commands next to the notes, which
 means that they have to be inside the @code{< >}.  Don't get confused
 by the chord @code{< >} and the dynamic @code{\< \>}!
-
+@end ignore
 
 @quotation
 @example
-r4 <c8 e g \> ( > <c e g> <c e g>  < ) \! c8 f a>
+r4 <<c e g>>8-\>-( <<c e g>> <<c e g>>  <<c f a>>8-\!-\)
 @end example
 @lilypond[relative 0, fragment]
 \slurUp
-r4 <c8 e g \> ( > <c e g> <c e g>  < ) \! c8 f a>
-@end lilypond
-@end quotation
-@separate
-
-@c   this example is a bit too strongly worded -- there's nothing wrong
-@c   with starting a piece with a chord; you just have to be careful when
-@c   you do so.  I've rephrased this example below.
-@c There is one golden rule that you should keep in mind when writing
-@c LilyPond input:
-@c @quotation
-@c @strong{DO NOT START A PIECE WITH A CHORD}
-@c @end quotation
-@c Of course, it is a allowed, but the result might not be what you expect:
-
-@c   rephrased "don't start with a chord"
-There is one caution when using chords: if you use a chord at the very
-beginning of the piece, LilyPond might not understand what you want:
-
-@quotation
-@lilypond[verbatim,singleline]
-\score { \notes <c'2 e'2> }
-@end lilypond
-@end quotation
-@separate
-
-If you have a piece that begins with a chord, you must explicitly
-state that the notes of the chord are to be put on the same staff, in
-the same voice.  This is done by specifying @code{\context Staff} or
-@code{\context Voice} for the notes:
-
-@quotation
-@lilypond[verbatim,singleline]
-\score { \notes \context Voice <c'2 e'2> }
+r4 <<c e g>>8-\>-( <<c e g>> <<c e g>>  <<c f a>>8-\!-\)
 @end lilypond
 @end quotation
 @separate
@@ -892,7 +866,7 @@ the same voice.  This is done by specifying @code{\context Staff} or
 \property Staff.TimeSignature = \turnOff
 \property Staff.autoBeaming = ##f
 \property Staff.Clef = \turnOff
-c( d )e
+c-( d e-)
 @end lilypond
 
 
@@ -904,7 +878,7 @@ c( d )e
 \property Staff.TimeSignature = \turnOff
 \property Staff.autoBeaming = ##f
 \property Staff.Clef = \turnOff
-c\(  c() d \)e
+c-\(  c-( d-) e-\)
 @end lilypond
 
 
@@ -916,7 +890,7 @@ c\(  c() d \)e
 \property Staff.TimeSignature = \turnOff
 \property Staff.autoBeaming = ##f
 \property Staff.Clef = \turnOff
-[a8 b]
+a8-[ b-]
 @end lilypond
 
 
@@ -968,15 +942,15 @@ a\< a \!a
 \property Staff.TimeSignature = \turnOff
 \property Staff.autoBeaming = ##f
 \property Staff.Clef = \turnOff
-a\> a \!a
+a-\> a a-\!
 @end lilypond
 
 
-@item @code{< >}
+@item @code{<< >>}
 @tab chord
 @tab
 @lilypond[fragment, relative 1]
-\context Voice <c e
+<<c e>
 @end lilypond
 
 @end multitable
@@ -993,8 +967,6 @@ polyphonic music, and integrating text and music.
 
 
 
-
-
 @node Printing lyrics
 @section Printing lyrics
 @cindex lyrics
@@ -1006,8 +978,8 @@ fragment of The Free Software Song:
 \score  { \notes { \addlyrics
   \notes \relative c' {
     \time 7/4
-    d'2 c4 b16 ( a g a b a b ) c a2
-    b2 c4 b8 ( a16 g ) a4 g2 }
+    d'2 c4 b16-( a g a b a b c-) a2
+    b2 c4 b8-( a16 g a4-) g2 }
   \context Lyrics \lyrics { 
     Join us now __ and
     share the soft -- ware; }
@@ -1085,8 +1057,8 @@ The melody of the song doesn't offer anything new:
 @example
  \notes \relative c' @{
     \time 7/4
-    d'2 c4 b16 ( a g a b a b ) c a2
-    b2 c4 b8 ( a16 g ) a4 g2 @}
+    d'2 c4 b16-( a g a b a b c-) a2
+    b2 c4 b8-( a16 g a4-) g2 @}
 @end example
 
 Both can be combined with the @code{\addlyrics}:
@@ -1119,6 +1091,8 @@ The complete file is listed here:
 @node A melody with chords 
 @section A melody with chords
 
+[TODO: show how to do fixed 4 measures to the line]
+
 In this section we show how to typeset a melody with chord
 accompaniment. This file is included as @file{input/tutorial/flowing.ly}.
 
@@ -1128,8 +1102,8 @@ 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.
+        c4 c8 d es-[ -( d-]-) c4 | f4 f8 g es-[-( d-)-] c g |
+        c4 c8 d es-[ -( d-]-) c4 | d4 es8 d c4.
         \bar "|."
 @}
 
@@ -1161,8 +1135,8 @@ 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.
+        c4 c8 d es-[ -( d-)-] c4 | f4 f8 g es-(-[  d-)-] c g |
+        c4 c8 d es-(-[ d-]-) c4 | d4 es8 d c4.
         \bar "|."
 }
 
@@ -1486,8 +1460,6 @@ The convention for naming @code{LyricsVoice} and @code{Voice} must
 also be used to get melismata on rests correct.
 
 
-@c    I think we need to change the name of this section, but that
-@c    would probably involve a lot of changes in other places too.
 @node More movements 
 @section More movements
 
@@ -1497,16 +1469,6 @@ you need to use @code{ly2dvi}, which comes with LilyPond.  @code{ly2dvi}
 creates the title, then calls @code{lilypond} to format the sheet music.
 In this section, we show you how to create titles like this:
 
-@c    Old version of the above paragraph.
-@c LilyPond only produces sheet music; it doesn't concern itself with
-@c producing titles.  Titles are produced using a simply wrapper program
-@c This is the jobs of a simple wrapper
-@c program called ly2dvi. @code{ly2dvi} calls LilyPond to do the
-@c sheet music formatting. Then it produces titles, and ties together all
-@c inputs into a single @file{dvi} file.  In this section, we show some of
-@c the options  for titling.  We will show how you can produce a file
-@c that looks like this:
-
 @center @strong{Two miniatures}
 @flushright
 Opus 1.
@@ -1595,7 +1557,7 @@ versions using old print-outs.
 @cindex tag line
 
 Many people find the default tagline (``Lily was here'') too droll.  
-If that is the case, you can change @code{tagline} to somethign else,
+If that is the case, you can change @code{tagline} to something else,
 as shown above.
 
 @separate
@@ -1749,16 +1711,14 @@ precisely one @code{Voice} context, so we give it a unique name
 
 @separate
 @example 
-<c4-\arpeggio g' c>
+<<c g' c>>4-\arpeggio
 @end example 
-The delimiters @code{<} and @code{>} are shorthands for
-@code{\simultaneous @{} and @code{@}}. The expression enclosed in
-@code{<} and @code{>} is a chord.
+The delimiters @code{<<} and @code{>>} enclose the pitches of a chord.
+@code{\arpeggio} typesets an arpeggio sign (a wavy vertical line)
+before the chord.
 
 @cindex arpeggio
 
-@code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
-the chord.
 
 @separate
 @example 
@@ -1800,7 +1760,7 @@ these notes are indeed processed by precisely one context with
 @code{\context}.
 @separate
 @example 
-\voiceOne s4  g8. b,16 c8 r <e'8. g> <f16 a> 
+\voiceOne s4  g8. b,16 c8 r <<e' g>>8. <<f a>>16
 @end example
 
 The oboes should have stems up to keep them from interfering with
@@ -1808,7 +1768,7 @@ the staff-jumping bass figure.  To do that, we use @code{\voiceOne}.
 
 @separate
 @example 
-\grace <e8( g> < d4 )f> <c2 e> 
+\grace <<e g>>-( <<d f>>4-) <<c e>>2 
 @end example
 @cindex @code{\grace}
 @cindex ornaments
@@ -1829,7 +1789,7 @@ of music is multiplied by the fraction.  Triplets make notes occupy 2/3
 of their notated duration, so in this case the fraction is 2/3.
 @separate
 @example 
-@{ <d8 f> <e g> <f a> @} 
+@{ <<d f>>8 <<e g>> <<f a>> @} 
 @end example 
 The piece of music to be `tripletted' is sequential music containing
 three chords.
@@ -1870,7 +1830,7 @@ This ends the two-part section.
 @separate
 @example 
 \stemBoth
-\grace <c,8( e> <)b8. d8.-\trill> <c16 e> |  
+\grace <<c, e>>8-( <<b d>>8.-\trill <<c e>>16 |  
 @end example
 @cindex trill
 @cindex stemBoth
@@ -1945,7 +1905,7 @@ manual staff switch here.
 
 @separate
 @example 
-\context Voice = reallyLow  @{\stemDown g2 ~ | g4 c8 @} > 
+\context Voice = reallyLow  @{\stemDown g2-~ | g4 c8 @} > 
 @end example
 @cindex tie
 @cindex @code{~}
@@ -2192,13 +2152,14 @@ a collision with the slur.  This could be achieved with
 works.  We insert an empty text between the 5 and the note. The empty
 text pushes the fingering instruction away:
 @example
-  a^" "^#'(finger "5")
+  a-)^" "^\markup @{ \finger "5" @} 
 @end example
 
-Lilypond tries to put fingering instructions as close to the notes as
-possible.  To make sure that Lilypond doesn't do that, we disguise the
-fingering as text: @code{(finger "5")}.
-
+A fingering instruction, which would be entered as @code{^5}, is put
+as close to the notes as possible, closer than the space entered to 
+push away the 5. Hence, the 5 is entered as a normal text, formatting
+of fingering instructions.  
 @separate
 
 Normally one would specify all dynamics in the same voice, so that
@@ -2257,6 +2218,9 @@ these ties: whenever we need such a tie, we insert a notehead in a
 different voice, and blank the stem.  This is done in the following
 snippet of code.
 
+@cindex transparent objects
+@cindex removing objects
+@cindex invisible objects
 @example
 \property Voice.Stem \set #'transparent = ##t
 d'
@@ -2377,72 +2341,75 @@ for transposing instruments.
 @subsection The full score
 
 
-The second file, @file{input/tutorial/os-score.ly}, reads the definitions of the first
-(@file{input/tutorial/os-music.ly}), and defines the @code{\score} block for the full
-conductor's score.
-
+The second file, @file{input/tutorial/os-score.ly}, reads the
+definitions of the first (@file{input/tutorial/os-music.ly}), and
+defines the @code{\score} block for the full conductor's score.
 
 @example
-% os-score.ly
+\version "1.7.6"
+
 \include "os-music.ly"
 \include "paper13.ly"
 
 #(ly:set-point-and-click 'line-column)
-#(define text-flat '((font-relative-size . -2)
-         (music "accidentals--1")))
-
+textFlat = \markup @{\smaller \musicglyph #"accidentals--1"@}
 \score @{
   <
     \global
     \property Score.BarNumber \override #'padding = #3
     \context StaffGroup = woodwind <
       \context Staff = flauti <
-        \property Staff.midiInstrument = #"flute"
-        \property Staff.instrument = "2 Flauti"
-        \property Staff.instr = "Fl."
+       \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 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
+       \property Staff.midiInstrument = #"timpani"
+       \property Staff.instrument = \markup @{ \column <<  "Timpani" "(C-G)" >> @}
+       \property Staff.instr = #"Timp."
+       \clef bass
         \Key
-        \timpani
+       \timpani
       >
     >
     \context StaffGroup = brass <
       \context Staff = trombe <
-        \property Staff.midiInstrument = #"trumpet"
-        \property Staff.instrument = #`(lines "2 Trombe" "(C)")
-        \property Staff.instr = #`(lines "Tbe." "(C)")
+       \property Staff.midiInstrument = #"trumpet"
+       \property Staff.instrument = \markup @{ \column << "2 Trombe" "(C)" >> @}
+       \property Staff.instr = \markup@{ \column << "Tbe." "(C)">> @}
         \Key
-        \context Voice=one \partcombine Voice
-          \context Thread=one \tromboI
-          \context Thread=two \tromboII
+       \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"
-          (columns "(E" ,text-flat ")"))
-        \property Staff.instr = #`(lines "Cor."
-          (columns "(E" ,text-flat ")"))
-        \property Staff.transposing = #3
-        \notes \key bes \major
-        \context Voice=one \corno
+       \property Staff.instrument
+       = \markup @{ \column << "Corno" @{ "(E"  \textFlat ")" @} >> @}
+       \property Staff.instr =
+       \markup @{ \column << "Cor." @{ "(E"  \textFlat ")" @} >> @}
+       \property Staff.transposing = #3
+       \notes \key bes \major
+       \context Voice=one \corno
       >
     >
   >
   \paper @{
     indent = 15 * \staffspace
-    linewidth = 55 * \staffspace
+    linewidth = 60 * \staffspace
     textheight = 90 * \staffspace
+    \translator@{
+      \VoiceContext
+      \consists "Multi_measure_rest_engraver"
+    @}
     \translator@{
       \HaraKiriStaffContext
+      \remove "Multi_measure_rest_engraver"
     @}
   @}
   \midi @{