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

« back to all changes in this revision

Viewing changes to Documentation/user/introduction.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 -*-texinfo-*-
 
1
@c -*- coding: utf-8; mode: texinfo; -*-
2
2
@c This file is part of lilypond.tely
3
3
 
4
4
@node Introduction
5
5
@chapter Introduction
6
6
 
7
 
LilyPond is a system for formatting music prettily.  This chapter
8
 
discusses the backgrounds of LilyPond.  It explains the problem of
9
 
printing music with computers, and our approach to solving those
10
 
problems.
11
 
 
12
7
 
13
8
@menu
14
9
* Engraving::
31
26
ink.  An image was formed by pressing paper to the plate.  The
32
27
stamping and cutting was completely done by hand.  Making a correction
33
28
was cumbersome, if possible at all, so the engraving had to be perfect
34
 
in one go.  Engraving was a highly specialized skill, a craftsman had
35
 
to complete around ten years of practical training before he could be
36
 
a master engraver.
 
29
in one go.  Engraving was a highly specialized skill; a craftsman had
 
30
to complete around five years of training before earning the title of
 
31
master engraver, and another five years of experience were
 
32
necessary to become truly skilled.
37
33
 
38
34
Nowadays, all newly printed music is produced with computers.  This
39
 
has obvious advantages; prints are cheaper to make, editorial work can
40
 
be delivered by email.  Unfortunately, the pervasive use of computers
41
 
has also decreased the graphical quality of scores.  Computer
42
 
printouts have a bland, mechanical look, which makes them unpleasant
43
 
to play from.
 
35
has obvious advantages; prints are cheaper to make, and editorial work
 
36
can be delivered by email.  Unfortunately, the pervasive use of
 
37
computers has also decreased the graphical quality of scores.
 
38
Computer printouts have a bland, mechanical look, which makes them
 
39
unpleasant to play from.
44
40
 
45
41
 
46
42
@c introduce illustrating aspects of engraving, font...
47
43
The images below illustrate the difference between traditional
48
44
engraving and typical computer output, and the third picture shows how
49
45
LilyPond mimics the traditional look.  The left picture shows a scan
50
 
of a flat symbol from a Henle edition published in 2000.  In the
51
 
center show symbol from a hand engraved B@"{a}renreiter edition of the
 
46
of a flat symbol from an edition published in 2000.  The center
 
47
depicts a symbol from a hand-engraved B@"{a}renreiter edition of the
52
48
same music.  The left scan illustrates typical flaws of computer
53
49
print: the staff lines are thin, the weight of the flat symbol matches
54
50
the light lines and it has a straight layout with sharp corners.  By
55
51
contrast, the B@"{a}renreiter flat has a bold, almost voluptuous
56
52
rounded look.  Our flat symbol is designed after, among others, this
57
53
one.  It is rounded, and its weight harmonizes with the thickness of
58
 
our staff lines, which are also much thicker than Henle's lines.
 
54
our staff lines, which are also much thicker than lines in the
 
55
computer edition.
59
56
 
60
 
@multitable @columnfractions  .05 .3 .3 .3 .05
 
57
@multitable @columnfractions .05 .3 .3 .3 .05
61
58
@item @tab
62
59
@ifnotinfo
63
60
@iftex
64
 
@image{henle-flat-bw,4cm}
65
 
@end iftex
66
 
@ifnottex
67
 
@image{henle-flat-bw,,,png}
68
 
@end ifnottex
69
 
 
70
 
@tab
71
 
@iftex
72
 
@image{baer-flat-bw,4cm}
73
 
@end iftex
74
 
@ifnottex
75
 
@image{baer-flat-bw,,,png}
76
 
@end ifnottex
77
 
 
78
 
@tab
79
 
@iftex
80
 
@image{lily-flat-bw,4cm}
 
61
@image{henle-flat-gray,,8cm}
 
62
@end iftex
 
63
@ifnottex
 
64
@image{henle-flat-gray,,,png}
 
65
@end ifnottex
 
66
 
 
67
@tab
 
68
@iftex
 
69
@image{baer-flat-gray,,8.4cm}
 
70
@end iftex
 
71
@ifnottex
 
72
@image{baer-flat-gray,,,png}
 
73
@end ifnottex
 
74
 
 
75
@tab
 
76
@iftex
 
77
@image{lily-flat-bw,,8cm}
81
78
@end iftex
82
79
@ifnottex
83
80
@image{lily-flat-bw,,,png}
85
82
@end ifnotinfo
86
83
@ifinfo
87
84
@c workaround for makeinfo-4.6: line breaks and multi-column cookies
88
 
@image{henle-flat-bw,,,png} @image{baer-flat-bw,,,png} @image{lily-flat-bw,,,png}
 
85
@image{henle-flat-bw,,,png} @image{baer-flat-bw,,,png} 
 
86
@image{lily-flat-bw,,,png}
89
87
@end ifinfo
90
88
 
91
89
@item @tab
106
104
@c introduce illustrating aspects of engraving, spacing...
107
105
In spacing, the distribution of space should reflect the durations
108
106
between notes.  However, many modern scores adhere to the durations
109
 
with mathematical precision, which leads to a poor result.  In the
 
107
with mathematical precision, which leads to poor results.  In the
110
108
next example a motive is printed twice.  It is printed once using
111
109
exact mathematical spacing, and once with corrections.  Can you
112
110
spot which fragment is which?
113
111
 
114
112
@cindex optical spacing
115
 
@lilypond[quote,noindent]
116
 
