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::
21 * An orchestral part::
25 @node Extending the templates
26 @section Extending the templates
28 You've read the tutorial, you know how to write music. But how can you
29 get the staves that you want? The templates are ok, but what if you
30 want something that isn't covered?
32 Start off with the template that seems closest to what you want to end
33 up with. Let's say that you want to write something for soprano and
34 cello. In this case, we would start with @q{Notes and lyrics} (for the
39 melody = \relative c' @{
57 \new Lyrics \lyricsto "one" \text
64 Now we want to add a cello part. Let's look at the @q{Notes only} example:
68 melody = \relative c' @{
83 We don't need two @code{\version} commands. We'll need the @code{melody}
84 section. We don't want two @code{\score} sections -- if we had two
85 @code{\score}s, we'd get the two parts separately. We want them together,
86 as a duet. Within the @code{\score} section, we don't need two
87 @code{\layout} or @code{\midi}.
89 If we simply cut and paste the @code{melody} section, we would end up with
90 two @code{melody} sections. So let's rename them. We'll call the section
91 for the soprano @code{sopranoMusic} and the section for the cello
92 @code{celloMusic}. While we're doing this, let's rename @code{text}
93 to be @code{sopranoLyrics}. Remember to rename both instances of all
94 these names -- both the initial definition (the
95 @code{melody = relative c' @{ } part) and the name's use (in the
96 @code{\score} section).
98 While we're doing this, let's change the cello part's staff -- celli
99 normally use bass clef. We'll also give the cello some different
104 sopranoMusic = \relative c' @{
112 sopranoLyrics = \lyricmode @{
116 celloMusic = \relative c @{
126 \new Voice = "one" @{
130 \new Lyrics \lyricsto "one" \sopranoLyrics
137 This is looking promising, but the cello part won't appear in the
138 score -- we haven't used it in the @code{\score} section. If we
139 want the cello part to appear under the soprano part, we need to add
142 \new Staff \celloMusic
146 underneath the soprano stuff. We also need to add @code{<<} and
147 @code{>>} around the music -- that tells LilyPond that there's
148 more than one thing (in this case, @code{Staff}) happening at once. The
149 @code{\score} looks like this now
155 \new Voice = "one" @{
159 \new Lyrics \lyricsto "one" \sopranoLyrics
161 \new Staff \celloMusic
169 This looks a bit messy; the indentation is messed up now. That is
170 easily fixed. Here's the complete soprano and cello template.
172 @lilypond[quote,verbatim,ragged-right]
174 sopranoMusic = \relative c' {
182 sopranoLyrics = \lyricmode {
186 celloMusic = \relative c {
201 \new Lyrics \lyricsto "one" \sopranoLyrics
203 \new Staff \celloMusic
212 @node How LilyPond files work
213 @section How LilyPond files work
215 The LilyPond input format is quite free-form, giving experienced
216 users a lot of flexibility to structure their files however they
217 wish. However, this flexibility can make things confusing for
218 new users. This section will explain some of this structure, but
219 may gloss over some details in favor of simplicity. For a complete
220 description of the input format, see @ref{File structure}.
222 Most examples in this manual are little snippets -- for example
228 As you are (hopefully) aware by now, this will not compile by
229 itself. These examples are shorthand for complete
230 examples. They all need at least curly braces to compile
238 Most examples also make use of the @code{\relative c'}
239 (or @code{c''}) command. This is not necessary to merely
240 compile the examples, but in most cases the output will
241 look very odd if you omit the @code{\relative c'}.
243 @lilypond[quote,fragment,ragged-right,verbatim]
249 Now we get to the only real stumbling block: LilyPond
250 input in this form is actually @emph{another}
251 shorthand. Although it compiles and displays the
252 correct output, it is shorthand for
262 A @code{\score} must begin with a single music
263 expression. Remember that a music expression could
264 be anything from a single note to a huge
269 insert the whole score of a Wagner opera in here
275 Since everything is inside @code{@{ ... @}}, it counts
276 as one music expression.
278 The @code{\score} can contain other things, such as
290 Some people put some of those commands outside the
291 @code{\score} block -- for example, @code{\header} is
292 often placed above the @code{\score}. That's just
293 another shorthand that LilyPond accepts.
298 Another great shorthand is the ability to define
299 variables. All the templates use this
302 melody = \relative c' @{
311 When LilyPond looks at this file, it takes the value of
312 @code{melody} (everything after the equals sign) and
313 inserts it whenever it sees
314 @code{\melody}. There's nothing special about the
315 names -- it could be @code{melody}, @code{global},
316 @code{pianorighthand}, or @code{foofoobarbaz}. You
317 can use whatever variable names you want. For
319 @ref{Saving typing with identifiers and functions}.
321 For a complete definition
322 of the input format, see @ref{File structure}.
325 @node Score is a single musical expression
326 @section Score is a single musical expression
328 In the previous section, @ref{How LilyPond files work},
329 we saw the general organization of LilyPond input
330 files. But we seemed to skip over the most important
331 part: how do we figure out what to write after
334 We didn't skip over it at all. The big mystery is simply
335 that there @emph{is} no mystery. This line explains it
339 @emph{A @code{\score} must begin with a single music expression.}
343 You may find it useful to review
344 @ref{Music expressions explained}. In that section, we
345 saw how to build big music expressions from small
346 pieces -- we started from notes, then chords, etc. Now
347 we're going to start from a big music expression and
352 @{ % this brace begins the overall music expression
354 insert the whole score of a Wagner opera in here
356 @} % this brace ends the overall music expression
361 A whole Wagner opera would easily double the length of
362 this manual, so let's just do a singer and piano. We
363 don't need a @code{GrandStaff} for this ensemble, so we
364 shall remove it. We @emph{do} need a singer and a piano,
371 \new Staff = "singer" <<
373 \new PianoStaff = piano <<
381 Remember that we use @code{<<} and @code{>>} to show
382 simultaneous music. And we definitely want to show
383 the vocal part and piano part at the same time!
389 \new Staff = "singer" <<
390 \new Voice = "vocal" @{ @}
392 \new Lyrics \lyricsto vocal \new Lyrics @{ @}
393 \new PianoStaff = "piano" <<
394 \new Staff = "upper" @{ @}
395 \new Staff = "lower" @{ @}
403 Now we have a lot more details. We have the singer's
404 staff: it contains a @code{Voice} (in LilyPond, this
405 term refers to a set of notes, not necessarily vocal
406 notes -- for example, a violin generally plays one
407 voice) and some lyrics. We also have a piano staff:
408 it contains an upper staff (right hand) and a lower
411 At this stage, we could start filling in notes. Inside
412 the curly braces next to @code{\new Voice = vocal},
413 we could start writing
421 But if we did that, the @code{\score} section would
422 get pretty long, and it would be harder to understand
423 what was happening. So let's use identifiers (or
434 \new Staff = "singer" <<
435 \new Voice = "vocal" @{ \melody @}
437 \new Lyrics \lyricsto vocal \new Lyrics @{ \text @}
438 \new PianoStaff = "piano" <<
439 \new Staff = "upper" @{ \upper @}
440 \new Staff = "lower" @{ \lower @}
449 Remember that you can use almost any name you like. The
450 limitations on identifier names are detailed in
451 @ref{File structure}.
453 When writing a @code{\score} section, or when reading
454 one, just take it slowly and carefully. Start with
455 the outer layer, then work on each smaller
456 layer. It also really helps to be strict with
457 indentation -- make sure that each item on the same
458 layer starts on the same horizontal position in your
466 @node An orchestral part
467 @section An orchestral part
469 In orchestral music, all notes are printed twice. Once in a part for
470 the musicians, and once in a full score for the conductor. Identifiers can
471 be used to avoid double work. The music is entered once, and stored in
472 a variable. The contents of that variable is then used to generate
473 both the part and the full score.
475 It is convenient to define the notes in a special file. For example,
476 suppose that the file @file{horn-music.ly} contains the following part
477 of a horn/@/bassoon duo
480 hornNotes = \relative c @{
487 Then, an individual part is made by putting the following in a file
490 \include "horn-music.ly"
492 instrument = "Horn in F"
496 \transpose f c' \hornNotes
503 \include "horn-music.ly"
507 substitutes the contents of @file{horn-music.ly} at this position in
508 the file, so @code{hornNotes} is defined afterwards. The command
509 @code{\transpose f@tie{}c'} indicates that the argument, being
510 @code{\hornNotes}, should be transposed by a fifth upwards. Sounding
511 @samp{f} is denoted by notated @code{c'}, which corresponds with the
512 tuning of a normal French Horn in@tie{}F. The transposition can be seen
513 in the following output
515 @lilypond[quote,ragged-right]
516 \transpose f c' \relative c {
522 In ensemble pieces, one of the voices often does not play for many
523 measures. This is denoted by a special rest, the multi-measure
524 rest. It is entered with a capital @samp{R} followed by a duration
525 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
526 etc.). By multiplying the
527 duration, longer rests can be constructed. For example, this rest
528 takes 3@tie{}measures in 2/4 time
534 When printing the part, multi-rests
535 must be condensed. This is done by setting a run-time variable
538 \set Score.skipBars = ##t
542 This command sets the property @code{skipBars} in the
543 @code{Score} context to true (@code{##t}). Prepending the rest and
544 this option to the music above, leads to the following result
546 @lilypond[quote,ragged-right]
547 \transpose f c' \relative c {
549 \set Score.skipBars = ##t
556 The score is made by combining all of the music together. Assuming
557 that the other voice is in @code{bassoonNotes} in the file
558 @file{bassoon-music.ly}, a score is made with
561 \include "bassoon-music.ly"
562 \include "horn-music.ly"
565 \new Staff \hornNotes
566 \new Staff \bassoonNotes
573 @lilypond[quote,ragged-right]
581 r4 d,8 f | gis4 c | b bes |
582 a8 e f4 | g d | gis f
587 More in-depth information on preparing parts and scores can be found
588 in the notation manual; see @ref{Orchestral music}.
590 Setting run-time variables (@q{properties}) is discussed in
591 @ref{Changing context properties on the fly}.