]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/introduction.itely
* lily/beam-engraver.cc (acknowledge_grob): set melismata for new
[lilypond.git] / Documentation / user / introduction.itely
1 @c -*-texinfo-*-
2
3 @node Introduction
4 @chapter Introduction
5
6 LilyPond is a program to print sheet music.  If you have used notation
7 programs before, then the way to use this program might be surprising
8 at first sight.  To print music with lilypond, you have to enter
9 musical codes in a file.  Then you run LilyPond on the file, and the
10 music is produced without any further intervention.  For example,
11 something like this:
12
13 @lilypond[fragment,verbatim, relative 1, intertext="produces this
14
15 "]
16 \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
17 @end lilypond
18
19 @cindex encoding music
20
21 Encoding music using letters and digits may appear strange,
22 intimidating or even clumsy at first. Nevertheless, when you take the
23 effort to learn the codes and the program you will find that it is
24 easier than it seems.  Entering music can be done quickly, and you
25 never have to remember how you made the program do something
26 complicated: it is all in the input code, and you only have to read
27 the file to see how it works. Moreover, when you use LilyPond, you are
28 rewarded with very nicely looking output.
29
30 In this chapter, we will explain the reasoning behind this unusual
31 design, and how this approach affects you as a user.
32
33 @menu
34 * Batch processing::            
35 * Music engraving::             
36 * Music representation::        
37 * Example applications::        
38 * About this manual::           
39 @end menu
40
41 @node Batch processing
42 @section Batch processing
43
44 @cindex GUI
45 @cindex Batch
46 @cindex UNIX
47
48 When we started developing LilyPond, we were still studying at the
49 university.  We were interested in music notation, not as publishers
50 or musicians, but as students and scientists. We wanted to figure to
51 what extent formatting sheet music could be automated.  Back then GUIs
52 were not as ubiquitous as they are today, and we were immersed in the
53 UNIX operating system, where it is very common to use compilers to
54 achieve computing tasks, so our computerized music engraving
55 experiment took on the form of a compiler.
56
57
58 @ignore
59 @cindex free software
60 @cindex sharing software
61
62 You can freely use, modify and redistribute LilyPond. This choice was
63 also motivated by our academic background. In the scientific community
64 it has always been a tradition to share knowledge, also if that
65 knowledge was packaged as software. One of the most visible groups
66 that stimulated this philosophy, was the Free Software Foundation,
67 whose popular GNU project aimed to replace closed and proprietary
68 computing solutions with free (as in ``Libre'') variants. We jumped on
69 that bandwagon, and released LilyPond as free software.  That is the
70 reason that you can get LilyPond at no cost and without any strings
71 attached.
72 @end ignore
73
74
75 @node Music engraving
76 @section Music engraving
77
78
79
80 @cindex engraving
81 @cindex typography
82
83 Making sheet music may seem trivial at first (``you print 5 lines, and
84 then put in the notes at different heights''), @emph{music engraving},
85 i.e. professional music typography, is in another ballpark.  The term
86 `music engraving' derives from the traditional process of music
87 printing.  Only a few decades ago, sheet music was made by cutting and
88 stamping the music into zinc or pewter plates, mirrored. The plate
89 would be inked, and the depressions caused by the cutting and stamping
90 would hold ink.  A positive image was formed by pressing paper to the
91 plate. Stamping and cutting was completely done by hand. Making
92 corrections was cumbersome, so engraving had to be done correctly in
93 one go. As you can imagine this was a highly specialized skill, much
94 more so than the traditional process of printing books.
95 @cindex craftsmanship
96 @cindex master
97 In the traditional German craftsmanship six years of full-time
98 training, more than any other craft, were required before a student
99 could call himself a master of the art. After that many more years of
100 practical experience were needed to become an established music
101 engraver.  Even today, with the use of high-speed computers and
102 advanced software, music requires lots of manual fine tuning before it
103 acceptable to be published.
104
105 When we wanted to write a computer program to do create music
106 typography, we encountered the first problem: there were no sets of
107 musical symbols available: either they were not available freely, or
108 they did not look well to our taste. Not let down, we decided to try
109 font design ourselves. We created a font of musical symbols, relying
110 on nice printouts of hand-engraved music.  The experience helped
111 develop a typographical taste, and it made us appreciate subtle design
112 details. Without that experience, we would not have realized how ugly
113 the fonts were that we admired at first.
114
115
116 @lilypond[noindent]
117 #(define magfact 3.0)
118 \score {  \notes { as'2 r4 }
119           \paper {
120                  raggedright = ##t
121               \translator {
122                   \ScoreContext
123                   AccidentalPlacement \override #'right-padding = #3.0
124                   StaffSymbol \override #'transparent =   ##t
125                   Clef \override #'transparent = ##t
126                   TimeSignature \override #'transparent = ##t
127                   Accidental \override #'font-magnification = #magfact
128                   Rest \override #'font-magnification = #magfact
129                   NoteHead \override #'font-magnification = #magfact
130                   Stem \override #'transparent = ##t
131                   } } }
132 @end lilypond
133
134 @cindex musical symbols
135 @cindex font
136 @cindex blackness
137 @cindex balance
138
139 The figure above shows a few notable glyphs. For example, the
140 half-notehead is not elliptic but slightly diamond shaped.  The
141 vertical stem of a flat symbol should be slightly brushed,
142 i.e. becoming wider at the top. Fine endings, such as the one on the
143 bottom of the quarter rest, should not end in sharp points, but rather
144 in rounded shapes.  Taken together, the blackness of the font must be
145 carefully tuned together with the thickness of lines, beams and slurs
146 to give a strong yet balanced overall impression.
147
148 Producing a strong and balanced look is the real challenge of music
149 engraving. It is a recurring theme with many variations.  In spacing,
150 the balance is in a distribution that reflects the character of the
151 music. The spacing should not lead to unnatural clusters of black and
152 big gaps with white space.  The distances between notes should reflect
153 the durations between notes, but adhering with mathematical precision
154 to the duration will lead to a poor result. Shown here is an example
155 of a motive, printed twice. It is printed using both exact,
156 mathematical spacing, and with some corrections. Can you spot which is
157 which?
158
159
160 @cindex optical spacing
161 @lilypond[noindent]
162     \score { \notes {
163       \property Staff.NoteSpacing \set #'stem-spacing-correction
164         = #0.6
165       c'4 e''4 e'4 b'4 |
166        \stemDown b'4 e''4 a'4 e''4| \stemBoth
167       \property Staff.NoteSpacing \override #'stem-spacing-correction
168       = #0.0
169       \property Staff.StaffSpacing \override #'stem-spacing-correction
170       = #0.0
171       c'4 e''4 e'4 b'4 |
172       \stemDown b'4 e''4 a'4 e''4|
173     }
174     \paper { raggedright = ##t } }
175 @end lilypond
176
177 @cindex regular rhythms
178 @cindex regular spacing
179
180 The fragment that was printed uses only quarter notes: notes that are
181 played in a constant rhythm. The spacing should reflect
182 that. Unfortunately, the eye deceives us a little: the eye not only
183 notices the distance between note heads, but also between consecutive
184 stems. The notes of a up-stem/down-stem combination should be put
185 farther apart, and the notes of a down-up combination should be put
186 closer together, all depending on the combined vertical positions of
187 the notes. The first two measures are printed with this correction,
188 the last two measures without. The notes in the last two measures form
189 downstem/upstems clumps of notes.
190
191 We hope that these examples show that music typography is a subtle
192 business, and that it requires skill and knowledge to produce good
193 engraving.  It was our challenge to see if we could put such knowledge
194 into a computer program.
195
196
197 @node Music representation
198 @section Music representation
199
200
201 One of the big questions when making programs, is what kind of input
202 the program should expect. Many music notation programs offer a
203 graphical interface that shows notation, and allow you to enter the
204 music by placing notes on a staff. From our point of view, this design
205 is a form of cheating. After all, the core message of a piece of music
206 notation simply is the music itself. If you start by offering notation
207 to the user, you have already skipped one conversion, even if it is
208 implicit. If we want to generate music notation from something else,
209 then the obvious candidate for the source is the music itself.
210
211 On paper this theory sounds very good. In practice, it opens a can of
212 worms. What really @emph{is} music? Many philosophical treatises must
213 have been written on the subject.  Instead of losing ourselves in
214 philosophical arguments over the essence of music, we have reversed
215 the question to yield a more practical approach. Our assumption is
216 that the printed score contains all of the music of piece. We build a
217 program that uses some input format to produce such a score. Over the
218 course of time, the program evolves. While this happens, we can remove
219 more and more elements of the input format: as the program improves,
220 it can fill in irrelevant details of the input by itself. At some
221 (hypothetical) point, the program is finished: there is no possibility
222 to remove any more elements from the syntax.  What we have left is by
223 definition exactly the musical meaning of the score.
224
225 There are also more practical concerns.  Our users have to key in the
226 music into the file directly, so the input format should have a
227 friendly syntax. As programmers and scientists, we want a
228 clean formal definition. After all, producing music notation is a
229 difficult problem, and in the scientific world, problems can only be
230 solved if they are well-specified. Moreover, formally defined formats
231 are easier to write programs for.
232
233 These ideas shaped our music representation: it is a compact format
234 that can easily be typed by hand. It complex musical constructs from
235 simple entities like notes and rests, in much the same way that one
236 builds complex formulas from simple expressions such as numbers and
237 mathematical operators.
238
239 @node Example applications
240 @section Example applications
241
242 As programmers and hedonists we enjoy beauty in code, and code that
243 produces beautiful typeset music, but nevertheless this program can
244 applied to do useful things. In this section, we show a few small
245 examples of what is possible.
246
247 The simplest application, is printing just notes.
248
249 @lilypond[relative=1]
250   \time 2/4 c4 c g'4 g a4 a g2  
251 @end lilypond
252
253 To these notes, chord names and lyrics  may be added
254
255 @lilypond[raggedright]
256 \score { <
257   \context ChordNames \chords  { c2 c f2 c }
258   \notes \relative c' { \time 2/4 c4 c g'4 g a4 a g2 }
259   \context Lyrics \lyrics  { twin kle twin kle lit tle star } > }
260 @end lilypond
261
262
263 [TODO: need piano and tab example]
264
265 The following example combines some more exotic uses of notation
266
267 @lilypondfile{screech-boink.ly}  
268
269
270
271 @node About this manual
272 @section About this manual
273
274 The manual is divided into the following chapters
275 @table @strong
276 @item Tutorial
277   Gives a gentle introduction into typesetting music.
278   Start here if you have never used lilypond before.
279 @item   Reference manual
280   Here, each aspect of typesetting music is discussed.
281 @item Internals
282   This chapter discusses how it works from the inside, and how you can
283   extend the program.
284 @item Invoking
285   This chapter explains how to runn LilyPond and its helper programs. 
286 @end table
287
288 Once you are experienced with, you can simply use the manual as
289 reference: there is an extensive index@footnote{If you are looking for
290 something, and you cannot find it by using the index, that is
291 considered a bug.  In that case, please file a bug report}, but the
292 document is also available in
293 @ifhtml
294 One Big Page,
295 @end ifhtml
296 @ifnothtml
297 @uref{../lilypond.html,One Big Page}
298 @end ifnothtml 
299 which is is available for text search using your browser's search
300 facility.
301 @cindex search in manual
302 @cindex using the manual
303
304
305 If you are familiar with music notation, and music terminology
306 (especially if you are a foreigner), then it is advisable to consult
307 the glossary as well. This documents explains many terms, and includes
308 translations to various languages. It is a 
309 @ifhtml
310 @uref{../glossary.html,separate document}
311 @end ifhtml
312 @ifnothtml
313 separate document, and can be printed as well.
314 @end ifnothtml
315 @cindex idiom
316 @cindex jargon
317 @cindex terminology
318 @cindex foreign languages
319 @cindex language
320
321
322 This manual is not complete without a number of other documents. They
323 are not available in print, but should be included with the
324 documentation package for your platform
325
326 @itemize @bullet
327 @item
328 Generated internal documentation.
329 @ifhtml
330 available @uref{../lilypond-internals/lilypond-internals.html,here}
331 @end ifhtml
332
333 Almost all formatting functionality that is used internally, is
334 available directly to the user. For example, all variables that
335 control thicknesses, distances, etc, can be changed from input
336 files. There are a huge number of formatting options, and it would be
337 impossible to describe them all in a hand-written manual. The
338 generated internal documentation is a heavily crosslinked HTML
339 document, produced directly from the formatting definitions used.  It
340 the nit-gritty details of each and every LilyPond class, object and
341 function.
342
343 Each section of the reference manual has a @b{See also}
344 subsection, with links (in the HTML document, at least) to the
345 generated documentation.
346
347 @item
348   Templates
349 @ifhtml
350 available @uref{../../../input/templates/out-www/collated-files.html,here}
351 @end ifhtml
352
353   When you have gone through the tutorial, you theoretically should be
354 able to start writing input files. However, this turns out to be a
355 little intimidating.  To give you a headstart, we have collected a
356 number of often-used formats in example files. You can take one of
357 these example files, and add notes in the appropriate places to
358 generate output.
359
360 @item
361   Various input examples
362 @ifhtml
363 available @uref{../../../input/test/out-www/collated-files.html,here}
364 @end ifhtml
365 @cindex snippets
366
367 These small files show various applications of lilypond, and are
368 available as a big HTML document, with pictures and explanatory texts
369 included.
370
371
372 @item
373   The regression test
374 @ifhtml
375 available @uref{../../../input/regression/out-www/collated-files.html,here}
376 @end ifhtml
377
378 We strive to test each feature in a collection of input snippets. This
379 is primarily to help us debug the program, but it can be instructive
380 to see how we excercise the program. The format is like the input
381 examples.
382
383 @end itemize
384
385 @cindex adjusting output
386 @cindex variables
387 @cindex properties
388 @cindex lilypond-internals
389 @cindex internal documentation
390 @cindex Scheme
391 @cindex extending lilypond
392 @cindex bugreport
393 @cindex index