~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to Documentation/user/putting.itely

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@c -*- coding: utf-8; mode: texinfo; -*-
 
2
@node Putting it all together
 
3
@chapter Putting it all together
 
4
 
 
5
This chapter discusses general LilyPond concepts and how to
 
6
create @code{\score} blocks.
 
7
 
 
8
 
 
9
@menu
 
10
* Extending the templates::     
 
11
* How LilyPond files work::     
 
12
* Score is a single musical expression::  
 
13
@end menu
 
14
 
 
15
 
 
16
@node Extending the templates
 
17
@section Extending the templates
 
18
 
 
19
You've read the tutorial, you know how to write music.  But how can you
 
20
get the staves that you want?  The templates are ok, but what if you
 
21
want something that isn't covered?
 
22
 
 
23
Start off with the template that seems closest to what you want to end
 
24
up with.  Let's say that you want to write something for soprano and
 
25
cello.  In this case, we would start with ``Notes and lyrics'' (for the
 
26
soprano part).
 
27
 
 
28
@example
 
29
\version "2.7.39"
 
30
melody = \relative c' @{
 
31
  \clef treble
 
32
  \key c \major
 
33
  \time 4/4
 
34
 
 
35
  a4 b c d
 
36
@}
 
37
 
 
38
text = \lyricmode @{
 
39
  Aaa Bee Cee Dee
 
40
@}
 
41
 
 
42
\score@{
 
43
  <<
 
44
    \new Voice = "one" @{
 
45
      \autoBeamOff
 
46
      \melody
 
47
    @}
 
48
    \new Lyrics \lyricsto "one" \text
 
49
  >>
 
50
  \layout @{ @}
 
51
  \midi @{ \tempo 4=60 @}
 
52
@}
 
53
@end example
 
54
 
 
55
Now we want to add a cello part.  Let's look at the ``Notes only'' example:
 
56
 
 
57
@example
 
58
\version "2.7.39"
 
59
melody = \relative c' @{
 
60
  \clef treble
 
61
  \key c \major
 
62
  \time 4/4
 
63
 
 
64
  a4 b c d
 
65
@}
 
66
     
 
67
\score @{
 
68
\new Staff \melody
 
69
\layout @{ @}
 
70
\midi @{ \tempo 4=60 @}
 
71
@}
 
72
@end example
 
73
 
 
74
We don't need two @code{\version} commands.  We'll need the @code{melody}
 
75
section.  We don't want two @code{\score} sections -- if we had two
 
76
@code{\score}s, we'd get the two parts separately.  We want them together,
 
77
as a duet.  Within the @code{\score} section, we don't need two
 
78
@code{\layout} or @code{\midi}.
 
79
 
 
80
If we simply cut and paste the @code{melody} section, we would end up with
 
81
two @code{melody} sections.  So let's rename them.  We'll call the section
 
82
for the soprano @code{sopranoMusic} and the section for the cello
 
83
@code{celloMusic}.  While we're doing this, let's rename @code{text}
 
84
to be @code{sopranoLyrics}.  Remember to rename both instances of all
 
85
these names -- both the initial definition (the
 
86
@code{melody = relative c' @{ } part) and the name's use (in the
 
87
@code{\score} section).
 
88
 
 
89
While we're doing this, let's change the cello part's staff -- celli
 
90
normally use bass clef.  We'll also give the cello some different
 
91
notes.
 
92
 
 
93
@example
 
94
\version "2.7.39"
 
95
sopranoMusic = \relative c' @{
 
96
  \clef treble
 
97
  \key c \major
 
98
  \time 4/4
 
99
 
 
100
  a4 b c d
 
101
@}
 
102
 
 
103
sopranoLyrics = \lyricmode @{
 
104
  Aaa Bee Cee Dee
 
105
@}
 
106
 
 
107
celloMusic = \relative c @{
 
108
  \clef bass
 
109
  \key c \major
 
110
  \time 4/4
 
111
 
 
112
  d4 g fis8 e d4
 
113
@}
 
114
 
 
115
\score@{
 
116
  <<
 
117
    \new Voice = "one" @{
 
118
      \autoBeamOff
 
119
      \sopranoMusic
 
120
    @}
 
121
    \new Lyrics \lyricsto "one" \sopranoLyrics
 
122
  >>
 
123
  \layout @{ @}
 
124
  \midi @{ \tempo 4=60 @}
 
125
@}
 
126
@end example
 
127
 
 
128
This is looking promising, but the cello part won't appear in the
 
129
score -- we haven't used it in the @code{\score} section.  If we
 
130
want the cello part to appear under the soprano part, we need to add
 
131
 
 
132
@example
 
133
\new Staff \celloMusic
 
134
@end example
 
135
 
 
136
@noindent
 
137
underneath the soprano stuff.  We also need to add @code{<<} and
 
138
@code{>>} around the music -- that tells LilyPond that there's
 
139
more than one thing (in this case, @code{Staff}) happening at once.  The
 
140
@code{\score} looks like this now
 
141
 
 
142
@example
 
143
\score@{
 
144
  <<
 
145
    <<
 
146
      \new Voice = "one" @{
 
147
        \autoBeamOff
 
148
        \sopranoMusic
 
149
      @}
 
150
      \new Lyrics \lyricsto "one" \sopranoLyrics
 
151
    >>
 
152
    \new Staff \celloMusic
 
153
  >>
 
154
  \layout @{ @}
 
155
  \midi @{ \tempo 4=60 @}
 
156
@}
 
157
@end example
 
158
 
 
159
@noindent
 
160
This looks a bit messy; the indentation is messed up now.  That is
 
161
easily fixed.  Here's the complete soprano and cello template.
 
162
 
 
163
@lilypond[quote,verbatim,ragged-right]
 
164
\version "2.7.39"
 
165
sopranoMusic = \relative c' {
 
166
  \clef treble
 
167
  \key c \major
 
168
  \time 4/4
 
169
 
 
170
  a4 b c d
 
171
}
 
