@c TODO:
@c * more details about running lilypond; error messages,
@c compiling/viewing (emacs?)
-@c * where to go from First steps+More basics?
+@c * where to go from First steps+More basics?
@c Your first LilyPond score in 10 minutes?
picture in the HTML version of this manual, you will see the exact
LilyPond input that was used to generate that image.
Try it on this image
+
@lilypond[quote,raggedright,relative=2]
c-\markup { \bold \huge { Click here. } }
@end lilypond
@table @asis
@item Entering pitches and durations
see
-@ref{Pitches} and @ref{Durations}.
+@ref{Pitches}, and @ref{Durations}.
@item Clefs
-see @ref{Clef}
+see @ref{Clef}.
@item Rests
see @ref{Rests}.
@item Time signatures and other timing commands
@c commands to type?
@c
-@c We don't have enough space to explain either VIM
+@c We don't have enough space to explain either VIM
@c or Emacs non-advanced users, and I fear that both editors will only
@c confuse newbies. I vote for keeping the material in footnotes.
@c
@noindent
To process @file{test.ly}, proceed as follows
-@noindent
@example
lilypond test.ly
@end example
PDF output to `test.pdf'...
PS output to `test.ps'...
@end example
+
@cindex DVI file
@cindex Viewing music
@cindex xdvi
-
@noindent
The result is the file @file{test.pdf}@footnote{For @TeX{}
aficionados: there is also a @file{test.dvi} file. It can be viewed
@cindex key signature, setting
The key signature is set with the command @code{\key}, followed by
a pitch and @code{\major} or @code{\minor}
+
@example
\key d \major
g1
Adding all alterations explicitly might require a little more effort
when typing, but the advantage is that transposing is easier, and
music can be printed according to different conventions. See
-@ref{Accidentals} for some examples how accidentals can be printed
+@ref{Accidentals}, for some examples how accidentals can be printed
according to different rules.
@quotation
@table @asis
@item Accidentals
-see @ref{Accidentals}
+see @ref{Accidentals}.
@item Key signature
-see @ref{Key signature}
+see @ref{Key signature}.
@end table
@end quotation
@cindex tie
A tie is created by appending a tilde @samp{~} to the first note
being tied
+
@lilypond[quote,notime,fragment,verbatim,relative=3]
g4~ g a2~ a4
@end lilypond
@}
@}
@end example
+
@lilypond[quote, noindent]
\score {
\notes \transpose c c' {
@separate
An example of the use of quotes is in the following Mozart fragment
+
@lilypond[quote,raggedright,fragment,verbatim]
\key a \major
\time 6/8
relative to the previous one, and changing the octave of a single note
shifts all following notes an octave up or down.
-For more information on Relative octaves see @ref{Relative octaves}
+For more information on Relative octaves see @ref{Relative octaves},
and @ref{Octave check}.
((1 + 2) * 3) / (4 * 5)
@end example
+
@cindex expression
@cindex music expression
This example shows a sequence of expressions, where each expression is
to group expressions.
Like mathematical expressions, music expressions can be nested
-arbitrarily deep, e.g.
+arbitrarily deep@footnote{The reason for getting three staves in the
+previous example but just a single staff in current one will be explained
+later.}
+
@lilypond[quote,verbatim,relative=2]
{
c <<c e>>
@cindex indent
When spreading expressions over multiple lines, it is customary to use
an indent that indicates the nesting level. Formatting music like this
-eases reading, and helps you insert the right number of closing
+eases reading, and helps you insert the right number of closing
braces at the end of an expression. For example,
@example
@end example
Some editors have special support for entering LilyPond, and can help
-indenting source files. See @ref{Editor support} for more information.
+indenting source files. See @ref{Editor support}, for more information.
To print more than one staff, each piece of music that makes up a
staff is marked by adding @code{\new Staff} before it. These
-@code{Staff}'s are then combined parallel with @code{<<} and
+@code{Staff} elements are then combined parallel with @code{<<} and
@code{>>}, as demonstrated here
@lilypond[quote,fragment,verbatim]
@end lilypond
-The command @code{\new} introduces a `notation context.' A notation
+The command @code{\new} introduces a `notation context.' A notation
context is an environment in which musical events (like notes or
@code{\clef} commands) are interpreted. For simple pieces, such
notation contexts are created implicitly. For more complex pieces, it
gets its own stave.
There are several types of contexts: @code{Staff}, @code{Voice} and
-@code{Score} handle normal music notation. Other staves are also
+@code{Score} handle normal music notation. Other contexts are also
@code{Lyrics} (for setting lyric texts) and @code{ChordNames} (for
printing chord names).
In terms of syntax, prepending @code{\new} to a music expression
creates a bigger music expression. In this way it resembles the minus
-sign in mathematics. The formula (4+5) is an expression, so -(4+5) is a bigger
-expression.
+sign in mathematics. The formula @math{(4+5)} is an expression, so
+@math{-(4+5)} is a bigger expression.
We can now typeset a melody with two staves
}
\new Staff {
\clef bass
- c2 e4 g2.
+ c2 e4 g2.
f4 e d c2.
}
>>
Common accents can be added to a note using a dash (@samp{-}) and a
single character
+
@lilypond[quote,verbatim,relative=2]
c-. c-- c-> c-^ c-+ c-_
@end lilypond
@cindex fingering
Similarly, fingering indications can be added to a note using a dash
(@samp{-}) and the digit to be printed
-@c
+
@lilypond[quote,verbatim,relative=2]
c-3 e-5 b-2 a-1
@end lilypond
Dynamic signs are made by adding the markings (with a backslash) to
the note
+
@lilypond[quote,verbatim,relative=2]
c\ff c\mf
@end lilypond
Crescendi and decrescendi are started with the commands @code{\<} and
@code{\>}. An ending dynamic, for example @code{\f}, will finish the
crescendo, or the command @code{\!} can be used
+
@lilypond[quote,verbatim,relative=2]
-c2\< c2\ff\> c2 c2\!
+c2\< c2\ff\> c2 c2\!
@end lilypond
@separate
@cindex slur
A slur is a curve drawn across many notes, and indicates legato
-articulation. The starting note and ending note are marked with a
-@samp{(} and a @samp{)}, respectively
+articulation. The starting note and ending note are marked with
+@samp{(} and @samp{)}, respectively
@lilypond[quote,fragment,relative=2,verbatim]
d4( c16)( cis d e c cis d e)( d4)
@end lilypond
@separate
+
@cindex slurs versus ties
A slur looks like a tie, but it has a different meaning. A tie simply
makes the first note sound longer, and can only be used on pairs of
@lilypond[quote,fragment,relative=2]
c2~( c8 fis fis4 ~ fis2 g2)
@end lilypond
+
@cindex phrasing slurs
Slurs to indicate phrasing can be entered with @code{\(} and
@code{\)}, so you can have both legato slurs and phrasing slurs at the
same time.
@lilypond[quote,fragment,relative=2,verbatim]
-a8(\( ais b c) cis2 b'2 a4 cis, c\)
+a8(\( ais b c) cis2 b'2 a4 cis, c\)
@end lilypond
For more information on
+
+@quotation
@table @asis
@item Fingering
-see @ref{Fingering instructions}
+see @ref{Fingering instructions}.
@item Articulations
-see @ref{Articulations}
+see @ref{Articulations}.
@item Slurs
-see @ref{Slurs}
+see @ref{Slurs}.
@item Phrasing slurs
-see @ref{Phrasing slurs}
+see @ref{Phrasing slurs}.
@item Dynamics
-see @ref{Dynamics}
-@item Fingering
+see @ref{Dynamics}.
@end table
+@end quotation
+
@node Combining notes into chords
@section Combining notes into chords
You can combine markings like beams and ties with chords. They must
be placed outside the angled brackets
+
@lilypond[quote,relative=1,fragment,verbatim]
r4 <c e g>8[ <c f a>]~ <c f a>
@end lilypond
@example
-r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
+r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
@end example
+
@lilypond[quote,relative=1,fragment]
\slurUp
-r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
+r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
@end lilypond
@separate
@node Basic rhythmical commands
-@section Basic rhythmical commands
+@section Basic rhythmical commands
@cindex pickup
@cindex anacruse
A pickup is entered with the keyword @code{\partial}. It
is followed by a duration: @code{\partial 4} is a quarter note upstep
and @code{\partial 8} an eighth note
+
@lilypond[quote,relative=2,verbatim,fragment]
\partial 8
f8 c2 d e
@end lilypond
+
@cindex tuplets
@cindex triplets
Tuplets are made with the @code{\times} keyword. It takes two
arguments: a fraction and a piece of music. The duration of the piece
of music is multiplied by the fraction. Triplets make notes occupy
-2/3 of their notated duration, so a triplet has 2/3 as its fraction
-@c
+2/3 of their notated duration, so a triplet has 2/3 as its fraction
+
@lilypond[quote,relative=1,verbatim,fragment]
\times 2/3 { f8 g a }
\times 2/3 { c r c }
@end lilypond
+
@cindex grace notes
@cindex accacciatura
Grace notes are also made by prefixing a music expression with the
@noindent
For more information on
+
@table @asis
-@item Grace notes
+@item Grace notes
see @ref{Grace notes},
@item Tuplets
see @ref{Tuplets},
@example
% notes for twinkle twinkle follow
-c4 c g' g a a
+c4 c g' g a a
%@{
This line, and the notes below
pitch, the input-mode must be switched. This is done with
@code{\lyrics}. In @code{\lyrics} mode, all words are read as lyric
syllables.
+
@example
\lyrics @{ I want to break free @}
@end example
to explicitly specify a @code{Lyrics} context,
@example
-\new Lyrics \lyrics @{ I want to break free @}
+\new Lyrics \lyrics @{ I want to break free @}
@end example
The melody for this song is as follows
The lyrics can be set to these notes, combining both with the
@code{\lyricsto} keyword
+
@example
\lyricsto "@var{name}" \new Lyrics @dots{}
@end example
+
+@noindent
where @var{name} identifies to which melody the lyrics should be
aligned. In this case, there is only one melody, so we can leave it
empty.
The final result is
+
@lilypond[quote,verbatim,fragment,raggedright]
-\score {
+\score {
\notes <<
\partial 4
\relative c' {
This melody ends on a @rglos{melisma}, a single syllable (`free')
sung to more than one note. This is indicated with an @emph{extender
line}. It is entered as two underscores, i.e.,
+
@example
\lyrics @{ I want to break free __ @}
@end example
+
@lilypond[quote,raggedright]
\score {
<<
Similarly, hyphens between words can be entered as two dashes,
resulting in a centered hyphen between two syllables
+
@example
Twin -- kle twin -- kle
@end example
+
@lilypond[quote,raggedright]
\score {
<<
@cindex chord names
In popular music, it is common to denote accompaniment as chord-names.
-Such chords can be entered like notes,
+Such chords can be entered like notes,
@example
c2 f4. g8
Other chords can be created by adding modifiers after a colon. The
following example shows a few common modifiers
-@c
+
@lilypond[quote,verbatim]
\chords { c2 f4:m g4:maj7 gis1:dim7 }
@end lilypond
@cindex lead sheet
@separate
-When put together, chord names, lyrics and a melody form
+When put together, chord names, lyrics and a melody form
a lead sheet, for example,
@example
>>
@}
@end example
+
@lilypond[quote,raggedright]
\score {
<<
connecting and controlling digital instruments. A MIDI file is like a
tape recording of a MIDI instrument.
-To create a MIDI from a music piece of music, add a
+To create a MIDI from a music piece of music, add a
@code{\midi} block causes LilyPond to create a MIDI file, so you
can listen to the music you entered. It is great for checking the
music: octaves that are off or accidentals that were mistyped stand
out very much when listening to the musical transcription.
The @code{\midi} block is added to @code{\score}, for example,
+
@example
\score @{
@var{..music..}
- \midi @{ \tempo 4=72 @}
+ \midi @{ \tempo 4=72 @}
@}
@end example
@example
\score @{
@var{..music..}
- \midi @{ \tempo 4=72 @}
+ \midi @{ \tempo 4=72 @}
\paper @{ @}
@}
@end example
@code{\header} block. The name of the piece, its composer, etc., are
entered as an assignment, within @code{\header @{ @dots{} @}}. For
example,
+
@example
\header @{
title = "Eight miniatures"
@lilypond[quote,verbatim,relative=3]
<< { a4 g2 f4~ f4 } \\
- { r4 g4 f2 f4 } >>
+ { r4 g4 f2 f4 } >>
@end lilypond
For polyphonic music typesetting, spacer rests can also be convenient: these
are rests that do not print. It is useful for filling up voices that
temporarily do not play. Here is the same example with a spacer rest
instead of a normal rest
+
@lilypond[quote,relative=3]
<< { a4 g2 f4~ f4 } \\
- { s4 g4 f2 f4 } >>
+ { s4 g4 f2 f4 } >>
@end lilypond
Again, these expressions can be nested arbitrarily
<<
\new Staff <<
{ a4 g2 f4~ f4 } \\
- { s4 g4 f2 f4 }
+ { s4 g4 f2 f4 }
>>
\new Staff <<
\clef bass
{ <c, g>1 ~ <c g>4 } \\
- { f4 d e2 ~ e4}
+ { f4 d e2 ~ e4}
>>
>>
@end lilypond
@cindex @code{\context}
Piano music is typeset in two staves connected by a brace. Printing
-such a staff is similar to the polyphonic example in @ref{More staves}
+such a staff is similar to the polyphonic example in @ref{More staves},
+
@example
<< \new Staff @{ @dots{} @}
\new Staff @{ @dots{} @} >>
@end example
+
+@noindent
but now this entire expression must be interpreted as a
@code{PianoStaff}
+
@example
\new PianoStaff << \new Staff @dots{} >>
@end example
@lilypond[quote,relative=1,fragment]
\new PianoStaff <<
- \new Staff { \time 2/4 c4 c g' g }
+ \new Staff { \time 2/4 c4 c g' g }
\new Staff { \clef bass c,, c' e c }
>>
@end lilypond
By using variables, also known as identifiers, it is possible to break
up complex music expressions. An identifier is assigned as follows
-@c
+
@example
namedMusic = \notes @{ @dots{}
@end example
It is possible to use variables for many other types of objects in the
input. For example,
+
@example
width = 4.5\cm
name = "Wendy"
aFivePaper = \paper @{ paperheight = 21.0 \cm @}
@end example
+
Depending on its contents, the identifier can be used in different
places. The following example uses the above variables
+
@example
\score @{
\notes @{ c4^\name @}
a variable. The contents of that variable is then used to generate
both the part and the score.
-It is convenient to define the notes in a special file, for example,
+It is convenient to define the notes in a special file, for example,
suppose that the @file{horn-music.ly} contains the following part of a
horn/bassoon duo,
+
@example
hornNotes = \notes \relative c @{
\time 2/4
for a whole note, 2 for a half note, etc.). By multiplying the
duration, longer rests can be constructed. For example, this rest
takes 3 measures in 2/4 time
+
@example
R2*3
@end example
When printing the part, multi-rests
must be condensed. This is done by setting a run-time variable
+
@example
\set Score.skipBars = ##t
@end example
@}
@end example
+@noindent
leading to
@lilypond[quote,raggedright]
}
\new Staff {
\clef bass
- r4 d,8 f | gis4 c | b bes |
- a8 e f4 | g d | gis f
+ r4 d,8 f | gis4 c | b bes |
+ a8 e f4 | g d | gis f
}
}
}
treatises, songbooks or manuals like this. Such texts can be made by
hand, simply by importing a PostScript figure into the word processor.
However, there is an automated procedure to reduce the amount of work
-involved HTML, La@TeX{}, and Texinfo documents.
+involved HTML, La@TeX{}, and Texinfo documents.
A script called @code{lilypond-book} will extract the music fragments,
run format them, and put back the resulting notation. This program is
@end example
Under Unix, you can view the results as follows
+
@example
$ cd input/tutorial
$ mkdir -p out/
To convert the file into a nice PDF document, run the following
commands
+
@example
$ dvips -Ppdf -u +lilypond lilybook
$ ps2pdf lilybook.ps