\score {
117
 
  \notes {
118
 
    \override Staff.NoteSpacing #'stem-spacing-correction = #0.6
119
 
    c'4 e''4 e'4 b'4 |
120
 
    \stemDown b'4 e''4 a'4 e''4 | \bar "||"
121
 
    \override Staff.NoteSpacing #'stem-spacing-correction = #0.0
122
 
    \override Staff.StaffSpacing #'stem-spacing-correction = #0.0
123
 
    \stemBoth c'4 e''4 e'4 b'4 |
124
 
    \stemDown b'4 e''4 a'4 e''4 |
125
 
  }
126
 
  \paper { raggedright = ##t }
 
113
@c file spacing-optical.
 
114
@c need to include it here,  because we want two images.
 
115
@lilypond
 
116
\paper {
 
117
  ragged-right = ##t
 
118
  indent = #0.0
 
119
}
 
120
 
 
121
music = {
 
122
   c'4 e''4 e'4 b'4 |
 
123
   \stemDown
 
124
   b'8[ e'' a' e'']
 
125
   \stemNeutral
 
126
   e'8[ e'8 e'8 e'8]  
 
127
}
 
128
 
 
129
\score
 
130
{
 
131
  \music
 
132
  \layout {
 
133
    \context {
 
134
      \Staff
 
135
      \override NoteSpacing #'stem-spacing-correction = #0.6
 
136
    }
 
137
  }
 
138
}
 
139
@end lilypond
 
140
 
 
141
@lilypond
 
142
\paper {
 
143
  ragged-right = ##t
 
144
  indent = #0.0
 
145
}
 
146
 
 
147
music = {
 
148
   c'4 e''4 e'4 b'4 |
 
149
   \stemDown
 
150
   b'8[ e'' a' e'']
 
151
   \stemNeutral
 
152
   e'8[ e'8 e'8 e'8]  
 
153
}
 
154
\score
 
155
{
 
156
  \music
 
157
  \layout {
 
158
    \context {
 
159
      \Staff
 
160
      \override NoteSpacing #'stem-spacing-correction = #0.0
 
161
      \override NoteSpacing #'same-direction-correction = #0.0
 
162
      \override StaffSpacing #'stem-spacing-correction = #0.0
 
163
    }
 
164
  }
127
165
}
128
166
@end lilypond
129
167
 
134
172
constant rhythm.  The spacing should reflect that.  Unfortunately, the
135
173
eye deceives us a little; not only does it notice the distance between
136
174
note heads, it also takes into account the distance between
137
 
consecutive stems.  As a result, the notes of an up-stem/down-stem
138
 
combination should be put farther apart, and the notes of a down-up
 
175
consecutive stems.  As a result, the notes of an up-stem/@/down-stem
 
176
combination should be put farther apart, and the notes of a 
 
177
down-stem/@/up-stem
139
178
combination should be put closer together, all depending on the
140
179
combined vertical positions of the notes.  The first two measures are
141
180
printed with this correction, the last two measures without.  The notes
142
 
in the last two measures form down-stem/up-stem clumps of notes.
 
181
in the last two measures form down-stem/@/up-stem clumps of notes.
143
182
 
144
183
@cindex typography
145
184
 
146
185
Musicians are usually more absorbed with performing than with studying
147
 
the looks of piece of music; nitpicking about typographical details
 
186
the looks of a piece of music, so nitpicking about typographical details
148
187
may seem academical.  But it is not.  In larger pieces with monotonous
149
188
rhythms, spacing corrections lead to subtle variations in the layout
150
189
of every line, giving each one a distinct visual signature.  Without
151
 
this signature all lines would look the same, they become like a
152
 
labyrinth.  If the musician looks away once or has a lapse in his
153
 
concentration, he will be lost on the page.
154
 
@c he/she
 
190
this signature all lines would look the same, and they become like a
 
191
labyrinth.  If a musician looks away once or has a lapse in
 
192
concentration, the lines might lose their place on the page.
155
193
 
156
194
Similarly, the strong visual look of bold symbols on heavy staff lines
157
 
stands out better when music is far away from reader, for example, if
158
 
it is on a music stand.  A careful distribution of white space allows
 
195
stands out better when the music is far away from the reader, for example,
 
196
if it is on a music stand.  A careful distribution of white space allows
159
197
music to be set very tightly without cluttering symbols together.  The
160
198
result minimizes the number of page turns, which is a great advantage.
161
199
 
162
200
This is a common characteristic of typography.  Layout should be
163
201
pretty, not only for its own sake, but especially because it helps the
164
 
reader in his task.  For performance material like sheet music, this is
165
 
doubly important: musicians have a limited amount of attention.  The
 
202
reader in her task.  For performance material like sheet music, this is
 
203
of double importance: musicians have a limited amount of attention.  The
166
204
less attention they need for reading, the more they can focus on
167
 
playing itself.  In other words, better typography translates to better
 
205
playing the music.  In other words, better typography translates to better
168
206
performances.
169
207
 
170
 
Hopefully, these examples also demonstrate that music typography is an
171
 
art that is subtle and complex, and to produce it requires
172
 
considerable expertise, which musicians usually do not have.  LilyPond
173
 
is our effort to bring the graphical excellence of hand-engraved music
174
 
to the computer age, and make it available to normal musicians.  We
175
 
have tuned our algorithms, font-designs, and program settings to
176
 
produce prints that match the quality of the old editions we love to
177
 
see and love to play from.
 
208
These examples demonstrate that music typography is an art that is
 
209
subtle and complex, and that producing it requires considerable
 
210
expertise, which musicians usually do not have.  LilyPond is our
 
211
effort to bring the graphical excellence of hand-engraved music to the
 
212
computer age, and make it available to normal musicians.  We have
 
213
tuned our algorithms, font-designs, and program settings to produce
 
214
prints that match the quality of the old editions we love to see and
 
215
love to play from.
178
216
 
179
217
 
180
218
 
187
225
write a program to take over their jobs?
188
226
 
189
227
The answer is: we cannot.  Typography relies on human judgment of
190
 
appearance, so people cannot be replaced ultimately.  However, much of
 
