Guide, node Updating translation committishes..
@end ignore
-@c \version "2.17.11"
+@c \version "2.19.22"
@node Fundamental concepts
@chapter Fundamental concepts
\header @{ @}
\score @{
- @var{...compound music expression...} % all the music goes here!
+ @var{ @dots{} compound music expression @dots{} } % all the music goes here!
\layout @{ @}
\midi @{ @}
@}
example serves as a useful starting place.
@funindex \book
-@funindex book
@funindex \score
-@funindex score
@cindex book
@cindex score
input. LilyPond treats input like this:
@example
-\relative c'' @{
- c4 a d c
+\relative @{
+ c''4 a d c
@}
@end example
\score @{
\new Staff @{
\new Voice @{
- \relative c'' @{
- c4 a b c
+ \relative @{
+ c''4 a b c
@}
@}
@}
For now, though, let us return to the first example and examine the
@code{\score} command, leaving the others to default.
-A @code{\score} block must always contain just one music expression,
-and 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
+A @code{\score} block must always contain exactly one music
+expression. Remember that a music expression could be anything
+from a single note to a huge compound expression like
@example
@{
\new StaffGroup <<
- @var{...insert the whole score of a Wagner opera in here...}
+ @var{ @dots{} insert the whole score of a Wagner opera in here @dots{} }
>>
@}
@end example
@noindent
-Since everything is inside @code{@{ ... @}}, it counts
+Since everything is inside @code{@{ @dots{} @}}, it counts
as one music expression.
As we saw previously, the @code{\score} block can contain other
@end example
@funindex \header
-@funindex header
@funindex \layout
-@funindex layout
@funindex \midi
-@funindex midi
@cindex header
@cindex layout
@cindex midi
shown they will cause LilyPond to produce a printed output and a
MIDI output respectively. They are described fully in the
Notation Reference -- @ruser{Score layout}, and
-@ruser{Creating MIDI files}.
+@ruser{Creating MIDI output}.
@cindex scores, multiple
@cindex book block, implicit
@cindex implicit book block
@funindex \book
-@funindex book
You may code multiple @code{\score} blocks. Each will be
treated as a separate score, but they will be all combined into
templates use this:
@example
-melody = \relative c' @{
- c4 a b c
+melody = \relative @{
+ c'4 a b c
@}
\score @{
@subsection Score is a (single) compound musical expression
@funindex \score
-@funindex score
@cindex score
@cindex contents of a score block
@cindex score block, contents of
there @emph{is} no mystery. This line explains it all:
@quotation
-@emph{A @code{\score} block must begin with a compound music expression.}
+@emph{A @code{\score} block must contain exactly one music expression.}
@end quotation
@noindent
-To understand what is meant by a music expression and a compound
+To understand what is meant by a
music expression, you may find it useful to review the tutorial,
@ref{Music expressions explained}. In that section, we saw how to
build big music expressions from small pieces -- we started from
to cultivate so that you can see at a glance what each stave is
for.
-Remember that we use @code{<< ... >>} instead of @code{@{ ... @}} to
+Remember that we use @code{<< @dots{} >>} instead of @code{@{ @dots{} @}} to
show simultaneous music. This causes the vocal part and piano part
-to appear one above the other in the score. The @code{<< ... >>}
+to appear one above the other in the score. The @code{<< @dots{} >>}
construct would not be necessary for the Singer staff in the example
above if it were going to contain only one sequential music
-expression, but @code{<< ... >>} rather than braces is necessary if
+expression, but @code{<< @dots{} >>} rather than braces is necessary if
the music in the Staff is to contain two or more simultaneous
expressions, e.g. two simultaneous Voices, or a Voice with lyrics.
We're going to have a voice with lyrics, so angle brackets are
braces next to @code{\new Voice = "vocal"}, we could start writing
@example
-\relative c'' @{
- r4 d8\noBeam g, c4 r
+\relative @{
+ r4 d''8\noBeam g, c4 r
@}
@end example
have a piece of real music:
@lilypond[verbatim,quote,ragged-right]
-melody = \relative c'' { r4 d8\noBeam g, c4 r }
+melody = \relative { r4 d''8\noBeam g, c4 r }
text = \lyricmode { And God said, }
-upper = \relative c'' { <g d g,>2~ <g d g,> }
-lower = \relative c { b2 e }
+upper = \relative { <g' d g,>2~ <g d g,> }
+lower = \relative { b,2 e }
\score {
<<
@lilypond[verbatim,quote,ragged-right]
\new Staff {
- \relative g' {
- r4 g8 g c4 c8 d |
+ \relative {
+ r4 g'8 g c4 c8 d |
e4 r8
<<
{ f8 c c }
@lilypond[verbatim,quote,ragged-right]
\new Staff = "main" {
- \relative g' {
- r4 g8 g c4 c8 d |
+ \relative {
+ r4 g'8 g c4 c8 d |
e4 r8
<<
{ f8 c c }
@multitable @columnfractions .3 .7
@headitem Bracket Type
@tab Function
-@item @code{@{ .. @}}
+@item @code{@{ @dots{} @}}
@tab Encloses a sequential segment of music
-@item @code{< .. >}
+@item @code{< @dots{} >}
@tab Encloses the notes of a chord
-@item @code{<< .. >>}
+@item @code{<< @dots{} >>}
@tab Encloses simultaneous music expressions
-@item @code{( .. )}
+@item @code{( @dots{} )}
@tab Marks the start and end of a slur
-@item @code{\( .. \)}
+@item @code{\( @dots{} \)}
@tab Marks the start and end of a phrasing slur
-@item @code{[ .. ]}
+@item @code{[ @dots{} ]}
@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@{..@}}.
+tuplets written as @code{\tuplet x/y @{ @dots{} @}}, and grace notes
+written as @code{\grace @{ @dots{} @}}.
Outside LilyPond, the conventional use of brackets requires the
-different types to be properly nested, like this, @code{<< [ @{ ( .. )
+different types to be properly nested, like this, @code{<< [ @{ ( @dots{} )
@} ] >>}, 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
inserted beam and end before the end of the beam -- not very
musical, perhaps, but possible:
-@lilypond[quote,verbatim,ragged-right,relative=2]
-g8\( a b[ c b\) a] g4
+@lilypond[quote,verbatim,ragged-right]
+\relative { g'8\( a b[ c b\) a] g4 }
@end lilypond
In general, different kinds of brackets, bracket-like constructs,
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,ragged-right,relative=1]
-r16[ g \tuplet 3/2 { r16 e'8] }
-g,16( a \tuplet 3/2 { b16 d) e }
-g,8[( a \tuplet 3/2 { b8 d) e~] } |
-\tuplet 5/4 { e32\( a, b d e } a4.\)
+@lilypond[quote,verbatim,ragged-right]
+\relative {
+ r16[ g' \tuplet 3/2 { r16 e'8] }
+ g,16( a \tuplet 3/2 { b16 d) e }
+ g,8[( a \tuplet 3/2 { b8 d) e~] } |
+ \tuplet 5/4 { e32\( a, b d e } a4.\)
+}
@end lilypond
so when exactly are multiple voices needed? Look first at
this example of four chords:
-@lilypond[quote,verbatim,ragged-right,relative=1]
-\key g \major
-<d g>4 <d fis> <d a'> <d g>
+@lilypond[quote,verbatim,ragged-right]
+\relative {
+ \key g \major
+ <d' g>4 <d fis> <d a'> <d g>
+}
@end lilypond
This can be expressed using just the single angle bracket chord
-symbols, @code{< ... >}, and for this just a single voice is
+symbols, @code{< @dots{} >}, and for this just a single voice is
needed. But suppose the F-sharp were actually an eighth-note
followed by an eighth-note G, a passing note on the way to the A?
Now we have two notes which start at the same time but have
@funindex \\
The easiest way to enter fragments with more than one voice on a
-staff is to enter each voice as a sequence (with @code{@{...@}}),
-and combine them simultaneously with angle brackets, @code{<<...>>}.
+staff is to enter each voice as a sequence (with @code{@{ @dots{} @}}),
+and combine them simultaneously with angle brackets, @code{<< @dots{} >>}.
The fragments must also be separated with double backward slashes,
@code{\\}, to place them in separate voices. Without these, the
notes would be entered into a single voice, which would usually
Here's how we split the chords above into two voices and add both
the passing note and a slur:
-@lilypond[quote,verbatim,ragged-right,relative=2]
-\key g \major
-% Voice "1" Voice "2"
-<< { g4 fis8( g) a4 g } \\ { d4 d d d } >>
+@lilypond[quote,verbatim,ragged-right]
+\relative {
+ \key g \major
+ % Voice = "1" Voice = "2"
+ << { g'4 fis8( g) a4 g } \\ { d4 d d d } >>
+}
@end lilypond
Notice how the stems of the second voice now point down.
Here's another simple example:
-@lilypond[quote,verbatim,ragged-right,relative=2]
-\key d \minor
-% Voice "1" Voice "2"
-<< { r4 g g4. a8 } \\ { d,2 d4 g } >> |
-<< { bes4 bes c bes } \\ { g4 g g8( a) g4 } >> |
-<< { a2. r4 } \\ { fis2. s4 } >> |
+@lilypond[quote,verbatim,ragged-right]
+\relative {
+ \key d \minor
+ % Voice = "1" Voice = "2"
+ << { r4 g' g4. a8 } \\ { d,2 d4 g } >> |
+ << { bes4 bes c bes } \\ { g4 g g8( a) g4 } >> |
+ << { a2. r4 } \\ { fis2. s4 } >> |
+}
@end lilypond
It is not necessary to use a separate @code{<< \\ >>} construct
notes in each bar it may be better to split out each voice
separately, like this:
-@lilypond[quote,verbatim,ragged-right,relative=2]
-\key d \minor
-<< {
- % Voice "1"
- r4 g g4. a8 |
- bes4 bes c bes |
- a2. r4 |
-} \\ {
- % Voice "2"
- d,2 d4 g |
- g4 g g8( a) g4 |
- fis2. s4 |
-} >>
+@lilypond[quote,verbatim,ragged-right]
+<<
+ \key d \minor
+ \relative { % Voice = "1"
+ r4 g' g4. a8 |
+ bes4 bes c bes |
+ a2. r4 |
+ } \\
+ \relative { % Voice = "2"
+ d'2 d4 g |
+ g4 g g8( a) g4 |
+ fis2. s4 |
+ }
+>>
@end lilypond
of slurs, stems, ties, dynamics etc., is set appropriately.
@lilypond[quote,verbatim]
-\new Staff \relative c' {
+\new Staff \relative {
+ % Main voice
+ c'16 d e f
+ % Voice = "1" Voice = "2" Voice = "3"
+ << { g4 f e } \\ { r8 e4 d c8~ } >> |
+ << { d2 e } \\ { c8 b16 a b8 g~ 2 } \\ { s4 b c2 } >> |
+}
+@end lilypond
+
+@funindex \voices
+If you prefer entering the voices in a different order, like top
+to bottom, you can specify the respective voice numbers in front
+of one @code{<< @dots{} >>} construct using the @code{\voices}
+command, like
+
+@lilypond[quote,verbatim]
+\new Staff \relative {
% Main voice
- c16 d e f
- % Voice "1" Voice "2" Voice "3"
+ c'16 d e f
+ % Voice = "1" Voice = "2"
<< { g4 f e } \\ { r8 e4 d c8~ } >> |
- << { d2 e } \\ { c8 b16 a b8 g~ g2 } \\ { s4 b c2 } >> |
+ \voices 1,3,2
+ % Voice = "1" Voice = "3" Voice = "2"
+ << { d2 e } \\ { s4 b c2 } \\ { c8 b16 a b8 g~ 2 } >> |
}
@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{<< @dots{} >>} 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,
blue triangle voice.
@lilypond[quote,verbatim]
-\new Staff \relative c' {
+\new Staff \relative {
% Main voice
- c16 d e f
+ c'16 d e f
<< % Bar 1
{
\voiceOneStyle
{ d2 e }
\\
% Voice 2 continues
- { c8 b16 a b8 g~ g2 }
+ { c8 b16 a b8 g~ 2 }
\\
{
\voiceThreeStyle
We shall see later how commands like these may be created by the
user.
See @ref{Visibility and color of objects} and
-@ref{Using variables for tweaks}.
+@ref{Using variables for layout adjustments}.
@cindex polyphony and relative note entry
@cindex relative note entry and polyphony
preceding chord. So in
@example
-\relative c' @{ noteA << < noteB noteC > \\ noteD >> noteE @}
+\relative @{ noteA << < noteB noteC > \\ noteD >> noteE @}
@end example
@noindent
command at the start of each voice:
@example
-\relative c' @{ noteA ... @}
+\relative @{ noteA @dots{} @}
<<
- \relative c'' @{ < noteB noteC > ... @}
+ \relative @{ < noteB noteC > @dots{} @}
\\
- \relative g' @{ noteD ... @}
+ \relative @{ noteD @dots{} @}
>>
-\relative c' @{ noteE ... @}
+\relative @{ noteE @dots{} @}
@end example
Let us finally analyze the voices in a more complex piece of music.
@c The following should appear as music without code
@lilypond[quote,ragged-right]
-\new Staff \relative c'' {
+\new Staff \relative {
\key aes \major
+ \voices 1,2,4 % No voice three
<< % Voice one
- { c2 aes4. bes8 }
+ { c''2 aes4. bes8 }
\\ % Voice two
{
% Ignore these for now - they are explained in Ch 4
- \once \override NoteColumn.ignore-collision = ##t
+ \once \override NoteColumn.force-hshift = #0
<ees, c>2
\once \override NoteColumn.force-hshift = #0.5
des2
}
- \\ % No voice three
\\ % Voice four
{
\override NoteColumn.force-hshift = #0
@c The following should appear as music without code
@c The three voice styles should be defined in -init
@lilypond[quote,ragged-right]
-\new Staff \relative c'' {
+\new Staff \relative {
\key aes \major
+ \voices 1,2,4 % No Voice three (we want stems down)
<<
{ % Voice one
\voiceOneStyle
- c2 aes4. bes8
+ c''2 aes4. bes8
}
\\ % Voice two
{ \voiceTwoStyle
% Ignore these for now - they are explained in Ch 4
- \once \override NoteColumn.ignore-collision = ##t
+ \once \override NoteColumn.force-hshift = #0
<ees, c>2
\once \override NoteColumn.force-hshift = #0.5
des2
}
- \\ % No Voice three (we want stems down)
\\ % Voice four
{ \voiceThreeStyle
\override NoteColumn.force-hshift = #0
enter the music of the first bar in three voices:
@lilypond[quote,verbatim,ragged-right]
-\new Staff \relative c'' {
+\new Staff \relative {
\key aes \major
<<
- { c2 aes4. bes8 } \\ { <ees, c>2 des } \\ { aes'2 f4 fes }
+ { c''2 aes4. bes8 } \\ { <ees, c>2 des } \\ { aes'2 f4 fes }
>> |
<c ees aes c>1 |
}
voices downward ones. The stems for voices 1 and 2 are right,
but the stems in voice 3 should go down in this particular piece
of music. We can correct this by skipping voice three
-and placing the music in voice four. This is done by simply
-adding another pair of @code{\\}.
+and placing the music in voice four. This could be done by simply
+adding another pair of @code{\\}, but we use the @code{\voices}
+command instead (which would also allow us to enter the voices in
+different order if we preferred doing that):
@lilypond[quote,verbatim,ragged-right]
-\new Staff \relative c'' {
+\new Staff \relative {
\key aes \major
+ \voices 1,2,4 % Omit Voice three
<< % Voice one
- { c2 aes4. bes8 }
+ { c''2 aes4. bes8 }
\\ % Voice two
{ <ees, c>2 des }
- \\ % Omit Voice three
\\ % Voice four
{ aes'2 f4 fes }
>> |
@subsection Explicitly instantiating voices
@funindex \voiceOne
-@funindex voiceOne
@funindex \voiceTwo
-@funindex voiceTwo
@funindex \voiceThree
-@funindex voiceThree
@funindex \voiceFour
-@funindex voiceFour
@funindex \oneVoice
-@funindex oneVoice
@funindex \new Voice
@cindex voice contexts, creating
@example
\new Staff @{
- \relative c' @{
- << @{ e4 f g a @} \\ @{ c,4 d e f @} >>
+ \relative @{
+ << @{ e'4 f g a @} \\ @{ c,4 d e f @} >>
@}
@}
@end example
@example
\new Staff <<
- \new Voice = "1" @{ \voiceOne \relative c' @{ e4 f g a @} @}
- \new Voice = "2" @{ \voiceTwo \relative c' @{ c4 d e f @} @}
+ \new Voice = "1" @{ \voiceOne \relative @{ e'4 f g a @} @}
+ \new Voice = "2" @{ \voiceTwo \relative @{ c'4 d e f @} @}
>>
@end example
@c The following example should not display the code
@lilypond[ragged-right,quote]
\new Staff <<
- \new Voice = "1" { \voiceOne \relative c' { e4 f g a } }
- \new Voice = "2" { \voiceTwo \relative c' { c4 d e f } }
+ \new Voice = "1" { \voiceOne \relative { e'4 f g a } }
+ \new Voice = "2" { \voiceTwo \relative { c'4 d e f } }
>>
@end lilypond
markup, ties, slurs, and dynamics:
@lilypond[quote,ragged-right,verbatim]
-\relative c' {
+\relative {
% Default behavior or behavior after \oneVoice
- c4 d8~ d e4( f | g4 a) b-> c |
+ c'4 d8~ 8 e4( f | g4 a) b-> c |
}
@end lilypond
@lilypond[quote,ragged-right,verbatim]
-\relative c' {
+\relative {
\voiceOne
- c4 d8~ d e4( f | g4 a) b-> c |
+ c'4 d8~ 8 e4( f | g4 a) b-> c |
\oneVoice
- c,4 d8~ d e4( f | g4 a) b-> c |
+ c,4 d8~ 8 e4( f | g4 a) b-> c |
}
@end lilypond
@lilypond[quote,ragged-right,verbatim]
-\relative c' {
+\relative {
\voiceTwo
- c4 d8~ d e4( f | g4 a) b-> c |
+ c'4 d8~ 8 e4( f | g4 a) b-> c |
\oneVoice
- c,4 d8~ d e4( f | g4 a) b-> c |
+ c,4 d8~ 8 e4( f | g4 a) b-> c |
}
@end lilypond
-Now let's look at three different ways to notate the same passage of
+Now let's look at four different ways to notate the same passage of
polyphonic music, each of which is advantageous in different
circumstances, using the example from the previous section.
permitting a phrasing slur to be drawn over them.
@lilypond[quote,ragged-right,verbatim]
-\new Staff \relative c' {
+\new Staff \relative {
\voiceOneStyle
% This section is homophonic
- c16^( d e f
+ c'16^( d e f
% Start simultaneous section of three voices
<<
% Continue the main voice in parallel
\new Voice {
% Set stems, etc., down
\voiceTwo
- r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
+ r8 e4 d c8~ | 8 b16 a b8 g~ 2 |
}
% Initiate third voice
\new Voice {
}
@end lilypond
+@cindex voices, continued
+@funindex \voices
+
+The @code{\voices} command can also be used for continuing a main
+voice into the simultaneous construct:
+
+@lilypond[quote,ragged-right,verbatim]
+\new Staff \relative {
+ \new Voice = "main" {
+ \voiceOneStyle
+ % This section is homophonic
+ c'16^( d e f
+ % Start simultaneous section of three voices
+ \voices "main",2,3
+ <<
+ % Continue the main voice in parallel
+ { g4 f e | d2 e) | }
+ % Initiate second voice
+ \\
+ % Set stems, etc., down
+ { r8 e4 d c8~ | 8 b16 a b8 g~ 2 | }
+ \\
+ % Initiate third voice
+ % Set stems, etc, up
+ { s2. | s4 b c2 | }
+ >>
+ }
+}
+@end lilypond
+
+
@cindex nesting music expressions
@cindex nesting simultaneous constructs
@cindex nesting voices
typeset the music:
@lilypond[quote,ragged-right,verbatim]
-\new Staff \relative c' {
- c16^( d e f
+\new Staff \relative {
+ c'16^( d e f
<<
{ g4 f e | d2 e) | }
\new Voice {
\voiceTwo
r8 e4 d c8~ |
<<
- { c8 b16 a b8 g~ g2 | }
+ { c8 b16 a b8 g~ 2 | }
\new Voice {
\voiceThree
s4 b c2 |
as here:
@lilypond[quote,ragged-right,verbatim]
-\new Staff \relative c' <<
+\new Staff \relative <<
% Initiate first voice
\new Voice {
\voiceOne
- c16^( d e f g4 f e | d2 e) |
+ c'16^( d e f g4 f e | d2 e) |
}
% Initiate second voice
\new Voice {
% Set stems, etc, down
\voiceTwo
- s4 r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
+ s4 r8 e4 d c8~ | 8 b16 a b8 g~ 2 |
}
% Initiate third voice
\new Voice {
@cindex collisions, notes
@cindex shift commands
@funindex \shiftOff
-@funindex shiftOff
@funindex \shiftOn
-@funindex shiftOn
@funindex \shiftOnn
-@funindex shiftOnn
@funindex \shiftOnnn
-@funindex shiftOnnn
Closely spaced notes in a chord, or notes occurring at the same
time in different voices, are arranged in two, occasionally more,
down. If notes from two voices which have their stems in the
same direction are placed at the same position and both voices
have no shift or the same shift specified, the error message
-@qq{Too many clashing note columns} will be produced.
+@qq{This voice needs a @code{@bs{}voiceXx} or @code{@bs{}shiftXx} setting}
+will be produced.
@seealso
-Notation Reference: @ruser{Multiple voices}.
+Learning Manual:
+@ref{Moving objects}.
+
+Notation Reference:
+@ruser{Multiple voices}.
@node Voices and vocals
@funindex \new Lyrics
@funindex \lyricsto
-@funindex lyricsto
@funindex Lyrics
@cindex Lyrics context, creating
@cindex lyrics, linking to voice
@lilypond[quote,verbatim]
<<
\new Voice = "one" {
- \relative c'' {
+ \relative {
\autoBeamOff
\time 2/4
- c4 b8. a16 | g4. f8 | e4 d | c2 |
+ c''4 b8. a16 | g4. f8 | e4 d | c2 |
}
}
\new Lyrics \lyricsto "one" {
@cindex lyrics and beaming
@cindex beaming and lyrics
@funindex \autoBeamOff
-@funindex autoBeamOff
The automatic beaming which LilyPond uses by default works well
for instrumental music, but not so well for music with lyrics,
@funindex \new ChoirStaff
@funindex ChoirStaff
@funindex \lyricmode
-@funindex lyricmode
@cindex vocal score structure
@cindex choir staff
@lilypond[quote,verbatim]
global = { \key f \major \time 6/8 \partial 8 }
-SopOneMusic = \relative c'' {
- c8 | c8([ bes)] a a([ g)] f | f'4. b, | c4.~ c4
+SopOneMusic = \relative {
+ c''8 | c8([ bes)] a a([ g)] f | f'4. b, | c4.~ 4
}
SopOneLyrics = \lyricmode {
Let | flee -- cy flocks the | hills a -- dorn, __
}
-SopTwoMusic = \relative c' {
- r8 | r4. r4 c8 | a'8([ g)] f f([ e)] d | e8([ d)] c bes'
+SopTwoMusic = \relative {
+ r8 | r4. r4 c'8 | a'8([ g)] f f([ e)] d | e8([ d)] c bes'
}
SopTwoLyrics = \lyricmode {
Let | flee -- cy flocks the | hills a -- dorn,
@lilypond[quote,verbatim]
keyTime = { \key c \major \time 4/4 \partial 4 }
-SopMusic = \relative c' { c4 | e4. e8 g4 g | a4 a g }
-AltoMusic = \relative c' { c4 | c4. c8 e4 e | f4 f e }
-TenorMusic = \relative c { e4 | g4. g8 c4. b8 | a8 b c d e4 }
-BassMusic = \relative c { c4 | c4. c8 c4 c | f8 g a b c4 }
+SopMusic = \relative { c'4 | e4. e8 g4 g | a4 a g }
+AltoMusic = \relative { c'4 | c4. c8 e4 e | f4 f e }
+TenorMusic = \relative { e4 | g4. g8 c4. b8 | a8 b c d e4 }
+BassMusic = \relative { c4 | c4. c8 c4 c | f8 g a b c4 }
VerseOne =
\lyricmode { E -- | ter -- nal fa -- ther, | strong to save, }
output. For example, compare the input and output of the
following example:
-@lilypond[quote,verbatim,relative=2]
-cis4 cis2. | a4 a2. |
+@lilypond[quote,verbatim]
+\relative { cis''4 cis2. | a4 a2. | }
@end lilypond
The input is rather sparse, but in the output, bar lines,
@subsection Creating contexts
@funindex \new
-@funindex new
@cindex new contexts
@cindex creating contexts
@cindex contexts, creating
-In an input file a score block, introduced with a @code{\score}
-command, contains a single music expression and an associated
-output definition (either a @code{\layout} or a @code{\midi} block).
-The @code{Score} context is usually left to be created automatically
-when the interpretation of that music expression starts.
+In an input file, a score block (introduced with a @code{\score}
+command) contains a single music expression; but it can also contain
+associated output definitions too -- either a @code{\layout} block, a
+@code{\midi} block or both. The @code{Score} context is usually left to
+be created automatically when the interpretation of that music
+expression starts.
For scores with only one voice and one staff, the @code{Voice} and
@code{Staff} contexts may also be left to be created automatically,
\clef "treble"
\key g \minor
\new Voice { % create voice for RH notes
- \relative c'' { % start of RH notes
- d4 ees16 c8. |
+ \relative { % start of RH notes
+ d''4 ees16 c8. |
d4 ees16 c8. |
} % end of RH notes
} % end of RH voice
\key g \minor
\new Voice { % create LH voice one
\voiceOne
- \relative g { % start of LH voice one notes
+ \relative { % start of LH voice one notes
g8 <bes d> ees, <g c> |
g8 <bes d> ees, <g c> |
} % end of LH voice one notes
} % end of LH voice one
\new Voice { % create LH voice two
\voiceTwo
- \relative g { % start of LH voice two notes
+ \relative { % start of LH voice two notes
g4 ees |
g4 ees |
} % end of LH voice two notes
@tab Engraves clefs
@item Completion_heads_engraver
@tab Splits notes which cross bar lines
-@c The old Dynamic_engraver is deprecated. -jm
-@item New_dynamic_engraver
+@item Dynamic_engraver
@tab Creates hairpins and dynamic texts
@item Forbid_line_break_engraver
@tab Prevents line breaks if a musical element is still active
@cindex context properties, modifying
@cindex modifying context properties
@funindex \set
-@funindex set
@funindex \unset
-@funindex unset
Contexts are responsible for holding the values of a number of
context @emph{properties}. Many of them can be changed to
but occasionally it can be tricky. If the wrong context
is specified, no error message is produced, but the expected
action will not take place. For example, the
-@code{instrumentName} clearly lives in the @code{Staff} context, since
-it is the staff that is to be named.
-In this example the first staff is labeled, but not the second,
-because we omitted the context name.
+@code{clefGlyph} clearly lives in the @code{Staff} context, since
+it is the staff's clef glyph that is to be changed.
+In this example the first staff's clef is printed correctly, but not the
+second -- which prints the default treble clef instead of the
+expected bass (or F) clef -- because we omitted the context name.
@lilypond[quote,verbatim,ragged-right]
<<
- \new Staff \relative c'' {
- \set Staff.instrumentName = #"Soprano"
- c2 c
+ \new Staff \relative {
+ \set Staff.clefGlyph = "clefs.C"
+ c''2 c
}
- \new Staff \relative c' {
- \set instrumentName = #"Alto" % Wrong!
- d2 d
+ \new Staff \relative {
+ \set clefGlyph = "clefs.F" % Wrong!
+ d'2 d
}
>>
@end lilypond
Remember the default context name is @code{Voice}, so the second
-@code{\set} command set the property @code{instrumentName} in the
-@code{Voice} context to @qq{Alto}, but as LilyPond does not look
+@code{\set} command set the property @code{clefGlyph} in the
+@code{Voice} context to @code{clefs.F}, but as LilyPond does not look
for any such property in the @code{Voice} context, no
further action took place. This is not an error, and no error
message is logged in the log file.
Internals Reference: see @rinternals{Tunable context properties}, or
@rinternals{Contexts}.
-The @code{instrumentName} property will take effect only
+The @code{clefGlyph} property will take effect only
if it is set in the @code{Staff} context, but
some properties can be set in more than one context.
For example, the property @code{extraNatural} is by
@lilypond[quote,verbatim,ragged-right]
<<
- \new Staff \relative c'' {
- aeses2 aes
+ \new Staff \relative {
+ aeses'2 aes
}
- \new Staff \relative c'' {
+ \new Staff \relative {
\set Staff.extraNatural = ##f
- aeses2 aes
+ aeses'2 aes
}
>>
@end lilypond
@lilypond[quote,verbatim,ragged-right]
<<
- \new Staff \relative c'' {
- aeses2 aes
+ \new Staff \relative {
+ aeses'2 aes
}
- \new Staff \relative c'' {
+ \new Staff \relative {
\set Score.extraNatural = ##f
- aeses2 aes
+ aeses'2 aes
}
>>
@end lilypond
-As another example, if @code{clefOctavation} is set in
+As another example, if @code{clefTransposition} is set in
the @code{Score} context this immediately changes the value
-of the octavation in all current staves and sets a new default
+of the transposition in all current staves and sets a new default
value which will be applied to all staves.
The opposite command, @code{\unset}, effectively removes the
other things) several times. The change is from the default
value, not the most recently set value.
-@lilypond[quote,verbatim,ragged-right,relative=1]
-c4 d
-% make note heads smaller
-\set fontSize = #-4
-e4 f |
-% make note heads larger
-\set fontSize = #2.5
-g4 a
-% return to default size
-\unset fontSize
-b4 c |
+@lilypond[quote,verbatim,ragged-right]
+\relative {
+ c'4 d
+ % make note heads smaller
+ \set fontSize = #-4
+ e4 f |
+ % make note heads larger
+ \set fontSize = #2.5
+ g4 a
+ % return to default size
+ \unset fontSize
+ b4 c |
+}
@end lilypond
We have now seen how to set the values of several different types of
@subsubheading Setting context properties with @code{\with}
@funindex \with
-@funindex with
@cindex context properties, setting with \with
The default value of context properties may be set at the time the
context is created. Sometimes this is a clearer way of setting a
property value if it is to remain fixed for the duration of
the context. When a context is created with a @code{\new}
-command it may be followed immediately by a @code{\with @{ .. @}}
+command it may be followed immediately by a @code{\with @{ @dots{} @}}
block in which the default property values are set. For example,
if we wish to suppress the printing of extra naturals for the
duration of a staff we would write:
@lilypond[quote,verbatim,ragged-right]
<<
\new Staff {
- \relative c'' {
- gisis4 gis aeses aes
+ \relative {
+ gisis'4 gis aeses aes
}
}
\new Staff \with { extraNatural = ##f } {
- \relative c'' {
- gisis4 gis aeses aes
+ \relative {
+ gisis'4 gis aeses aes
}
}
>>
@cindex context properties, setting with \context
@funindex \context
-@funindex context
The values of context properties may be set in @emph{all} contexts
of a particular type, such as all @code{Staff} contexts, with a single
@code{\context} block within a @code{\layout} block. Each
@code{\context} block will affect all contexts of the type specified
throughout the @code{\score} or @code{\book} block in which the
-@code{\layout} block appears. Here is a example to show the format:
+@code{\layout} block appears. Here is an example to show the format:
@lilypond[verbatim,quote]
\score {
\new Staff {
- \relative c'' {
- cisis4 e d cis
+ \relative {
+ cisis''4 e d cis
}
}
\layout {
\score {
<<
\new Staff {
- \relative c'' {
- gisis4 gis aeses aes
+ \relative {
+ gisis'4 gis aeses aes
}
}
\new Staff {
- \relative c'' {
- gisis4 gis aeses aes
+ \relative {
+ gisis'4 gis aeses aes
}
}
>>
@cindex removing engravers
@funindex \consists
-@funindex consists
@funindex \remove
-@funindex remove
We have seen that contexts each contain several engravers, each
of which is responsible for producing a particular part of the
\new Staff \with {
\remove "Staff_symbol_engraver"
}
-\relative c' {
- c4 d
+\relative {
+ c'4 d
\set fontSize = #-4 % make note heads smaller
e4 f |
\set fontSize = #2.5 % make note heads larger
\new Voice \with {
\consists "Ambitus_engraver"
} {
- \relative c'' {
+ \relative {
\voiceOne
- c4 a b g
+ c''4 a b g
}
}
\new Voice {
- \relative c' {
+ \relative {
\voiceTwo
- c4 e d f
+ c'4 e d f
}
}
>>
}
<<
\new Voice {
- \relative c'' {
+ \relative {
\voiceOne
- c4 a b g
+ c''4 a b g
}
}
\new Voice {
- \relative c' {
+ \relative {
\voiceTwo
- c4 e d f
+ c'4 e d f
}
}
>>
@subsubheading Changing all contexts of the same type
@funindex \layout
-@funindex layout
The examples above show how to remove or add engravers to
individual contexts. It is also possible to remove or add
\score {
<<
\new Staff {
- \relative c'' {
- c4 a b g
+ \relative {
+ c''4 a b g
}
}
\new Staff {
- \relative c' {
- c4 a b g
+ \relative {
+ c'4 a b g
}
}
\new Staff {
\clef "G_8"
- \relative c' {
- c4 a b g
+ \relative {
+ c'4 a b g
}
}
\new Staff {
\clef "bass"
- \relative c {
+ \relative {
c4 a b g
}
}
@example
\version @w{"@version{}"}
-melody = \relative c' @{
+melody = \relative @{
\clef "treble"
\key c \major
\time 4/4
@example
\version @w{"@version{}"}
-melody = \relative c' @{
+melody = \relative @{
\clef "treble"
\key c \major
\time 4/4
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{melody = \relative @{ } part) and the name's use (in the
@code{\score} section).
While we're doing this, let's change the cello part's staff --
@example
\version @w{"@version{}"}
-sopranoMusic = \relative c' @{
+sopranoMusic = \relative @{
\clef "treble"
\key c \major
\time 4/4
Aaa Bee Cee Dee
@}
-celloMusic = \relative c @{
+celloMusic = \relative @{
\clef "bass"
\key c \major
\time 4/4
easily fixed. Here's the complete soprano and cello template.
@lilypond[quote,verbatim,ragged-right,addversion]
-sopranoMusic = \relative c' {
+sopranoMusic = \relative {
\clef "treble"
\key c \major
\time 4/4
Aaa Bee Cee Dee
}
-celloMusic = \relative c {
+celloMusic = \relative {
\clef "bass"
\key c \major
\time 4/4
@lilypond[quote,ragged-right]
global = { \key d \major \time 4/4 }
-sopranoMusic = \relative c'' {
+sopranoMusic = \relative {
\clef "treble"
- r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
+ r4 d''2 a4 | d4. d8 a2 | cis4 d cis2 |
}
sopranoWords = \lyricmode {
Wor -- thy | is the lamb | that was slain |
}
-altoMusic = \relative a' {
+altoMusic = \relative {
\clef "treble"
- r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
+ r4 a'2 a4 | fis4. fis8 a2 | g4 fis e2 |
}
altoWords = \sopranoWords
-tenorMusic = \relative c' {
+tenorMusic = \relative {
\clef "G_8"
- r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
+ r4 fis'2 e4 | d4. d8 d2 | e4 a, cis2 |
}
tenorWords = \sopranoWords
-bassMusic = \relative c' {
+bassMusic = \relative {
\clef "bass"
- r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
+ r4 d'2 cis4 | b4. b8 fis2 | e4 d a'2 |
}
bassWords = \sopranoWords
-upper = \relative a' {
+upper = \relative {
\clef "treble"
\global
- r4 <a d fis>2 <a e' a>4 |
+ r4 <a' d fis>2 <a e' a>4 |
<d fis d'>4. <d fis d'>8 <a d a'>2 |
<g cis g'>4 <a d fis> <a cis e>2 |
}
-lower = \relative c, {
+lower = \relative {
\clef "bass"
\global
- <d d'>4 <d d'>2 <cis cis'>4 |
+ <d, d'>4 <d d'>2 <cis cis'>4 |
<b b'>4. <b' b'>8 <fis fis'>2 |
<e e'>4 <d d'> <a' a'>2 |
}
\score {
<< % combine ChoirStaff and PianoStaff in parallel
\new ChoirStaff <<
- \new Staff = "sopranos" <<
- \set Staff.instrumentName = #"Soprano"
+ \new Staff = "sopranos"
+ \with { instrumentName = #"Soprano" }
+ <<
\new Voice = "sopranos" {
\global
\sopranoMusic
\new Lyrics \lyricsto "sopranos" {
\sopranoWords
}
- \new Staff = "altos" <<
- \set Staff.instrumentName = #"Alto"
+ \new Staff = "altos"
+ \with { instrumentName = #"Alto" }
+ <<
\new Voice = "altos" {
\global
\altoMusic
}
>>
- \new Lyrics \lyricsto "altos" { \altoWords }
- \new Staff = "tenors" <<
- \set Staff.instrumentName = #"Tenor"
+ \new Lyrics \lyricsto "altos" {
+ \altoWords
+ }
+ \new Staff = "tenors"
+ \with { instrumentName = #"Tenor" }
+ <<
\new Voice = "tenors" {
\global
\tenorMusic
}
>>
- \new Lyrics \lyricsto "tenors" { \tenorWords }
- \new Staff = "basses" <<
- \set Staff.instrumentName = #"Bass"
+ \new Lyrics \lyricsto "tenors" {
+ \tenorWords
+ }
+ \new Staff = "basses"
+ \with { instrumentName = #"Bass" }
+ <<
\new Voice = "basses" {
\global
\bassMusic
\bassWords
}
>> % end ChoirStaff
- \new PianoStaff <<
- \set PianoStaff.instrumentName = #"Piano"
+ \new PianoStaff \with { instrumentName = #"Piano" }
+ <<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
}
@end lilypond
-None of the templates provides this layout exactly. The nearest is
+@warning{This layout can be achieved very easily using the built-in
+template: @code{satb.ly}, see @ref{Built-in templates}. But for ease
+of use this template deliberately hides the necessary context
+structure, instead providing it automatically. So for purposes of
+learning let us see how to build this up from scratch. You may need
+to do this if the built-in template does not meet your needs
+adequately.}
+
+The nearest copy-and-edit template to this layout is
@ref{SATB vocal score and automatic piano reduction} -- but we need
to change the layout and add a piano
accompaniment which is not derived automatically from the vocal parts.
@example
\new ChoirStaff <<
- \new Staff = "sopranos" <<
- \set Staff.instrumentName = #"Soprano"
+ \new Staff = "sopranos"
+ \with @{ instrumentName = #"Soprano" @}
+ <<
\new Voice = "sopranos" @{
\global
\sopranoMusic
\new Lyrics \lyricsto "sopranos" @{
\sopranoWords
@}
- \new Staff = "altos" <<
- \set Staff.instrumentName = #"Alto"
+ \new Staff = "altos"
+ \with @{ instrumentName = #"Alto" @}
+ <<
\new Voice = "altos" @{
\global
\altoMusic
\new Lyrics \lyricsto "altos" @{
\altoWords
@}
- \new Staff = "tenors" <<
- \set Staff.instrumentName = #"Tenor"
+ \new Staff = "tenors"
+ \with @{ instrumentName = #"Tenor" @}
+ <<
\new Voice = "tenors" @{
\global
\tenorMusic
\new Lyrics \lyricsto "tenors" @{
\tenorWords
@}
- \new Staff = "basses" <<
- \set Staff.instrumentName = #"Bass"
+ \new Staff = "basses"
+ \with @{ instrumentName = #"Bass" @}
+ <<
\new Voice = "basses" @{
\global
\bassMusic
@q{Solo piano} template:
@example
-\new PianoStaff <<
- \set PianoStaff.instrumentName = #"Piano "
+\new PianoStaff \with @{ instrumentName = #"Piano " @}
+<<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
@}
>> % end ChoirStaff
- \new PianoStaff <<
- \set PianoStaff.instrumentName = #"Piano"
+ \new PianoStaff \with @{ instrumentName = #"Piano" @}
+ <<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
@lilypond[quote,verbatim,ragged-right,addversion]
global = { \key d \major \time 4/4 }
-sopranoMusic = \relative c'' {
+sopranoMusic = \relative {
\clef "treble"
- r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
+ r4 d''2 a4 | d4. d8 a2 | cis4 d cis2 |
}
sopranoWords = \lyricmode {
Wor -- thy | is the lamb | that was slain |
}
-altoMusic = \relative a' {
+altoMusic = \relative {
\clef "treble"
- r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
+ r4 a'2 a4 | fis4. fis8 a2 | g4 fis fis2 |
}
altoWords = \sopranoWords
-tenorMusic = \relative c' {
+tenorMusic = \relative {
\clef "G_8"
- r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
+ r4 fis'2 e4 | d4. d8 d2 | e4 a, cis2 |
}
tenorWords = \sopranoWords
-bassMusic = \relative c' {
+bassMusic = \relative {
\clef "bass"
- r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
+ r4 d'2 cis4 | b4. b8 fis2 | e4 d a'2 |
}
bassWords = \sopranoWords
-upper = \relative a' {
+upper = \relative {
\clef "treble"
\global
- r4 <a d fis>2 <a e' a>4 |
+ r4 <a' d fis>2 <a e' a>4 |
<d fis d'>4. <d fis d'>8 <a d a'>2 |
<g cis g'>4 <a d fis> <a cis e>2 |
}
-lower = \relative c, {
+lower = \relative {
\clef "bass"
\global
- <d d'>4 <d d'>2 <cis cis'>4 |
+ <d, d'>4 <d d'>2 <cis cis'>4 |
<b b'>4. <b' b'>8 <fis fis'>2 |
<e e'>4 <d d'> <a' a'>2 |
}
\score {
<< % combine ChoirStaff and PianoStaff in parallel
\new ChoirStaff <<
- \new Staff = "sopranos" <<
- \set Staff.instrumentName = #"Soprano"
+ \new Staff = "sopranos"
+ \with { instrumentName = #"Soprano" }
+ <<
\new Voice = "sopranos" {
\global
\sopranoMusic
\new Lyrics \lyricsto "sopranos" {
\sopranoWords
}
- \new Staff = "altos" <<
- \set Staff.instrumentName = #"Alto"
+ \new Staff = "altos"
+ \with { instrumentName = #"Alto" }
+ <<
\new Voice = "altos" {
\global
\altoMusic
\new Lyrics \lyricsto "altos" {
\altoWords
}
- \new Staff = "tenors" <<
- \set Staff.instrumentName = #"Tenor"
+ \new Staff = "tenors"
+ \with { instrumentName = #"Tenor" }
+ <<
\new Voice = "tenors" {
\global
\tenorMusic
\new Lyrics \lyricsto "tenors" {
\tenorWords
}
- \new Staff = "basses" <<
- \set Staff.instrumentName = #"Bass"
+ \new Staff = "basses"
+ \with { instrumentName = #"Bass" }
+ <<
\new Voice = "basses" {
\global
\bassMusic
}
>> % end ChoirStaff
- \new PianoStaff <<
- \set PianoStaff.instrumentName = #"Piano "
+ \new PianoStaff
+ \with { instrumentName = #"Piano " }
+ <<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
@end example
It is not necessary to use the simultaneous construct
-@code{<< .. >>} for the manual two staff and the pedal organ staff,
+@code{<< @dots{} >>} for the manual two staff and the pedal organ staff,
since they contain only one music expression, but it does no harm,
and always using angle brackets after @code{\new Staff} is a good
habit to cultivate in case there are multiple voices. The opposite
is true for Voices: these should habitually be followed by braces
-@code{@{ .. @}} in case your music is coded in several variables
+@code{@{ @dots{} @}} in case your music is coded in several variables
which need to run consecutively.
Let's add this structure to the score block, and adjust the indenting.
composer = "J S Bach"
}
keyTime = { \key c \minor \time 4/4 }
-ManualOneVoiceOneMusic = \relative g' {
- g4 g f ees |
+ManualOneVoiceOneMusic = \relative {
+ g'4 g f ees |
d2 c |
}
-ManualOneVoiceTwoMusic = \relative c' {
- ees16 d ees8~ ees16 f ees d c8 d~ d c~ |
- c8 c4 b8 c8. g16 c b c d |
+ManualOneVoiceTwoMusic = \relative {
+ ees'16 d ees8~ 16 f ees d c8 d~ d c~ |
+ 8 c4 b8 c8. g16 c b c d |
}
-ManualTwoMusic = \relative c' {
- c16 b c8~ c16 b c g a8 g~ g16 g aes ees |
- f16 ees f d g aes g f ees d ees8~ ees16 f ees d |
+ManualTwoMusic = \relative {
+ c'16 b c8~ 16 b c g a8 g~ 16 g aes ees |
+ f16 ees f d g aes g f ees d ees8~ 16 f ees d |
}
-PedalOrganMusic = \relative c {
- r8 c16 d ees d ees8~ ees16 a, b g c b c8 |
+PedalOrganMusic = \relative {
+ r8 c16 d ees d ees8~ 16 a, b g c b c8 |
r16 g ees f g f g8 c,2 |
}
By this point, you've seen this kind of thing:
@lilypond[quote,verbatim,ragged-right]
-hornNotes = \relative c'' { c4 b dis c }
+hornNotes = \relative { c''4 b dis c }
\score {
{
You may even realize that this could be useful in minimalist music:
@lilypond[quote,verbatim,ragged-right]
-fragmentA = \relative c'' { a4 a8. b16 }
-fragmentB = \relative c'' { a8. gis16 ees4 }
+fragmentA = \relative { a'4 a8. b16 }
+fragmentB = \relative { a'8. gis16 ees4 }
violin = \new Staff {
\fragmentA \fragmentA |
However, you can also use these variables (also known as
macros, or user-defined commands) for tweaks:
-@c TODO Avoid padtext - not needed with skylining
@lilypond[quote,verbatim,ragged-right]
dolce = \markup { \italic \bold dolce }
-padText = { \once \override TextScript.padding = #5.0 }
+centreText = { \once \override TextScript.self-alignment-X = #CENTER }
+
fthenp =_\markup {
\dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p
}
-violin = \relative c'' {
+violin = \relative {
\repeat volta 2 {
- c4._\dolce b8 a8 g a b |
- \padText
- c4.^"hi there!" d8 e' f g d |
- c,4.\fthenp b8 c4 c-. |
+ c''4._\dolce b8 a8 g a b |
+ \centreText
+ c4.^"hi there!" d8 e f g d |
+ c4.\fthenp b8 c4 c-. |
}
}
{
\violin
}
- \layout { ragged-right = ##t }
}
@end lilypond
the last line.
@example
-violin = \relative c'' @{
+violin = \relative @{
\repeat volta 2 @{
- c4._\markup @{ \italic \bold dolce @} b8 a8 g a b |
- \once \override TextScript.padding = #5.0
- c4.^"hi there!" d8 e' f g d |
- c,4.\markup @{
+ c''4._\markup @{ \italic \bold dolce @} b8 a8 g a b |
+ \once \override TextScript.self-alignment-X = #CENTER
+ c4.^"hi there!" d8 e f g d |
+ c4._\markup @{
\dynamic f \italic \small @{ 2nd @} \hspace #0.1 \dynamic p
@}
b8 c4 c-. |
@}
@end example
-@c TODO Replace the following with a better example -td
-@c Skylining handles this correctly without padText
-
So far we've seen static substitution -- when LilyPond
-sees @code{\padText}, it replaces it with the stuff that
+sees @code{\centreText}, it replaces it with the stuff that
we've defined it to be (ie the stuff to the right of
-@code{padtext=}).
+@code{centreText=}).
LilyPond can handle non-static substitution, too (you
can think of these as functions).
@lilypond[quote,verbatim,ragged-right]
padText =
#(define-music-function
- (parser location padding)
+ (padding)
(number?)
#{
\once \override TextScript.padding = #padding
#})
-\relative c''' {
- c4^"piu mosso" b a b |
+\relative {
+ c''4^"piu mosso" b a b
\padText #1.8
- c4^"piu mosso" d e f |
+ c4^"piu mosso" b a b
\padText #2.6
- c4^"piu mosso" fis a g |
+ c4^"piu mosso" b a b
}
@end lilypond
of a horn/@/bassoon duo
@example
-hornNotes = \relative c @{
+hornNotes = \relative @{
\time 2/4
r4 f8 a | cis4 f | e4 d |
@}
in the following output
@lilypond[quote,ragged-right]
-\transpose f c' \relative c {
+\transpose f c' \relative {
\time 2/4
r4 f8 a | cis4 f | e4 d |
}
R2*3
@end example
-When printing the part, multi-rests
-must be condensed. This is done by setting a run-time variable
+When printing the part, multi-measure rests must be compressed. There
+is a music function available to do this:
@example
-\set Score.skipBars = ##t
+\compressMMRests @{ ... @}
@end example
-@noindent
-This command sets the property @code{skipBars} in the
-@code{Score} context to true (@code{##t}). Prepending the rest and
-this option to the music above, leads to the following result
+Applying this to @code{hornNotes} gives:
@lilypond[quote,ragged-right]
-\transpose f c' \relative c {
+\compressMMRests \transpose f c' \relative {
\time 2/4
- \set Score.skipBars = ##t
R2*3 |
r4 f8 a | cis4 f | e4 d |
}
leading to
@lilypond[quote,ragged-right]
-\relative c <<
+\relative <<
\new Staff {
\clef "treble"
\time 2/4
>>
@end lilypond
+@seealso
+Learning Manual:
+@ref{Organizing pieces with variables}.
+Notation Reference:
+@ruser{Transpose},
+@ruser{Writing parts},
+@ruser{Full measure rests},
+@ruser{Including LilyPond files}.