}
@end lilypond
+This example uses @code{\with}, which will be explained more
+fully later. It is a means of modifying the default behaviour
+of a Staff. Here it says that the new staff should be placed
+above the staff called @qq{main} instead of the default position
+which is below.
+
Ossia are often written without clef and without
time signature and are usually in a smaller font.
-These require commands which
+These require further commands which
have not yet been introduced. See ...
TODO Add ref to tweaks section where this example should
be placed and explained.
@end lilypond
+You have already met a number of different types of bracket in
+writing the input file to LilyPond. These obey different rules
+which can be confusing at first. Before we explain the rules
+let's first review the different types of bracket.
+
+@multitable @columnfractions .3 .7
+@headitem Bracket Type
+ @tab Function
+@item @code{@{ .. @}}
+ @tab Encloses a sequential segment of music
+@item @code{< .. >}
+ @tab Encloses the notes of a chord
+@item @code{<< .. >>}
+ @tab Encloses concurrent or simultaneous sections
+@item @code{( .. )}
+ @tab Marks the start and end of a slur
+@item @code{\( .. \)}
+ @tab Marks the start and end of a phrase mark
+@item @code{[ .. ]}
+ @tab Marks the start and end of a manual beam
+@end multitable
+
+To these we should add other constructs which generate lines
+between or across notes: ties (marked by a tilde, @code{~}),
+tuplets written as @code{\times x/y @{ .. @}}, and grace notes
+written as @code{\grace@{ .. @}}.
+
+Outside LilyPond, the conventional use of brackets requires
+the different types to be properly nested, like this,
+@code{<< @{ ( .. ) @} >>}, with the closing brackets being
+encountered in exactly the opposite order to the opening
+brackets. This @strong{is} a requirement for the three types of
+bracket described by the word @q{Encloses} in the table above -
+they must nest properly.
+However, the remaining brackets, described with the word
+@q{Marks} in the table above together with ties and tuplets,
+do @strong{not} have to nest
+properly with any of the brackets. In fact, these are not
+brackets in the sense that
+they enclose something - they are simply markers to indicate
+where something starts and ends.
+
+So, for example, a phrasing slur can start before a manually
+inserted beam and end before the end of the beam - not very
+musical, perhaps, but possible:
+
+@lilypond[quote,verbatim,fragment,ragged-right,relative=2]
+ { g8\( a b[ c b\) a] }
+@end lilypond
+
+In general, different kinds of brackets, and those implied by
+tuplets, ties and grace notes, may be mixed freely.
+This example shows a beam extending into a tuplet (line 1),
+a slur extending into a tuplet (line 2),
+a beam and a slur extending into a tuplet, a tie crossing
+two tuplets, and a phrasing slur extending out of a tuplet
+(lines 3 and 4).
+
+@lilypond[quote,verbatim,fragment,ragged-right]
+{
+ r16[ g16 \times 2/3 {r16 e'8] }
+ g16( a \times 2/3 {b d) e' }
+ g8[( a \times 2/3 {b d') e'~]}
+ \times 4/5 {e'32\( a b d' e'} a'4.\)
+}
+@end lilypond
@node Voices contain music
@cindex Voice context
The lowest, most fundamental or innermost layers in a LilyPond
-score are called Voices. Voices are sometimes
-called @q{layers} in other notation packages. In LilyPond they
-are called @q{Voice contexts}.
+score are called @q{Voice contexts} or just @q{Voices} for short.
+Voices are sometimes called @q{layers} in other notation
+packages.
In fact, a Voice layer or context is the only one which can
contain music. If a Voice context is not explicitly declared
one is created automatically. Some instruments such as an
-Oboe can play only one note at a time and music written for
+Oboe can play only one note at a time. Music written for
such instruments is monophonic and requires just a single
voice. Instruments which can play more than one note at a
time like the piano will often require multiple voices to
-encode the different concurent notes and rhythms they are
+encode the different concurrent notes and rhythms they are
capable of playing.
A single voice can contain many notes in a chord, of course,
as sequential notes, as they must start at the same time.
This section of the bar requires three voices, and the
normal practice would be to write the whole bar as three
-voices, as shown here, where we have used different notehead
+voices, as shown here, where we have used different noteheads
and colors for the three voices.
@c The following should appear as music without code
@end lilypond
These voices are all separate from the main voice that contains
-the notes just outside the @code{<< \\ >>} construct. Let's call
+the notes just outside the @code{<< .. >>} construct. Let's call
this the @emph{simultaneous construct}. Slurs and ties may only
connect notes within the same voice, so slurs and ties cannot go
into or out of a simultaneous construct. Conversely,
parallel voices from separate simultaneous constructs on the same
-staff are the same voice. Other voice- related properties also
+staff are the same voice. Other voice-related properties also
carry across simultaneous constructs. Here is the same example,
with different colors and noteheads for each voice. Note that
changes in one Voice do not affect other voices, but they do
@cindex stem down
@cindex stem up
-@funindex \stemDown
-@funindex \stemUp
+@funindex \voiceOne
+@funindex \voiceTwo
+@funindex \voiceThree
+@funindex \voiceFour
The stem directions are automatically assigned with the
odd-numbered voices taking upward stems and the even-numbered
by telling LilyPond that this third voice is really a fourth
voice, with stems going down, using the @code{\voiceFour}
command. There are also corresponding @code{\voiceOne},
-@code{\voiceTwo} and @code{voiceThree} commands.
-This result in the following:
+@code{\voiceTwo}, @code{voiceThree} and @code{voiceFour}
+commands. This results in the following:
@lilypond[quote,verbatim,fragment,ragged-right]
\new Staff \relative c'' {
FIXME: Move the following words and example into Tweaks or
somewhere more suitable, leaving just a ref here. -td
-Ways or correcting horizontal placings are described fully
+Ways of correcting horizontal placings are described fully
in the Notation Reference.
We introduce just one here, the @code{force-hshift} property of
@code{NoteColumn}. The lower two notes of the first chord (i.e,
<<
{ c2 aes4. bes8 } \\
{ aes2 f4 fes } \\
- { \stemDown
+ { \voiceFour
\once \override NoteColumn #'force-hshift = #0 <ees c>2
\once \override NoteColumn #'force-hshift = #0.5 des2
}
Voice contexts can also be created manually
inside a @code{<< >>} block to create polyphonic music, using
-@code{\voiceOne}, up to @code{\voiceFour} to automatically assign
-the directions of stems, slurs, etc.
+@code{\voiceOne} ... @code{\voiceFour} to indicate the required
+directions of stems, slurs, etc.
-Specifically, the construct @code{<< \\ >>} which we used in
+Specifically, the construct @code{<< \\ >>} which we used in
the previous section:
@example
to avoid clashes of note heads. The command @code{\oneVoice}
reverts the settings back to the normal values for a single voice.
+Let us see in a simple example exactly what effect
+@code{\oneVoice}, @code{\voiceOne} and @code{voiceTwo} have on
+markup, ties, slurs, and dynamics:
+
+@lilypond[quote,ragged-right,verbatim]
+\relative c'{
+c-"default" d8 ~ d e4 ( f g a ) b-> c \break
+\voiceOne
+c,-"\\voiceOne" d8 ~ d e4 ( f g a ) b-> c \break
+\oneVoice
+c,-"\\oneVoice" d8 ~ d e4 ( f g a ) b-> c \break
+\voiceTwo
+c,-"\\voiceTwo" d8 ~ d e4 ( f g a ) b-> c \break
+}
+@end lilypond
+
An expression that appears directly inside a @code{<< >>} belongs
to the main voice. This is useful when extra voices appear while
the main voice is playing. Here is a more correct rendition of
@end lilypond
-
@node Voices and vocals
@subsection Voices and vocals
>>
@end lilypond
+The automatic beaming which LilyPond uses by default works well
+for instrumental music, but not so well for music with lyrics,
+where beaming is either not required at all or is used to indicate
+melismata in the lyrics. In the example above we use the command
+@code{\autoBeamOff} to turn off the automatic beaming.
+
Let us reuse the earlier example from Judas Maccabæus to
illustrate this more flexible technique. We first recast
it to use variables so the music and lyrics can be separated
@node Contexts explained
@subsection Contexts explained
-When music is printed, a lot of notational elements must be added to the
-output. For example, compare the input and output of the following example:
+When music is printed, many notational elements which do not
+appear explicitly in the input file must be added to the
+output. For example, compare the input and output of the
+following example:
@lilypond[quote,verbatim,relative=2,fragment]
cis4 cis2. g4
@end lilypond
-The input is rather sparse, but in the output, bar lines, accidentals,
-clef, and time signature are added. LilyPond @emph{interprets} the
-input. During this step, the musical information is inspected in time
-order, similar to reading a score from left to right. While reading
-the input, the program remembers where measure boundaries are, and which
-pitches require explicit accidentals. This information must be held on
-several levels. For example, the effect of an accidental is limited
-to a single staff, while a bar line must be synchronized across the
-entire score.
-
-Within LilyPond, these rules and bits of information are grouped in
-@emph{Contexts}. Some examples of contexts are @context{Voice},
-@context{Staff}, and @context{Score}. They are hierarchical to
-reflect the heirarchical nature of a musical score. For
-example: a @context{Staff} can contain many @context{Voice}s, and a
-@context{Score} can contain many @context{Staff} contexts.
+The input is rather sparse, but in the output, bar lines,
+accidentals, clef, and time signature have been added. When
+LilyPond @emph{interprets} the input the musical information
+is inspected in time order, similar to reading a score from left
+to right. While reading the input, the program remembers where
+measure boundaries are, and which pitches require explicit
+accidentals. This information must be held on several levels.
+For example, the effect of an accidental is limited
+to a single staff, while a bar line must be synchronized across
+the entire score.
+
+Within LilyPond, these rules and bits of information are grouped
+in @emph{Contexts}. We have already met the @context{Voice}
+context.
+Others are the @context{Staff} and @context{Score} contexts.
+Contexts are hierarchical to reflect the heirarchical nature of
+a musical score.
+For example: a @context{Staff} context can contain many
+@context{Voice} contexts, and a @context{Score} context can
+contain many @context{Staff} contexts.
@quotation
@image{context-example,5cm,,}
creating some notation objects and maintaining the associated
properties. For example, the @context{Voice} context may introduce an
accidental and then the @context{Staff} context maintains the rule to
-show or suppress the accidental for the remainder of the measure. The
-synchronization of bar lines is handled in the @context{Score} context.
+show or suppress the accidental for the remainder of the measure.
+As another example, the synchronization of bar lines is by default
+handled in the @context{Score} context.
However, in some music we may not want the bar lines to be
-synchronized -- consider a polymetric score in 4/4 and 3/4 time. In
-such cases, we must modify the default settings of the @context{Score}
-and @context{Staff} contexts.
+synchronized -- consider a polymetric score in 4/4 and 3/4 time.
+In such cases, we must modify the default settings of the
+@context{Score} and @context{Staff} contexts.
For very simple scores, contexts are created implicitly, and you need
not be aware of them. For larger pieces, such as anything with more
than one staff, they must be
created explicitly to make sure that you get as many staves as you
need, and that they are in the correct order. For typesetting pieces
-with specialized notation, it can be useful to modify existing or
-to define new contexts.
+with specialized notation, it is usual to modify existing or
+even to define totally new contexts.
-In addition to the @context{Score}, @context{Staff} and
+In addition to the @context{Score,} @context{Staff} and
@context{Voice} contexts there are contexts which fit between
the score and staff levels to control staff groups, such as the
@context{PianoStaff} and @context{ChoirStaff} contexts. There
@node Creating contexts
@subsection Creating contexts
-The top level context, @context{Score}, is created with the
-@code{\score} command, or automatically in simple scores.
+There can be only one top level context, the @context{Score}
+context. This is created with the @code{\score} command,
+or, in simple scores, it is created automatically.
-For scores with only one voice and one staff, the @context{Voice}
-and @context{Staff} contexts may be left to be created
-automatically, but for more complex scores it is necessary to
-create @context{Staff} and @context{Voice} contexts by hand.
+For scores with only one voice and one staff, the
+@context{Voice} and @context{Staff} contexts may be left to be
+created automatically, but for more complex scores it is
+necessary to create them by hand.
The simplest command that does this is @code{\new}.
It is prepended to a music expression, for example
@noindent
where @var{type} is a context name (like @code{Staff} or
@code{Voice}). This command creates a new context, and starts
-interpreting the @var{music expression} with that.
+interpreting the @var{music expression} within that context.
Note that there is no @code{\new Score % Invalid!} command;
-a @context{Score} context is introduced with @code{\score}.
-This is because there can be only one @context{Score}
-context, whereas there may be multiple @context{Staff}
-and @context{Voice} contexts - each created by an @code{\new}.
+the single top-level @context{Score} context is introduced
+with @code{\score}. This is because there can be only one
+@context{Score} context, whereas there may be multiple
+@context{Staff} and @context{Voice} contexts - each created
+by @code{\new}.
So a practical application of @code{\new} is a score with many
-staves. Each part that should be on its own staff, is preceded
+staves. Each part that should be on its own staff is preceded
with @code{\new Staff}.
@lilypond[quote,verbatim,relative=2,ragged-right,fragment]
is produced by an @code{Engraver}. Thus there is an engraver
to print staves, one to print noteheads, one for stems, one for
beams, etc, etc. In total there are over 120 such engravers!
-Fortunately, for most scores it is not necessary to know more than
-a few, and for simple scores you do not need to know about any.
+Fortunately, for most scores it is not necessary to know about
+more than a few, and for simple scores you do not need to know
+about any.
A musical score can be viewed heirarchically. At the top level
is the whole score. This consists of one or more staves.
Engravers such as the @code{Metronome_mark_engraver}, whose
action and output applies to the score as a whole, live in
-the highest level Context - the @context{Score} context. There
-can be only one of these engravers as there is only one tempo
+the highest level context - the @context{Score} context. There
+can be only one of these engravers as there can be only one tempo
at any particular point in the score.
The @code{Clef_engraver} and @code{Key_engraver} are to be
different clefs and keys.
The @code{Note_heads_engraver} and @code{Stem_engraver} live
-in a context at the Voice level, the lowest level of all.
+in a @context{Voice} context, the lowest level context of all.
Each engraver processes the particular objects associated
-with its function, and contain the properties that relate
+with its function, and contains the properties that relate
to that function. These properties, like the properties
associated with contexts, may be modified to change the
operation of the engraver or the appearance of those elements
more than one thing (in this case, @code{Staff}) happening at once. The
@code{\score} looks like this now
+@c Indentation in this example is deliberately poor
@example
\score @{
<<
- <<
- \new Voice = "one" @{
- \autoBeamOff
- \sopranoMusic
- @}
- \new Lyrics \lyricsto "one" \sopranoLyrics
- >>
- \new Staff \celloMusic
+ <<
+ \new Voice = "one" @{
+ \autoBeamOff
+ \sopranoMusic
+ @}
+ \new Lyrics \lyricsto "one" \sopranoLyrics
+ >>
+ \new Staff \celloMusic
>>
\layout @{ @}
\midi @{ @}
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
-orchestral accompaniment underneath. Here's an example:
+orchestral accompaniment underneath. Here's an example
+from Handel's Messiah:
@c The following should appear as music without code
@lilypond[quote,ragged-right]
the default, so the @code{\voiceXXX} commands can be removed.
We also need to specify the tenor clef for the tenors.
The way in which lyrics are specified has also been simplified
-as we have not yet encountered the method in the template so
-far. We've also added the names of each staff.
+as we have not yet encountered the method used in the template.
+We've also added the names of each staff.
Doing this gives for our ChoirStaff:
stacked one above the other:
@example
-<< % combine ChoirStaff and PianoStaff in parallel
+<< % combine ChoirStaff and PianoStaff one above the other
\new ChoirStaff <<
\new Staff = "sopranos" <<
\new Voice = "sopranos" @{ \global \sopMusic @}
instead of the real music. We'll add that later.
Next let's see what should go in the score block.
-This just mirrors the staff structure we want.
+We simply mirror the staff structure we want.
Organ music is usually written on three staves,
one for each manual and one for the pedals. The
manual staves should be bracketed together so we
-need to use a PianoStaff for them.
+need to use a PianoStaff for them. The first
+manual part needs two voices and the second manual
+part just one.
@example
\new PianoStaff <<
Next we need to add a staff for the pedal organ.
This goes underneath the PianoStaff, but it must
be simultaneous with it, so we need angle brackets
-round the two.
+round the two. Missing these out would generate
+an error in the log file. It's a common mistake
+which you'll make sooner or later! Try copying
+the final example at the end of this section,
+remove these angle brackets, and compile it to
+see what errors it generates.
@example
<< % PianoStaff and Pedal Staff must be simultaneous
indenting. We also add the appropriate clefs, ensure the
second voice stems point down with @code{\voiceTwo} and
enter the time signature and key to each staff using our
-predefined variable, \TimeKey.
+predefined variable, @code{\TimeKey}.
@example
\score @{
TODO: this is really old stuff from the really old tutorial.
Rewrite, fix, etc. Or maybe delete entirely. -gp
Include section on tags -td
+and then move to section 5. Working ... -td
In orchestral music, all notes are printed twice. Once in a part for
the musicians, and once in a full score for the conductor. Variables can