172
 
 
173
sopranoLyrics = \lyricmode {
 
174
  Aaa Bee Cee Dee
 
175
}
 
176
 
 
177
celloMusic = \relative c {
 
178
  \clef bass
 
179
  \key c \major
 
180
  \time 4/4
 
181
 
 
182
  d4 g fis8 e d4
 
183
}
 
184
 
 
185
\score{
 
186
  <<
 
187
    <<
 
188
      \new Voice = "one" {
 
189
        \autoBeamOff
 
190
        \sopranoMusic
 
191
      }
 
192
      \new Lyrics \lyricsto "one" \sopranoLyrics
 
193
    >>
 
194
    \new Staff \celloMusic
 
195
  >>
 
196
  \layout { }
 
197
  \midi { \tempo 4=60 }
 
198
}
 
199
@end lilypond
 
200
 
 
201
 
 
202
 
 
203
@node How LilyPond files work
 
204
@section How LilyPond files work
 
205
 
 
206
The LilyPond input format is quite free-form, giving experienced
 
207
users a lot of flexibility to structure their files however they
 
208
wish.  However, this flexibility can make things confusing for
 
209
new users.  This section will explain some of this structure, but
 
210
may gloss over some details in favor of simplicity.  For a complete
 
211
description of the input format, see @ref{File structure}.
 
212
 
 
213
Most examples in this manual are little snippets -- for example
 
214
 
 
215
@example
 
216
c4 a b c
 
217
@end example
 
218
 
 
219
As you are (hopefully) aware by now, this will not compile by
 
220
itself.  These examples are shorthand for complete
 
221
examples.  They all need at least curly braces to compile
 
222
 
 
223
@example
 
224
@{
 
225
  c4 a b c
 
226
@}
 
227
@end example
 
