A basic example of a lilypond input file is
@example
-\version "2.11.23"
+\version "2.11.38"
\score @{
@var{...compound music expression...} % all the music goes here!
\header @{ @}
There are many variations of this basic pattern, but this
example serves as a useful starting place.
-Up to this point none of the examples you have seen have used a
+Up to this point none of the examples you have seen has used a
@code{\score@{@}} command. This is because LilyPond automatically
adds the extra commands which are needed when you give it simple
input. LilyPond treats input like this:
A @code{\score} block must always contain just one music
expression, and
-this must appear first within the @code{\score @{..@}} block.
+this must appear immediately after the @code{\score} command.
Remember that a music expression could be anything from a single
note to a huge compound expression like
Since everything is inside @code{@{ ... @}}, it counts
as one music expression.
-As we saw previously, the @code{\score} can contain other things,
-such as
+As we saw previously, the @code{\score} block can contain other
+things, such as
@example
\score @{
@noindent
Some people put some of those commands outside the @code{\score}
block -- for example, @code{\header} is often placed above the
-@code{\score}. That's just another shorthand that LilyPond
+@code{\score} command. That's just another shorthand that LilyPond
accepts.
Two more commands you have not previously seen are
Notation Reference -- @ruser{Score layout} and
@ruser{Creating MIDI files}.
-The @code{\book} command allows
-several @code{\score} blocks to be combined into one output.
-If there are several @code{\book} blocks each one produces a
+You may code multiple @code{\score} blocks. Each will be
+treated as a separate score, but they will be all combined into
+a single output file. A @code{\book} command is not necessary
+-- one will be implicitly created. However, if you would like
+separate output files from one @code{.ly} file then the
+@code{\book} command should be used to separate the different
+sections: each @code{\book} block will produce a
separate output file. For details see @ruser{Multiple scores
in a book}.
there @emph{is} no mystery. This line explains it all:
@quotation
-@emph{A @code{\score} must begin with a compound music expression.}
+@emph{A @code{\score} block must begin with a compound music expression.}
@end quotation
@noindent
@}
@end example
-Remember that we use @code{<<} and @code{>>} to show simultaneous
+Remember that we use @code{<< ... >>} instead of
+@code{@{ ... @}} to show simultaneous
music. And we definitely want to show the vocal part and piano
part at the same time, not one after the other! However, the
-@code{<< .. >>} construct is not really necessary for the Singer
+@code{<< ... >>} construct is not really necessary for the Singer
staff, as it contains only one music expression, but Staves often
-do require simultaneous Voices within them, so using @code{<< .. >>}
+do require simultaneous Voices within them, so using
+@code{<< ... >>}
rather than braces is a good habit to adopt. We'll add some real
music later; for now let's just put in some dummy notes and lyrics.
<<
\new Staff = "singer" <<
\new Voice = "vocal" { c'1 }
- \addlyrics { One }
+ \addlyrics { And }
>>
\new PianoStaff = "piano" <<
\new Staff = "upper" { c'1 }
@example
\relative c'' @{
- a4 b c d
+ r4 d8\noBeam g, c4 r
@}
@end example
now have a piece of real music:
@lilypond[verbatim,quote,ragged-right]
-melody = \relative c'' { r4 d8\noBeam g, c r4 }
+melody = \relative c'' { r4 d8\noBeam g, c4 r }
text = \lyricmode { And God said, }
upper = \relative c'' { <g d g,>2~ <g d g,> }
lower = \relative c { b2 e2 }
@end lilypond
@noindent
-and exposes a problem commonly encountered with multiple
-voices: the stems of notes can collide with note heads
+We see that this fixes the stem direction, but exposes a
+problem sometimes encountered with multiple voices -- the
+stems of the notes in one voice can collide with the note heads
in other voices. In laying out the notes, LilyPond allows the
notes or chords from two voices to occupy the same vertical
note column provided the stems are in opposite directions, but
-the notes from a third voice are displaced to avoid the stems
-colliding. This often works well, but in this example the
+the notes from the third and fourth voices are displaced to if
+necessary to avoid the note heads
+colliding. This usually works well, but in this example the
notes of the lowest voice are clearly not well placed by default.
LilyPond provides several ways to adjust the horizontal placing
of notes. We are not quite ready yet to see how to correct this,
-so we shall leave this problem until a later section
-(see @ref{Fixing overlapping notation} )
+so we shall leave this problem until a later section
+(see the force-hshift property in @ref{Fixing overlapping
+notation} )
@node Explicitly instantiating voices
@subsection Explicitly instantiating voices
>>
\new Staff <<
\new Voice = "SopTwo" {
+ \global
\SopTwoMusic
}
\new Lyrics \lyricsto "SopTwo" {
>>
\new Staff <<
\clef "bass"
- \new Voice = "Tenor" { \voiceOne \TenorMusic }
+ \new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic }
\new Voice = "Bass" { \voiceTwo \BassMusic }
>>
>>
contain many @code{Staff} contexts.
@quotation
-@image{context-example,5cm,,}
+@sourceimage{context-example,5cm,,}
@end quotation
Each context has the responsibility for enforcing some notation rules,
the score and staff levels to control staff groups, such as the
@code{PianoStaff} and @code{ChoirStaff} contexts. There
are also alternative staff and voice contexts, and contexts for
-lyrics, percussion, fret boards, figured bass, etc. A complete
-list is shown in the Notation Reference.
-TODO: Add link
+lyrics, percussion, fret boards, figured bass, etc.
-The names of all context types are formed from one or more
+The names of all context types are formed from one or more
words, each word being capitalised and joined immediately to the
preceding word with no hyphen or underscore, e.g.,
@code{GregorianTranscriptionStaff}.
@lilypond[quote,verbatim,ragged-right]
<<
\new Staff \relative c'' {
- \set Staff.instrumentName = "Soprano"
+ \set Staff.instrumentName = #"Soprano"
c4 c
}
\new Staff \relative c' {
- \set instrumentName = "Alto" % Wrong!
+ \set instrumentName = #"Alto" % Wrong!
d4 d
}
>>
some properties can be set in more than one context.
For example, the property @code{extraNatural} is by
default set to ##t (true) for all staves.
-If it is set to ##f (false) in the @code{Staff} context
-it applies just to the accidentals on that staff.
+If it is set to ##f (false) in one particular @code{Staff}
+context it applies just to the accidentals on that staff.
If it is set to false in the @code{Score} context
it applies to all staves.
encountered until the end of the score or until the property is
@code{\set} or @code{\unset} again. Let's try changing the
font size, which affects the size of the note heads (among
-other things) several times.
+other things) several times. The change is from the default
+value, not the current value.
@lilypond[quote,verbatim,ragged-right,relative=1,fragment]
c4
output. This is a crude way of modifying the output, but it
can sometimes be useful.
-@unnumberedsubsubsec Changing a single context
+@subsubsection Changing a single context
To remove an engraver from a single context we use the
@code{\with} command placed immediately after the context creation
command, as in the previous section.
-As an
-illustration let's repeat an example from the previous
-section with the staff lines removed. Remember that the
+As an
+illustration let's repeat an example from the previous
+section with the staff lines removed. Remember that the
staff lines are produced by the Staff_symbol_engraver.
@lilypond[quote,verbatim,ragged-right]
>>
@end lilypond
-@unnumberedsubsubsec Changing all contexts of the same type
+@subsubsection Changing all contexts of the same type
The examples above show how to remove or add engravers to
individual contexts. It is also possible to remove or add
soprano part).
@example
-\version "2.11.23"
+\version "2.11.38"
melody = \relative c' @{
\clef treble
\key c \major
\time 4/4
-
a4 b c d
@}
Now we want to add a cello part. Let's look at the @q{Notes only} example:
@example
-\version "2.11.23"
+\version "2.11.38"
melody = \relative c' @{
\clef treble
\key c \major
\time 4/4
-
a4 b c d
@}
@}
@end example
-We don't need two @code{\version} commands. We'll need the @code{melody}
-section. We don't want two @code{\score} sections -- if we had two
-@code{\score}s, we'd get the two parts separately. We want them together,
-as a duet. Within the @code{\score} section, we don't need two
-@code{\layout} or @code{\midi}.
-
-If we simply cut and paste the @code{melody} section, we would end up with
-two @code{melody} sections. So let's rename them. We'll call the section
-for the soprano @code{sopranoMusic} and the section for the cello
-@code{celloMusic}. While we're doing this, let's rename @code{text}
-to be @code{sopranoLyrics}. Remember to rename both instances of all
-these names -- both the initial definition (the
-@code{melody = relative c' @{ } part) and the name's use (in the
+We don't need two @code{\version} commands. We'll need the
+@code{melody} section. We don't want two @code{\score} sections
+-- if we had two @code{\score}s, we'd get the two parts separately.
+We want them together, as a duet. Within the @code{\score}
+section, we don't need two @code{\layout} or @code{\midi}.
+
+If we simply cut and paste the @code{melody} section, we would
+end up with two @code{melody} definitions. This would not generate
+an error, but the second one would be used for both melodies.
+So let's rename them to make them distinct. We'll call the
+section for the soprano @code{sopranoMusic} and the section for
+the cello @code{celloMusic}. While we're doing this, let's rename
+@code{text} to be @code{sopranoLyrics}. Remember to rename both
+instances of all these names -- both the initial definition (the
+@code{melody = \relative c' @{ } part) and the name's use (in the
@code{\score} section).
-While we're doing this, let's change the cello part's staff -- celli
-normally use bass clef. We'll also give the cello some different
-notes.
+While we're doing this, let's change the cello part's staff --
+celli normally use bass clef. We'll also give the cello some
+different notes.
@example
-\version "2.11.23"
+\version "2.11.38"
sopranoMusic = \relative c' @{
\clef treble
\key c \major
\time 4/4
-
a4 b c d
@}
\clef bass
\key c \major
\time 4/4
-
d4 g fis8 e d4
@}
easily fixed. Here's the complete soprano and cello template.
@lilypond[quote,verbatim,ragged-right]
-\version "2.11.23"
+\version "2.11.37"
sopranoMusic = \relative c' {
\clef treble
\key c \major
\time 4/4
-
a4 b c d
}
\clef bass
\key c \major
\time 4/4
-
d4 g fis8 e d4
}
@node Four-part SATB vocal score
@subsection Four-part SATB vocal score
-Most vocal scores of music written for four-part mixed choir
+Most vocal scores of music written for four-part mixed choir
with orchestral accompaniment such as Mendelssohn's Elijah or
Handel's Messiah have the choral music and words on four
staves, one for each of SATB, with a piano reduction of the
@c The following should appear as music without code
@lilypond[quote,ragged-right]
-\version "2.11.23"
+\version "2.11.38"
global = { \key d \major \time 4/4 }
sopMusic = \relative c'' {
\clef "treble"
}
altoMusic = \relative a' {
\clef "treble"
- r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
+ r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
}
altoWords = \sopWords
tenorMusic = \relative c' {
for the three bars of the example above gives:
@lilypond[quote,verbatim,ragged-right]
-\version "2.11.23"
+\version "2.11.38"
global = { \key d \major \time 4/4 }
sopMusic = \relative c'' {
\clef "treble"
and key:
@example
-\version "2.11.23"
+\version "2.11.38"
\header @{
title = "Jesu, meine Freude"
composer = "J S Bach"
is to add the music, and combine all the parts together.
@lilypond[quote,verbatim,ragged-right]
-\version "2.11.23"
+\version "2.11.38"
\header {
title = "Jesu, meine Freude"
composer = "J S Bach"
+
+
+