1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
10 @node Putting it all together
11 @chapter Putting it all together
13 This chapter discusses general LilyPond concepts and how to
14 create @code{\score} blocks.
18 * Extending the templates::
19 * How LilyPond files work::
20 * Score is a single musical expression::
24 @node Extending the templates
25 @section Extending the templates
27 You've read the tutorial, you know how to write music. But how can you
28 get the staves that you want? The templates are ok, but what if you
29 want something that isn't covered?
31 Start off with the template that seems closest to what you want to end
32 up with. Let's say that you want to write something for soprano and
33 cello. In this case, we would start with @q{Notes and lyrics} (for the
38 melody = \relative c' @{
56 \new Lyrics \lyricsto "one" \text
63 Now we want to add a cello part. Let's look at the @q{Notes only} example:
67 melody = \relative c' @{
82 We don't need two @code{\version} commands. We'll need the @code{melody}
83 section. We don't want two @code{\score} sections -- if we had two
84 @code{\score}s, we'd get the two parts separately. We want them together,
85 as a duet. Within the @code{\score} section, we don't need two
86 @code{\layout} or @code{\midi}.
88 If we simply cut and paste the @code{melody} section, we would end up with
89 two @code{melody} sections. So let's rename them. We'll call the section
90 for the soprano @code{sopranoMusic} and the section for the cello
91 @code{celloMusic}. While we're doing this, let's rename @code{text}
92 to be @code{sopranoLyrics}. Remember to rename both instances of all
93 these names -- both the initial definition (the
94 @code{melody = relative c' @{ } part) and the name's use (in the
95 @code{\score} section).
97 While we're doing this, let's change the cello part's staff -- celli
98 normally use bass clef. We'll also give the cello some different
103 sopranoMusic = \relative c' @{
111 sopranoLyrics = \lyricmode @{
115 celloMusic = \relative c @{
125 \new Voice = "one" @{
129 \new Lyrics \lyricsto "one" \sopranoLyrics
136 This is looking promising, but the cello part won't appear in the
137 score -- we haven't used it in the @code{\score} section. If we
138 want the cello part to appear under the soprano part, we need to add
141 \new Staff \celloMusic
145 underneath the soprano stuff. We also need to add @code{<<} and
146 @code{>>} around the music -- that tells LilyPond that there's
147 more than one thing (in this case, @code{Staff}) happening at once. The
148 @code{\score} looks like this now
154 \new Voice = "one" @{
158 \new Lyrics \lyricsto "one" \sopranoLyrics
160 \new Staff \celloMusic
168 This looks a bit messy; the indentation is messed up now. That is
169 easily fixed. Here's the complete soprano and cello template.
171 @lilypond[quote,verbatim,ragged-right]
173 sopranoMusic = \relative c' {
181 sopranoLyrics = \lyricmode {
185 celloMusic = \relative c {
200 \new Lyrics \lyricsto "one" \sopranoLyrics
202 \new Staff \celloMusic
211 @node How LilyPond files work
212 @section How LilyPond files work
214 The LilyPond input format is quite free-form, giving experienced
215 users a lot of flexibility to structure their files however they
216 wish. However, this flexibility can make things confusing for
217 new users. This section will explain some of this structure, but
218 may gloss over some details in favor of simplicity. For a complete
219 description of the input format, see @ref{File structure}.
221 Most examples in this manual are little snippets -- for example
227 As you are (hopefully) aware by now, this will not compile by
228 itself. These examples are shorthand for complete
229 examples. They all need at least curly braces to compile
237 Most examples also make use of the @code{\relative c'}
238 (or @code{c''}) command. This is not necessary to merely
239 compile the examples, but in most cases the output will
240 look very odd if you omit the @code{\relative c'}.
242 @lilypond[quote,fragment,ragged-right,verbatim]
248 Now we get to the only real stumbling block: LilyPond
249 input in this form is actually @emph{another}
250 shorthand. Although it compiles and displays the
251 correct output, it is shorthand for
261 A @code{\score} must begin with a single music
262 expression. Remember that a music expression could
263 be anything from a single note to a huge
268 insert the whole score of a Wagner opera in here
274 Since everything is inside @code{@{ ... @}}, it counts
275 as one music expression.
277 The @code{\score} can contain other things, such as
289 Some people put some of those commands outside the
290 @code{\score} block -- for example, @code{\header} is
291 often placed above the @code{\score}. That's just
292 another shorthand that LilyPond accepts.
297 Another great shorthand is the ability to define
298 variables. All the templates use this
301 melody = \relative c' @{
310 When LilyPond looks at this file, it takes the value of
311 @code{melody} (everything after the equals sign) and
312 inserts it whenever it sees
313 @code{\melody}. There's nothing special about the
314 names -- it could be @code{melody}, @code{global},
315 @code{pianorighthand}, or @code{foofoobarbaz}. You
316 can use whatever variable names you want. For
318 @ref{Saving typing with identifiers and functions}.
320 For a complete definition
321 of the input format, see @ref{File structure}.
324 @node Score is a single musical expression
325 @section Score is a single musical expression
327 In the previous section, @ref{How LilyPond files work},
328 we saw the general organization of LilyPond input
329 files. But we seemed to skip over the most important
330 part: how do we figure out what to write after
333 We didn't skip over it at all. The big mystery is simply
334 that there @emph{is} no mystery. This line explains it
338 @emph{A @code{\score} must begin with a single music expression.}
342 You may find it useful to review
343 @ref{Music expressions explained}. In that section, we
344 saw how to build big music expressions from small
345 pieces -- we started from notes, then chords, etc. Now
346 we're going to start from a big music expression and
351 @{ % this brace begins the overall music expression
353 insert the whole score of a Wagner opera in here
355 @} % this brace ends the overall music expression
360 A whole Wagner opera would easily double the length of
361 this manual, so let's just do a singer and piano. We
362 don't need a @code{GrandStaff} for this ensemble, so we
363 shall remove it. We @emph{do} need a singer and a piano,
370 \new Staff = "singer" <<
372 \new PianoStaff = piano <<
380 Remember that we use @code{<<} and @code{>>} to show
381 simultaneous music. And we definitely want to show
382 the vocal part and piano part at the same time!
388 \new Staff = "singer" <<
389 \new Voice = "vocal" @{ @}
391 \new Lyrics \lyricsto vocal \new Lyrics @{ @}
392 \new PianoStaff = "piano" <<
393 \new Staff = "upper" @{ @}
394 \new Staff = "lower" @{ @}
402 Now we have a lot more details. We have the singer's
403 staff: it contains a @code{Voice} (in LilyPond, this
404 term refers to a set of notes, not necessarily vocal
405 notes -- for example, a violin generally plays one
406 voice) and some lyrics. We also have a piano staff:
407 it contains an upper staff (right hand) and a lower
410 At this stage, we could start filling in notes. Inside
411 the curly braces next to @code{\new Voice = vocal},
412 we could start writing
420 But if we did that, the @code{\score} section would
421 get pretty long, and it would be harder to understand
422 what was happening. So let's use identifiers (or
433 \new Staff = "singer" <<
434 \new Voice = "vocal" @{ \melody @}
436 \new Lyrics \lyricsto vocal \new Lyrics @{ \text @}
437 \new PianoStaff = "piano" <<
438 \new Staff = "upper" @{ \upper @}
439 \new Staff = "lower" @{ \lower @}
448 Remember that you can use almost any name you like. The
449 limitations on identifier names are detailed in
450 @ref{File structure}.
452 When writing a @code{\score} section, or when reading
453 one, just take it slowly and carefully. Start with
454 the outer layer, then work on each smaller
455 layer. It also really helps to be strict with
456 indentation -- make sure that each item on the same
457 layer starts on the same horizontal position in your