228
appearance, so people cannot be replaced completely.  However, much of
191
229
the dull work can be automated.  If LilyPond solves most of the common
192
230
situations correctly, this will be a huge improvement over existing
193
231
software.  The remaining cases can be tuned by hand.  Over the course
194
 
of years, the software can be refined to do more and more
 
232
of years, the software can be refined to do more and more things
195
233
automatically, so manual overrides are less and less necessary.
196
234
 
197
 
When we started we wrote the LilyPond program entirely in the C++
198
 
programming language, the program's functionality was set in stone by
 
235
When we started, we wrote the LilyPond program entirely in the C++
 
236
programming language; the program's functionality was set in stone by
199
237
the developers.  That proved to be unsatisfactory for a number of
200
238
reasons:
201
239
 
202
240
@itemize @bullet
203
241
@item When LilyPond makes mistakes,
204
 
 users need to override formatting decisions.  Therefore, the user
205
 
must access to the formatting engine.  Hence, rules and settings cannot
206
 
be fixed by us at compile time, but they must be accessible for users
207
 
at run-time.
 
242
users need to override formatting decisions.  Therefore, the user must
 
243
have access to the formatting engine.  Hence, rules and settings cannot
 
244
be fixed by us at compile-time but must be accessible for users at
 
245
run-time.
208
246
 
209
247
@item Engraving is a matter of visual judgment, and therefore a matter of
210
248
taste.  As knowledgeable as we are, users can disagree with our
211
249
personal decisions.  Therefore, the definitions of typographical style
212
250
must also be accessible to the user.
213
251
 
214
 
@item  Finally, we continually refine the formatting algorithms, so we
 
252
@item Finally, we continually refine the formatting algorithms, so we
215
253
need a flexible approach to rules.  The C++ language forces a certain
216
254
method of grouping rules that do not match well with how music
217
255
notation works.
218
 
 
219
256
@end itemize
220
257
 
221
 
These problems have been addressed by integrating the GUILE
222
 
interpreter for the Scheme programming language and rewriting parts of
223
 
LilyPond in Scheme.  The new, flexible formatting is built around the
 
258
These problems have been addressed by integrating an interpreter for
 
259
the Scheme programming language and rewriting parts of LilyPond in
 
260
Scheme.  The current formatting architecture is built around the
224
261
notion of graphical objects, described by Scheme variables and
225
262
functions.  This architecture encompasses formatting rules,
226
263
typographical style and individual formatting decisions.  The user has
229
266
Scheme variables control layout decisions.  For example, many
230
267
graphical objects have a direction variable that encodes the choice
231
268
between up and down (or left and right).  Here you see two chords,
232
 
with accents and arpeggio.  In the first chord, the graphical objects
 
269
with accents and arpeggios.  In the first chord, the graphical objects
233
270
have all directions down (or left).  The second chord has all
234
271
directions up (right).
235
272
 
236
 
@lilypond[quote,raggedright,relative=1]
 
273
@lilypond[quote,ragged-right]
237
274
\new Score \with {
238
 
  \override SpacingSpanner #'spacing-increment = #3
239
 
  \override TimeSignature #'transparent = ##t
240
 
  } {
241
 
  \stemDown <e g b>4_>-\arpeggio
242
 
  \override Arpeggio #'direction = #RIGHT
243
 
  \stemUp <e g b>4^>-\arpeggio
 
275
   \override SpacingSpanner #'spacing-increment = #3
 
276
   \override TimeSignature #'transparent = ##t
 
277
} \relative {
 
278
   \stemDown <e g b>4_>-\arpeggio
 
279
   \override Arpeggio #'direction = #RIGHT
 
280
   \stemUp <e g b>4^>-\arpeggio
244
281
}
245
282
@end lilypond
246
283
 
 
284
@noindent
247
285
The process of formatting a score consists of reading and writing the
248
 
variables of graphical objects.
249
 
 
250
 
Some variables have a preset value.  For example, the thickness of many
251
 
lines---a characteristic of typographical style---are preset
252
 
variables.  Changing them gives a different typographical impression
253
 
 
254
 
@lilypond[quote,raggedright]
255
 
