]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/putting.itely
identifier => variable.
[lilypond.git] / Documentation / user / putting.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-learning.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @node Putting it all together
11 @chapter Putting it all together
12
13 This chapter discusses general LilyPond concepts and how to
14 create @code{\score} blocks.
15
16
17 @menu
18 * Extending the templates::     
19 * Scores and parts::            
20 @end menu
21
22
23 @node Extending the templates
24 @section Extending the templates
25
26 You've read the tutorial, you know how to write music.  But how can you
27 get the staves that you want?  The templates are ok, but what if you
28 want something that isn't covered?
29
30 @menu
31 * Soprano and cello::           
32 * Another example of extending templates::  
33 @end menu
34
35 @node Soprano and cello
36 @unnumberedsubsec Soprano and cello
37
38 Start off with the template that seems closest to what you want to end
39 up with.  Let's say that you want to write something for soprano and
40 cello.  In this case, we would start with @q{Notes and lyrics} (for the
41 soprano part).
42
43 @example
44 \version "2.11.23"
45 melody = \relative c' @{
46   \clef treble
47   \key c \major
48   \time 4/4
49
50   a4 b c d
51 @}
52
53 text = \lyricmode @{
54   Aaa Bee Cee Dee
55 @}
56
57 \score@{
58   <<
59     \new Voice = "one" @{
60       \autoBeamOff
61       \melody
62     @}
63     \new Lyrics \lyricsto "one" \text
64   >>
65   \layout @{ @}
66   \midi @{ @}
67 @}
68 @end example
69
70 Now we want to add a cello part.  Let's look at the @q{Notes only} example:
71
72 @example
73 \version "2.11.23"
74 melody = \relative c' @{
75   \clef treble
76   \key c \major
77   \time 4/4
78
79   a4 b c d
80 @}
81
82 \score @{
83 \new Staff \melody
84 \layout @{ @}
85 \midi @{ @}
86 @}
87 @end example
88
89 We don't need two @code{\version} commands.  We'll need the @code{melody}
90 section.  We don't want two @code{\score} sections -- if we had two
91 @code{\score}s, we'd get the two parts separately.  We want them together,
92 as a duet.  Within the @code{\score} section, we don't need two
93 @code{\layout} or @code{\midi}.
94
95 If we simply cut and paste the @code{melody} section, we would end up with
96 two @code{melody} sections.  So let's rename them.  We'll call the section
97 for the soprano @code{sopranoMusic} and the section for the cello
98 @code{celloMusic}.  While we're doing this, let's rename @code{text}
99 to be @code{sopranoLyrics}.  Remember to rename both instances of all
100 these names -- both the initial definition (the
101 @code{melody = relative c' @{ } part) and the name's use (in the
102 @code{\score} section).
103
104 While we're doing this, let's change the cello part's staff -- celli
105 normally use bass clef.  We'll also give the cello some different
106 notes.
107
108 @example
109 \version "2.11.23"
110 sopranoMusic = \relative c' @{
111   \clef treble
112   \key c \major
113   \time 4/4
114
115   a4 b c d
116 @}
117
118 sopranoLyrics = \lyricmode @{
119   Aaa Bee Cee Dee
120 @}
121
122 celloMusic = \relative c @{
123   \clef bass
124   \key c \major
125   \time 4/4
126
127   d4 g fis8 e d4
128 @}
129
130 \score@{
131   <<
132     \new Voice = "one" @{
133       \autoBeamOff
134       \sopranoMusic
135     @}
136     \new Lyrics \lyricsto "one" \sopranoLyrics
137   >>
138   \layout @{ @}
139   \midi @{ @}
140 @}
141 @end example
142
143 This is looking promising, but the cello part won't appear in the
144 score -- we haven't used it in the @code{\score} section.  If we
145 want the cello part to appear under the soprano part, we need to add
146
147 @example
148 \new Staff \celloMusic
149 @end example
150
151 @noindent
152 underneath the soprano stuff.  We also need to add @code{<<} and
153 @code{>>} around the music -- that tells LilyPond that there's
154 more than one thing (in this case, @code{Staff}) happening at once.  The
155 @code{\score} looks like this now
156
157 @example
158 \score@{
159   <<
160     <<
161       \new Voice = "one" @{
162         \autoBeamOff
163         \sopranoMusic
164       @}
165       \new Lyrics \lyricsto "one" \sopranoLyrics
166     >>
167     \new Staff \celloMusic
168   >>
169   \layout @{ @}
170   \midi @{ @}
171 @}
172 @end example
173
174 @noindent
175 This looks a bit messy; the indentation is messed up now.  That is
176 easily fixed.  Here's the complete soprano and cello template.
177
178 @lilypond[quote,verbatim,ragged-right]
179 \version "2.11.23"
180 sopranoMusic = \relative c' {
181   \clef treble
182   \key c \major
183   \time 4/4
184
185   a4 b c d
186 }
187
188 sopranoLyrics = \lyricmode {
189   Aaa Bee Cee Dee
190 }
191
192 celloMusic = \relative c {
193   \clef bass
194   \key c \major
195   \time 4/4
196
197   d4 g fis8 e d4
198 }
199
200 \score{
201   <<
202     <<
203       \new Voice = "one" {
204         \autoBeamOff
205         \sopranoMusic
206       }
207       \new Lyrics \lyricsto "one" \sopranoLyrics
208     >>
209     \new Staff \celloMusic
210   >>
211   \layout { }
212   \midi { }
213 }
214 @end lilypond
215
216
217 @node Another example of extending templates
218 @unnumberedsubsec Another example of extending templates
219
220 TODO: somebody else fill this in.  You guys like vocal stuff,
221 right?  Get to it.  :)  -gp
222
223
224
225 @node Scores and parts
226 @section Scores and parts
227
228 TODO: this is really old stuff from the really old tutorial.
229 Rewrite, fix, etc.  -gp
230
231 In orchestral music, all notes are printed twice.  Once in a part for
232 the musicians, and once in a full score for the conductor.  Variables can
233 be used to avoid double work.  The music is entered once, and stored in
234 a variable.  The contents of that variable is then used to generate
235 both the part and the full score.
236
237 It is convenient to define the notes in a special file.  For example,
238 suppose that the file @file{horn-music.ly} contains the following part
239 of a horn/@/bassoon duo
240
241 @example
242 hornNotes = \relative c @{
243   \time 2/4
244   r4 f8 a cis4 f e d
245 @}
246 @end example
247
248 @noindent
249 Then, an individual part is made by putting the following in a file
250
251 @example
252 \include "horn-music.ly"
253 \header @{
254   instrument = "Horn in F"
255 @}
256
257 @{
258  \transpose f c' \hornNotes
259 @}
260 @end example
261
262 The line
263
264 @example
265 \include "horn-music.ly"
266 @end example
267
268 @noindent
269 substitutes the contents of @file{horn-music.ly} at this position in
270 the file, so @code{hornNotes} is defined afterwards.  The command
271 @code{\transpose f@tie{}c'} indicates that the argument, being
272 @code{\hornNotes}, should be transposed by a fifth upwards.  Sounding
273 @samp{f} is denoted by notated @code{c'}, which corresponds with the
274 tuning of a normal French Horn in@tie{}F.  The transposition can be seen
275 in the following output
276
277 @lilypond[quote,ragged-right]
278 \transpose f c' \relative c {
279   \time 2/4
280   r4 f8 a cis4 f e d
281 }
282 @end lilypond
283
284 In ensemble pieces, one of the voices often does not play for many
285 measures.  This is denoted by a special rest, the multi-measure
286 rest.  It is entered with a capital @samp{R} followed by a duration
287 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
288 etc.).  By multiplying the
289 duration, longer rests can be constructed.  For example, this rest
290 takes 3@tie{}measures in 2/4 time
291
292 @example
293 R2*3
294 @end example
295
296 When printing the part, multi-rests
297 must be condensed.  This is done by setting a run-time variable
298
299 @example
300 \set Score.skipBars = ##t
301 @end example
302
303 @noindent
304 This command sets the property @code{skipBars} in the
305 @code{Score} context to true (@code{##t}).  Prepending the rest and
306 this option to the music above, leads to the following result
307
308 @lilypond[quote,ragged-right]
309 \transpose f c' \relative c {
310   \time 2/4
311   \set Score.skipBars = ##t
312   R2*3
313   r4 f8 a cis4 f e d
314 }
315 @end lilypond
316
317
318 The score is made by combining all of the music together.  Assuming
319 that the other voice is in @code{bassoonNotes} in the file
320 @file{bassoon-music.ly}, a score is made with
321
322 @example
323 \include "bassoon-music.ly"
324 \include "horn-music.ly"
325
326 <<
327   \new Staff \hornNotes
328   \new Staff \bassoonNotes
329 >>
330 @end example
331
332 @noindent
333 leading to
334
335 @lilypond[quote,ragged-right]
336 \relative c <<
337   \new Staff {
338     \time 2/4 R2*3
339     r4 f8 a cis4 f e d
340   }
341   \new Staff {
342     \clef bass
343     r4 d,8 f | gis4 c | b bes |
344     a8 e f4 | g d | gis f
345   }
346 >>
347 @end lilypond
348
349 More in-depth information on preparing parts and scores can be found
350 in the notation manual; see @ruser{Orchestral music}.
351
352 Setting run-time variables (@q{properties}) is discussed in
353 @ruser{Changing context properties on the fly}.
354
355
356