228
 
 
229
Most examples also make use of the @code{\relative c'}
 
230
(or @code{c''}) command.  This is not necessary to merely
 
231
compile the examples, but in most cases the output will
 
232
look very odd if you omit the @code{\relative c'}.
 
233
 
 
234
@lilypond[quote,fragment,ragged-right,verbatim]
 
235
\relative c'' {
 
236
  c4 a b c
 
237
}
 
238
@end lilypond
 
239
 
 
240
Now we get to the only real stumbling block: LilyPond
 
241
input in this form is actually @emph{another}
 
242
shorthand.  Although it compiles and displays the
 
243
correct output, it is shorthand for
 
244
 
 
245
@example
 
246
\score @{
 
247
  \relative c'' @{
 
248
    c4 a b c
 
249
  @}
 
250
@}
 
251
@end example
 
252
 
 
253
A @code{\score} must begin with a single music
 
254
expression.  Remember that a music expression could
 
255
be anything from a single note to a huge
 
256
 
 
257
@example
 
258
@{
 
259
  \new GrandStaff <<
 
260
    insert the whole score of a Wagner opera in here
 
261
  >>
 
262
@}
 
263
@end example
 
264
 
 
265
@noindent
 
266
Since everything is inside @code{@{ ... @}}, it counts
 
267
as one music expression.
 
268
 
 
269
The @code{\score} can contain other things, such as
 
270
 
 
271
@example
 
272
\score @{
 
273
  @{ c'4 a b c' @}
 
274
  \layout @{ @}
 
275
  \paper @{ @}
 
276
  \midi @{ @}
 
277
  \header @{ @}
 
278
@}
 
279
@end example
 
280
 
 
281
@noindent
 
282
Some people put some of those commands outside the
 
283
@code{\score} block -- for example, @code{\header} is
 
284
often placed above the @code{\score}.  That's just
 
285
another shorthand that LilyPond accepts.
 
286
 
 
287
Another great shorthand is the ability to define
 
288
variables.  All the templates use this
 
289
 
 
290
@example
 
291
melody = \relative c' @{
 
292
  c4 a b c
 
293
@}
 
294
 
 
295
\score @{
 
296
  @{ \melody @}
 
297
@}
 
298
@end example
 
299
 
 
300
When LilyPond looks at this file, it takes the value of
 
301
@code{melody} (everything after the equals sign) and
 
302
inserts it whenever it sees
 
303
@code{\melody}.  There's nothing special about the
 
304
names -- it could be @code{melody}, @code{global},
 
305
@code{pianorighthand}, or @code{foofoobarbaz}.  You
 
306
can use whatever variable names you want.  For
 
307
more details, see
 
308
@ref{Saving typing with identifiers and functions}.
 
309
 
 
310
For a complete definition
 
311
of the input format, see @ref{File structure}.
 
312
 
 
313
 
 
314
@node Score is a single musical expression
 
315
@section Score is a single musical expression
 
316
 
 
317
In the previous section, @ref{How LilyPond files work},
 
318
we saw the general organization of LilyPond input
 
319
files.  But we seemed to skip over the most important
 
320
part: how do we figure out what to write after
 
321
@code{\score}?
 
322
 
 
323
We didn't skip over it at all.  The big mystery is simply
 
324
that there @emph{is} no mystery.  This line explains it
 
325
all:
 
326
 
 
327
@quotation
 
328
@emph{A @code{\score} must begin with a single music expression.}
 
329
@end quotation
 
330
 
 
331
@noindent
 
332
You may find it useful to review
 
333
@ref{Music expressions explained}.  In that section, we
 
334
saw how to build big music expressions from small
 
335
pieces -- we started from notes, then chords, etc.  Now
 
336
we're going to start from a big music expression and
 
337
work our way down.
 
338
 
 
339
@example
 
340
\score @{
 
341
  @{   % this brace begins the overall music expression
 
342
    \new GrandStaff <<
 
343
      insert the whole score of a Wagner opera in here
 
344
    >>
 
345
  @}   % this brace ends the overall music expression
 
346
  \layout @{ @}
 
347
@}
 
348
@end example
 
349
 
 
350
A whole Wagner opera would easily double the length of
 
351
this manual, so let's just do a singer and piano.  We
 
352
don't need a @code{GrandStaff} for this ensemble, so we
 
353
shall remove it.  We @emph{do} need a singer and a piano,
 
354
though.
 
355
 
 
356
@example
 
357
\score @{
 
358
  @{
 
359
    <<
 
360
      \new Staff = "singer" <<
 
361
      >>
 
362
      \new PianoStaff = piano <<
 
363
      >>
 
364
    >>
 
365
  @}
 
366
  \layout @{ @}
 
367
@}
 
368
@end example
 
369
 
 
370
Remember that we use @code{<<} and @code{>>} to show
 
371
simultaneous music.  And we definitely want to show
 
372
the vocal part and piano part at the same time!
 
373
 
 
374
@example
 
375
\score @{
 
376
  @{
 
377
    <<
 
378
      \new Staff = "singer" <<
 
379
        \new Voice = "vocal" @{ @}
 
380
      >>
 
381
      \new Lyrics \lyricsto vocal \new Lyrics @{ @}
 
382
      \new PianoStaff = "piano" <<
 
383
        \new Staff = "upper" @{ @}
 
384
        \new Staff = "lower" @{ @}
 
385
      >>
 
386
    >>
 
387
  @}
 
388
  \layout @{ @}
 
389
@}
 
390
@end example
 
391
 
 
392
Now we have a lot more details.  We have the singer's
 
393
staff: it contains a @code{Voice} (in LilyPond, this
 
394
term refers to a set of notes, not necessarily vocal
 
395
notes -- for example, a violin generally plays one
 
396
voice) and some lyrics.  We also have a piano staff:
 
397
it contains an upper staff (right hand) and a lower
 
398
staff (left hand).
 
399
 
 
400
At this stage, we could start filling in notes.  Inside
 
401
the curly braces next to @code{\new Voice = vocal},
 
402
we could start writing
 
403
 
 
404
@example
 
405
\relative c'' @{
 
406
  a4 b c d
 
407
@}
 
408
@end example
 
409
 
 
410
But if we did that, the @code{\score} section would
 
411
get pretty long, and it would be harder to understand
 
412
what was happening.  So let's use identifiers (or
 
413
variables) instead.
 
414
 
 
415
@example
 
416
melody = @{ @}
 
417
text = @{ @}
 
418
upper = @{ @}
 
419
lower = @{ @}
 
420
\score @{
 
421
  @{
 
422
    <<
 
423
      \new Staff = "singer" <<
 
424
        \new Voice = "vocal" @{ \melody @}
 
425
      >>
 
426
      \new Lyrics \lyricsto vocal \new Lyrics @{ \text @}
 
427
      \new PianoStaff = "piano" <<
 
428
        \new Staff = "upper" @{ \upper @}
 
429
        \new Staff = "lower" @{ \lower @}
 
430
      >>
 
431
    >>
 
432
  @}
 
433
  \layout @{ @}
 
434
@}
 
435
@end example
 
436
 
 
437
@noindent
 
438
Remember that you can use almost any name you like.  The
 
439
limitations on identifier names are detailed in
 
440
@ref{File structure}.
 
441
 
 
442
When writing a @code{\score} section, or when reading
 
443
one, just take it slowly and carefully.  Start with
 
444
the outer layer, then work on each smaller
 
445
layer.  It also really helps to be strict with
 
446
indentation -- make sure that each item on the same
 
447
layer starts on the same horizontal position in your
 
448
text editor!
 
449
 
 
450