fragment = \notes {
256
 
  \clef bass f8 as8
257
 
  c'4-~ c'16 as g f e16 g bes c' des'4
 
286
variables of graphical objects.  Some variables have a preset value.  For
 
287
example, the thickness of many lines -- a characteristic of typographical
 
288
style -- is a variable with a preset value.  You are free to alter this
 
289
value, giving your score a different typographical impression.
 
290
 
 
291
@lilypond[quote,ragged-right]
 
292
fragment = {
 
293
   \clef bass f8 as8
 
294
   c'4-~ c'16 as g f e16 g bes c' des'4
258
295
}
259
 
\score {
260
 
  <<
261
 
    \new Staff \fragment
262
 
    \new Staff \with {
 
296
<<
 
297
   \new Staff \fragment
 
298
   \new Staff \with {
263
299
      \override Beam #'thickness = #0.3
264
300
      \override Stem #'thickness = #0.5
265
301
      \override Bar #'thickness = #3.6
266
302
      \override Tie #'thickness = #2.2
267
303
      \override StaffSymbol #'thickness = #3.0
268
304
      \override Tie #'extra-offset = #'(0 .  0.3)
269
 
   } \fragment
270
 
   >>
271
 
}
 
305
      }
 
306
      \fragment
 
307
>>
272
308
@end lilypond
273
309
 
274
310
Formatting rules are also preset variables: each object has variables
275
 
containing procedures.  These procedure perform the actual formatting,
276
 
and by substituting different ones, we can change behavior.  In the
277
 
following example, the rule that note head objects use to produce
278
 
their symbol is changed during the music fragment
 
311
containing procedures.  These procedures perform the actual
 
312
formatting, and by substituting different ones, we can change the
 
313
appearance of objects.  In the following example, the rule which note
 
314
head objects are used to produce their symbol is changed during the music
 
315
fragment.
279
316
 
280
 
@lilypond[quote,raggedright]
 
317
@lilypond[quote,ragged-right]
281
318
#(define (mc-squared grob orig current)
282
319
  (let ((interfaces (ly:grob-property grob 'interfaces))
283
 
        (pos (ly:grob-property grob 'staff-position)))
 
320
        (pos (ly:grob-property grob 'staff-position)))
284
321
    (if (and (memq 'note-head-interface interfaces)
285
 
             (memq pos '(-2 -3 -5)))
286
 
        (begin
287
 
          (ly:grob-set-property! grob 'print-function brew-new-markup-stencil)
288
 
          (ly:grob-set-property! grob 'font-family 'roman)
289
 
          (ly:grob-set-property!
290
 
           grob 'text
291
 
           (make-raise-markup
292
 
            -0.5
293
 
            (case pos
294
 
              ((-5) (make-simple-markup "m"))
295
 
              ((-3) (make-simple-markup "c "))
296
 
              ((-2) (make-smaller-markup (make-bold-markup "2")))
297
 
              (else (make-simple-markup "bla")))))))))
 
322
             (memq pos '(-2 -3 -5)))
 
323
        (begin
 
324
          (ly:grob-set-property! grob 'stencil ly:text-interface::print)
 
325
          (ly:grob-set-property! grob 'font-family 'roman)
 
326
          (ly:grob-set-property!
 
327
           grob 'text
 
328
           (make-raise-markup
 
329
            -0.5
 
330
            (case pos
 
331
              ((-5) (make-simple-markup "m"))
 
332
              ((-3) (make-simple-markup "c "))
 
333
              ((-2) (make-smaller-markup (make-bold-markup "2")))
 
334
              (else (make-simple-markup "bla")))))))))
298
335
 
299
 
\score {
300
 
  \notes \context Voice \relative  c' {
301
 
    \stemUp
302
 
    \set autoBeaming = ##f
303
 
    \time 2/4
304
 
    <d f g>4
305
 
    \once \override NoteHead #'print-function = #Note_head::brew_ez_stencil
306
 
    <d f g>
307
 
    \once \override NoteHead #'style = #'cross
308
 
    <d f g>
309
 
    \applyoutput #mc-squared
310
 
    <d f g>
311
 
    <<
 
336
\new Voice \relative c' {
 
337
   \stemUp
 
338
   \set autoBeaming = ##f
 
339
   \time 2/4
 
340
   <d f g>4
 
341
   \once \override NoteHead #'stencil = #ly:note-head::brew-ez-stencil
 
342
   <d f g>
 
343
   \once \override NoteHead #'style = #'cross
 
344
   <d f g>
 
345
   \applyOutput #mc-squared
 
346
   <d f g>
 
347
   <<
312
348
      { d8[ es-( fis^^ g] fis2-) }
313
 
      \repeat unfold 5 { \applyoutput #mc-squared s8 }
314
 
    >>
315
 
  }
 
349
      \repeat unfold 5 { \applyOutput #mc-squared s8 }
 
350
   >>
316
351
}
317
352
@end lilypond
318
353
 
324
359
@cindex engraving
325
360
@cindex typography
326
361
 
327
 
The formatting process in LilyPond decides where to place
 
362
The formatting process decides where to place
328
363
symbols.  However, this can only be done once it is decided @emph{what}
329
364
symbols should be printed, in other words what notation to use.
330
365
 
331
366
Common music notation is a system of recording music that has evolved
332
 
over the past 1000 years.  The form that is now in common use, dates
333
 
from the early renaissance.  Although, the basic form (i.e.  note heads on a
334
 
5-line staff) has not changed, the details still change to express the
 
367
over the past 1000 years.  The form that is now in common use dates
 
368
from the early renaissance.  Although the basic form (i.e., note heads on a
 
369
5-line staff) has not changed, the details still evolve to express the
335
370
innovations of contemporary notation.  Hence, it encompasses some 500
336
371
years of music.  Its applications range from monophonic melodies to
337
 
monstrous counterpoint for large orchestras.
 
372
monstrous counterpoints for large orchestras.
338
373
 
339
374
How can we get a grip on such a many-headed beast, and force it into
340
 
the confines of a computer program?  We have broken up the problem of
341
 
notation (as opposed to engraving, i.e.  typography) into digestible
342
 
and programmable chunks: every type of symbol is handled by a separate
343
 
module, a so-called plug-in.  Each plug-in is completely modular and
344
 
independent, so each can be developed and improved separately.  People
345
 
that translate musical ideas to graphic symbols are called copyists or
346
 
engravers, so by analogy, each plug-in is called @code{engraver}.
 
375
the confines of a computer program?  Our solution is to break up the
 
376
problem of notation (as opposed to engraving, i.e., typography) into
 
377
digestible and programmable chunks: every type of symbol is handled by
 
378
a separate module, a so-called plug-in.  Each plug-in is completely
 
379
modular and independent, so each can be developed and improved
 
380
separately.  Such plug-ins are called @code{engraver}s, by analogy with
 
381
craftsmen who translate musical ideas to graphic symbols.
347
382
 
348
383
In the following example, we see how we start out with a plug-in for
349
384
note heads, the @code{Note_heads_engraver}.
350
385
 
351
 
@lilypond[quote,raggedright]
352
 
\include "engraver-example.lyinc"
 
386
@lilypond[quote,ragged-right]
 
387
\include "engraver-example.ily"
353
388
 
354
389
\score {
355
 
  \topVoice
356
 
  \paper {
357
 
    \context {
358
 
      \VoiceContext
 
390
   \topVoice
 
391
   \layout {
 
392
   \context {
 
393
      \Voice
359
394
      \remove "Stem_engraver"
360
395
      \remove "Phrasing_slur_engraver"
361
396
      \remove "Slur_engraver"
362
397
      \remove "Script_engraver"
363
398
      \remove "Beam_engraver"
364
399
      \remove "Auto_beam_engraver"
365
 
    }
366
 
    \context {
367
 
      \StaffContext
 
400
   }
 
401
   \context {
 
402
      \Staff
368
403
      \remove "Accidental_engraver"
369
404
      \remove "Key_engraver"
370
405
      \remove "Clef_engraver"
372
407
      \remove "Time_signature_engraver"
373
408
      \remove "Staff_symbol_engraver"
374
409
      \consists "Pitch_squash_engraver"
375
 
    }
376
 
  }
 
410
   }
 
411
}
377
412
}
378
413
@end lilypond
379
414
 
380
415
@noindent
381
416
Then a @code{Staff_symbol_engraver} adds the staff
382
417
 
383
 
@lilypond[quote,raggedright]
384
 
\include "engraver-example.lyinc"
 
418
@lilypond[quote,ragged-right]
 
419
\include "engraver-example.ily"
385
420
 
386
421
\score {
387
422
  \topVoice
388
 
  \paper {
 
423
  \layout {
389
424
    \context {
390
 
      \VoiceContext
 
425
      \Voice
391
426
      \remove "Stem_engraver"
392
427
      \remove "Phrasing_slur_engraver"
393
428
      \remove "Slur_engraver"
396
431
      \remove "Auto_beam_engraver"
397
432
    }
398
433
    \context {
399
 
      \StaffContext
 
434
      \Staff
400
435
      \remove "Accidental_engraver"
401
436
      \remove "Key_engraver"
402
437
      \remove "Clef_engraver"
409
444
@end lilypond
410
445
 
411
446
@noindent
412
 
The @code{Clef_engraver} defines a reference point for the staff
 
447
the @code{Clef_engraver} defines a reference point for the staff
413
448
 
414
 
@lilypond[quote,raggedright]
415
 
\include "engraver-example.lyinc"
 
449
@lilypond[quote,ragged-right]
 
450
\include "engraver-example.ily"
416
451
 
417
452
\score {
418
453
  \topVoice
419
 
  \paper {
 
454
  \layout {
420
455
    \context {
421
 
      \VoiceContext
 
456
      \Voice
422
457
      \remove "Stem_engraver"
423
458
      \remove "Phrasing_slur_engraver"
424
459
      \remove "Slur_engraver"
427
462
      \remove "Auto_beam_engraver"
428
463
    }
429
464
    \context {
430
 
      \StaffContext
 
465
      \Staff
431
466
      \remove "Accidental_engraver"
432
467
      \remove "Key_engraver"
433
468
      \remove "Bar_engraver"
438
473
@end lilypond
439
474
 
440
475
@noindent
441
 
And the @code{Stem_engraver} adds stems
 
476
and the @code{Stem_engraver} adds stems.
442
477
 
443
 
@lilypond[quote,raggedright]
444
 
\include "engraver-example.lyinc"
 
478
@lilypond[quote,ragged-right]
 
479
\include "engraver-example.ily"
445
480
 
446
481
\score {
447
482
  \topVoice
448
 
  \paper {
 
483
  \layout {
449
484
    \context {
450
 
      \VoiceContext
 
485
      \Voice
451
486
      \remove "Phrasing_slur_engraver"
452
487
      \remove "Slur_engraver"
453
488
      \remove "Script_engraver"
455
490
      \remove "Auto_beam_engraver"
456
491
    }
457
492
    \context {
458
 
      \StaffContext
 
493
      \Staff
459
494
      \remove "Accidental_engraver"
460
495
      \remove "Key_engraver"
461
496
      \remove "Bar_engraver"
467
502
 
468
503
The @code{Stem_engraver} is notified of any note head coming along.
469
504
Every time one (or more, for a chord) note head is seen, a stem
470
 
object is created and connected to the note head.
471
 
By adding engravers for beams, slurs, accents, accidentals, bar lines,
 
505
object is created and connected to the note head.  By adding
 
506
engravers for beams, slurs, accents, accidentals, bar lines,
472
507
time signature, and key signature, we get a complete piece of
473
508
notation.
474
509
 
475
 
@lilypond[quote,raggedright]
476
 
\include "engraver-example.lyinc"
 
510
@lilypond[quote,ragged-right]
 
511
\include "engraver-example.ily"
477
512
\score { \topVoice }
478
513
@end lilypond
479
514
 
480
515
This system works well for monophonic music, but what about
481
516
polyphony?  In polyphonic notation, many voices can share a staff.
482
517
 
483
 
@lilypond[quote,raggedright]
484
 
\include "engraver-example.lyinc"
485
 
\score { \context Staff << \topVoice \\ \botVoice >> }
 
518
@lilypond[quote,ragged-right]
 
519
\include "engraver-example.ily"
 
520
\new Staff << \topVoice \\ \botVoice >> 
486
521
@end lilypond
487
522
 
488
 
In this situation, the accidentals and staff are shared, but the
489
 
stems, slurs, beams, etc.  are private to each voice.  Hence, engravers
490
 
should be grouped.  The engravers for note heads, stems, slurs, etc.  go
491
 
into a group called ``Voice context,'' while the engravers for key,
492
 
accidental, bar, etc.  go into a group called ``Staff context.'' In the
493
 
case of polyphony, a single Staff context contains more than one Voice
494
 
context.  In polyphonic notation, many voices can share a staff.
495
 
Similarly, more Staff contexts can be put into a single Score context
496
 
 
497
 
@lilypond[quote,raggedright]
498
 
\include "engraver-example.lyinc"
 
523
In this situation, the accidentals and staff are shared, but the stems,
 
524
slurs, beams, etc., are private to each voice.  Hence, engravers should
 
525
be grouped.  The engravers for note heads, stems, slurs, etc., go into a
 
526
group called `Voice context,' while the engravers for key, accidental,
 
527
bar, etc., go into a group called `Staff context.'  In the case of
 
528
polyphony, a single Staff context contains more than one Voice context.
 
529
Similarly, multiple Staff contexts can be put into a single Score
 
530
context.  The Score context is the top level notation context.
 
531
 
 
532
@seealso
 
533
 
 
534
Program reference: @internalsref{Contexts}.
 
535
 
 
536
@lilypond[quote,ragged-right]
 
537
\include "engraver-example.ily"
499
538
\score {
500
 
  <<
501
 
    \new Staff << \topVoice \\ \botVoice >>
502
 
    \new Staff << \pah \\ \hoom >>
503
 
  >>
 
539
   <<
 
540
      \new Staff << \topVoice \\ \botVoice >>
 
541
      \new Staff << \pah \\ \hoom >>
 
542
   >>
504
543
}
505
544
@end lilypond
506
545
 
519
558
 
520
559
The syntax is also the user-interface for LilyPond, hence it is easy
521
560
to type
 
561
 
522
562
@example
523
563
c'4 d'8
524
564
@end example
525
 
a quarter note C1 (middle C) and eighth note D1 (D above middle C)
 
565
 
 
566
@noindent
 
567
a quarter note C1 (middle C) and an eighth note D1 (D above middle C)
 
568
 
526
569
@lilypond[quote,fragment]
527
570
c'4 d'8
528
571
@end lilypond
537
580
c4
538
581
@end lilypond
539
582
 
540
 
Combine this simultaneously with two other notes by enclosing in << and >>
 
583
@noindent
 
584
Chords can be constructed with @code{<<} and @code{>>} enclosing the notes
541
585
 
 
586
@c < > is not a music expression, 
 
587
@c so we use <<>> iso. <> to drive home the point of
 
588
@c expressions.  Don't change this back --hwn.
542
589
@example
543
590
<<c4 d4 e4>>
544
591
@end example
 
592
 
545
593
@lilypond[quote,fragment,relative=1]
546
 
\new Voice { <<c4 d4 e4>> }
 
594
\new Voice { <<c4 d4 e>> }
547
595
@end lilypond
548
596
 
 
597
@noindent
549
598
This expression is put in sequence by enclosing it in curly braces
550
 
@code{@{ @dots{} @}}
 
599
@code{@{@tie{}@dots{}@tie{}@}}
551
600
 
552
601
@example
553
 
@{ <<c4 d4 e4>> f4 @}
 
602
@{ f4 <<c4 d4 e4>> @}
554
603
@end example
555
604
 
556
 
@lilypond[quote,relative=1]
557
 
\new Voice { <<c4 d4 e4>> f4 }
 
605
@lilypond[quote,relative=1,fragment]
 
606
{ f4 <<c d e4>> }
558
607
@end lilypond
559
 
        
560
 
The above is another expression, and therefore, it many combined again
561
 
with a simultaneous expression; in this case, a half note
 
608
 
 
609
@noindent
 
610
The above is also an expression, and so it may be combined
 
611
again with another simultaneous expression (a half note) using <<,
 
612
@code{\\}, and >>
562
613
 
563
614
@example
564
 
<< @{ <<c4 d4 e4>> f4 @} g2 >>
 
615
<< g2 \\ @{ f4 <<c4 d4 e4>> @} >>
565
616
@end example
 
617
 
566
618
@lilypond[quote,fragment,relative=2]
567
 
\new Voice { << g2 \\ { <c d e>4 f4 } >> }
 
619
\new Voice { << g2 \\ { f4 <<c d e>> } >> }
568
620
@end lilypond
569
 
        
570
621
 
571
622
Such recursive structures can be specified neatly and formally in a
572
623
context-free grammar.  The parsing code is also generated from this
577
628
most.  They are partly a matter of taste, and also subject of much
578
629
discussion.  Although discussions on taste do have their merit, they
579
630
are not very productive.  In the larger picture of LilyPond, the
580
 
importance of input syntax is small: inventing neat syntax is easy,
 
631
importance of input syntax is small: inventing neat syntax is easy, while
581
632
writing decent formatting code is much harder.  This is also
582
633
illustrated by the line-counts for the respective components: parsing
583
 
and representation take up less than 10% of the code.
 
634
and representation take up less than 10% of the source code.
584
635
 
585
636
 
586
637
@node Example applications
589
640
We have written LilyPond as an experiment of how to condense the art
590
641
of music engraving into a computer program.  Thanks to all that hard
591
642
work, the program can now be used to perform useful tasks.  The
592
 
simplest application is printing notes
 
643
simplest application is printing notes.
593
644
 
594
 
@lilypond[quote,relative=1]
 
645
@lilypond[quote,relative=1,fragment]
595
646
\time 2/4 c4 c g'4 g a4 a g2
596
647
@end lilypond
597
648
 
598
649
@noindent
599
 
By adding chord names and lyrics we obtain a lead sheet
 
650
By adding chord names and lyrics we obtain a lead sheet.
600
651
 
601
 
@lilypond[quote,raggedright]
602
 
\score {
603
 
  <<
604
 
    \context ChordNames \chords  { c2 c f2 c }
605
 
    \new Staff \notes \relative c' { \time 2/4 c4 c g'4 g a4 a g2 }
606
 
    \context Lyrics \lyrics  { twin4 kle twin kle lit tle star2 }
607
 
  >>
608
 
}
 
652
@lilypond[quote,ragged-right]
 
653
<<
 
654
   \chords { c2 c f2 c }
 
655
   \new Staff \relative c' { \time 2/4 c4 c g'4 g a4 a g2 }
 
656
   \new Lyrics \lyricmode { twin4 kle twin kle lit tle star2 }
 
657
>>
609
658
@end lilypond
610
659
 
611
 
 
612
660
Polyphonic notation and piano music can also be printed.  The following
613
 
example combines some more exotic constructs
 
661
example combines some more exotic constructs.
614
662
 
615
 
@lilypondfile[quote,raggedright]{screech-boink.ly}
 
663
@lilypondfile[quote,ragged-right]{screech-boink.ly}
616
664
 
617
665
The fragments shown above have all been written by hand, but that is
618
666
not a requirement.  Since the formatting engine is mostly automatic, it
623
671
 
624
672
This manual also shows an application: the input format is text, and
625
673
can therefore be easily embedded in other text-based formats such as
626
 
La@TeX{}, HTML or in the case of this manual, Texinfo.  By means of a
 
674
La@TeX{}, HTML, or in the case of this manual, Texinfo.  By means of a
627
675
special program, the input fragments can be replaced by music images
628
 
in the resulting PostScript or HTML output files.  This makes it easy
 
676
in the resulting PDF or HTML output files.  This makes it easy
629
677
to mix music and text in documents.
630
678
 
631
679
 
641
689
The
642
690
@end ifhtml
643
691
@emph{@ref{Tutorial}}
644
 
gives a gentle introduction to typesetting music.
645
 
First time users should start here.
646
 
 
647
 
@item
648
 
@ifhtml
649
 
The
650
 
@end ifhtml
651
 
@emph{@ref{Notation manual}}
652
 
discusses topics grouped by notation construct.  Once you master the
653
 
basics, this is the place to look up details.
654
 
 
655
 
@item
656
 
@ifhtml
657
 
The
658
 
@end ifhtml
 
692
gives a gentle introduction to typesetting music.  First time
 
693
users should start here.
 
694
 
 
695
@item
 
696
@emph{@ref{Working on LilyPond projects}}
 
697
demonstrates practical uses of LilyPond.
 
698
 
 
699
@item
 
700
@emph{@ref{Running LilyPond}}
 
701
shows how to run LilyPond and its helper
 
702
programs.  In addition, this section explains how to upgrade input
 
703
files from previous versions of LilyPond.
 
704
 
 
705
@item
 
706
@emph{@ref{Basic notation}}
 
707
discusses topics grouped by notation construct.  This section gives
 
708
details about basic notation that will be useful in almost any
 
709
notation project.
 
710
 
 
711
@item
 
712
@emph{@ref{Instrument-specific notation}}
 
713
discusses topics grouped by notation construct.  This section gives
 
714
details about special notation that will only be useful for particular
 
715
instrument (or vocal) groups.
 
716
 
 
717
@item
 
718
@emph{@ref{Advanced notation}}
 
719
discusses topics grouped by notation construct.  This section gives
 
720
details about complicated or unusual notation.
 
721
 
 
722
@item
659
723
@emph{@ref{Changing defaults}}
660
724
explains how to fine tune layout.
661
 
@item
662
 
@ifhtml
663
 
The chapter
664
 
@end ifhtml
665
 
@emph{@ref{Invoking LilyPond}} shows how to run LilyPond and its helper
666
 
programs.
667
 
 
668
 
@item
669
 
@ifhtml
670
 
The
671
 
@end ifhtml
672
 
@emph{@ref{lilypond-book manual}}
673
 
explains  the details behind creating documents with in-line music
674
 
examples (like this manual).
675
 
 
676
 
@item
677
 
@ifhtml
678
 
The chapter
679
 
@end ifhtml
 
725
 
 
726
@item
 
727
@emph{@ref{Global issues}}
 
728
discusses issues which affect the global output, such as selecting
 
729
paper size or which MIDI instruments to use.
 
730
 
 
731
@item
 
732
@emph{@ref{LilyPond-book}} explains the details behind creating
 
733
documents with in-line music examples, like this manual.
 
734
 
 
735
@item
680
736
@emph{@ref{Converting from other formats}}
681
737
explains how to run the conversion programs.  These programs
682
738
are supplied with the LilyPond package, and convert a variety of music
683
 
formats to the @code{.ly}  format.  In addition, this section explains
684
 
how to upgrade input files from previous versions of LilyPond.
 
739
formats to the @code{.ly} format.
685
740
 
686
741
@item
687
742
@ifhtml
688
743
The
689
744
@end ifhtml
690
745
@emph{@ref{Literature list}}
691
 
 contains a set of useful reference books, for those who wish to know
692
 
 more  on notation and engraving.
 
746
contains a set of useful reference books for those who wish to know
 
747
more on notation and engraving.
 
748
 
 
749
@item
 
750
@emph{@ref{Example templates}}
 
751
provides templates of LilyPond pieces.  Just cut and paste a
 
752
template into a file, add notes, and you're done!
693
753
 
694
754
@end itemize
695
755
 
 
756
 
696
757
Once you are an experienced user, you can use the manual as reference:
697
758
there is an extensive index@footnote{If you are looking for something,
698
759
and you cannot find it in the manual, that is considered a bug.  In
699
760
that case, please file a bug report.}, but the document is also
700
761
available in
701
 
@ifnothtml
 
762
@iftex
702
763
a big HTML page,
703
 
@end ifnothtml
 
764
@end iftex
704
765
@ifhtml
705
 
@uref{../lilypond.html, a big HTML page}
 
766
@uref{source/Documentation/user/lilypond.html, one big page},
706
767
@end ifhtml
707
768
which can be searched easily using the search facility of a web
708
769
browser.
713
774
@c add/integrate glossary, put in list above
714
775
If you are not familiar with music notation or music terminology
715
776
(especially if you are a non-native English speaker), it is advisable
716
 
to consult the glossary as well.  The glossary explains musical terms,
717
 
and includes translations to various languages.  It is a
718
 
@ifhtml
719
 
@uref{../music-glossary.html,separate document}.
720
 
@end ifhtml
721
 
@ifnothtml
722
 
separate document, available in HTML and PDF.
723
 
@end ifnothtml
 
777
to consult the glossary as well.
 
778
@iftex
 
779
The music glossary explains musical terms, and includes translations
 
780
to various languages.  It is a separate document, available in HTML
 
781
and PDF.
 
782
@end iftex
 
783
@ifnottex
 
784
The @ref{Top,Music glossary,,music-glossary}, explains musical terms and
 
785
includes translations to various languages.  It is also available in
 
786
PDF.
 
787
@end ifnottex
724
788
@cindex idiom
725
789
@cindex jargon
726
790
@cindex terminology
730
794
 
731
795
This manual is not complete without a number of other documents.  They
732
796
are not available in print, but should be included with the
733
 
documentation package for your platform:
 
797
documentation package for your platform
734
798
 
735
799
@itemize @bullet
736
800
@item
 
801
@iftex
737
802
Program reference
738
 
@ifhtml
739
 
(available @uref{../lilypond-internals/lilypond-internals.html,here})
740
 
@end ifhtml
 
803
@end iftex
 
804
@ifnottex
 
805
@ref{Top,Program reference,,lilypond-internals}.
 
806
@end ifnottex
741
807
 
742
808
The program reference is a set of heavily cross linked HTML pages,
743
 
which documents the nit-gritty details of each and every LilyPond
744
 
class, object and function.  It is produced directly from the
 
809
which document the nitty-gritty details of each and every LilyPond
 
810
class, object, and function.  It is produced directly from the
745
811
formatting definitions used.
746
812
 
747
813
Almost all formatting functionality that is used internally, is
748
814
available directly to the user.  For example, all variables that
749
 
control thicknesses, distances, etc, can be changed in input
 
815
control thickness values, distances, etc., can be changed in input
750
816
files.  There are a huge number of formatting options, and all of them
751
 
are described in the generated documentation.  Each section of the
 
817
are described in this document.  Each section of the
752
818
notation manual has a @b{See also} subsection, which refers to the
753
 
the generated documentation.  In the HTML document, these subsections
 
819
generated documentation.  In the HTML document, these subsections
754
820
have clickable links.
755
821
 
756
 
@item
757
 
  Templates
758
 
@ifhtml
759
 
(available @uref{../../../../input/template/out-www/collated-files.html,here})
760
 
@end ifhtml
761
 
 
762
 
After you have gone through the tutorial, you should be able to write
763
 
input files.  In practice, writing files from scratch turns out to be
764
 
intimidating.  To give you a head start, we have collected a number of
765
 
often-used formats in example files.  These files can be used as a
766
 
start; simply copy the template and add notes in the appropriate
767
 
places.
768
 
 
769
 
@item
770
 
  Various input examples
771
 
@ifhtml
772
 
(available @uref{../../../../input/test/out-www/collated-files.html,here})
773
 
@end ifhtml
774
822
@cindex snippets
 
823
@item
 
824
@ifnothtml
 
825
Various input examples.
 
826
@end ifnothtml
 
827
@ifhtml
 
828
@c Works, but link name is not so nice; so write-out macro
 
829
@c @inputfileref{input/test,Various input examples}.
 
830
@uref{source/input/test/collated-files.html,Various input examples}.
 
831
@end ifhtml
775
832
 
776
833
This collection of files shows various tips and tricks, and is
777
834
available as a big HTML document, with pictures and explanatory texts
778
835
included.
779
836
 
780
837
@item
781
 
  The regression tests
 
838
@ifnothtml
 
839
The regression tests.
 
840
@end ifnothtml
782
841
@ifhtml
783
 
(available @uref{../../../../input/regression/out-www/collated-files.html,here})
 
842
@c Works, but link name is not so nice; so write-out macro
 
843
@c @inputfileref{input/regression,The regression tests}.
 
844
@uref{source/input/regression/collated-files.html,The regression tests}.
784
845
@end ifhtml
785
846
 
786
847
This collection of files tests each notation and engraving feature of
787
848
LilyPond in one file.  The collection is primarily there to help us
788
849
debug problems, but it can be instructive to see how we exercise the
789
 
program.  The format is similar to the the tips and tricks document.
790
 
 
 
850
program.  The format is similar to the tips and tricks document.
791
851
@end itemize
792
852
 
793
853
 
799
859
vary from system to system.  On occasion, this manual refers to
800
860
initialization and example files.  Throughout this manual, we refer to
801
861
input files relative to the top-directory of the source archive.  For
802
 
example, @file{input/test/bla.ly} may refer to the file
803
 
@file{lilypond-1.7.19/input/test/bla.ly}.  On binary packages for the
804
 
Unix platform, the documentation and examples can typically be found
805
 
somewhere below @file{/usr/share/doc/lilypond/}.  Initialization files,
806
 
for example @file{scm/lily.scm}, or @file{ly/engraver-init.ly}, are
807
 
usually found in the directory @file{/usr/share/lilypond/}.
 
862
example, @file{input/@/test/@/bla@/.ly} may refer to the file
 
863
@file{lilypond@/-2.8.0/@/input/@/test/@/bla@/.ly}.  On binary packages
 
864
for the Unix platform, the documentation and examples can typically be
 
865
found somewhere below @file{/usr/@/share/@/doc/@/lilypond/}.
 
866
Initialization files, for example @file{scm/@/lily@/.scm}, or
 
867
@file{ly/@/engraver@/-init@/.ly}, are usually found in the directory
 
868
@file{/usr/@/share/@/lilypond/}.
808
869
 
809
870
@cindex adjusting output
810
871
@cindex variables
813
874
@cindex internal documentation
814
875
@cindex Scheme
815
876
@cindex extending lilypond
816
 
@cindex bug report
817
877
@cindex index
818
878
 
819
879
Finally, this and all other manuals, are available online both as PDF
820
880
files and HTML from the web site, which can be found at
821
 
@uref{http://www.lilypond.org/}.
 
881
@uref{http://@/www@/.lilypond@/.org/}.
822
882
 
823
 
@cindex website
824
 
@cindex URL