]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/introduction.itely
*** empty log message ***
[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 [TODO: show examples]
248
249 The following example combines some more  exotic uses of notation
250
251 @lilypondfile{screech-boink.ly}  
252
253
254
255 @node About this manual
256 @section About this manual
257
258 The manual is divided into the following chapters
259 @table @strong
260 @item Tutorial
261   Gives a gentle introduction into typesetting music.
262   Start here if you have never used lilypond before.
263 @item   Reference manual
264   Here, each aspect of typesetting music is discussed.
265 @item Internals
266   This chapter discusses how it works from the inside, and how you can
267   extend the program.
268 @item Invoking
269   This chapter explains how to runn LilyPond and its helper programs. 
270 @end table
271
272 Once you are experienced with, you can simply use the manual as
273 reference: there is an extensive index@footnote{If you are looking for
274 something, and you cannot find it by using the index, that is
275 considered a bug.  In that case, please file a bug report}, but the
276 document is also available in
277 @ifhtml
278 One Big Page,
279 @end ifhtml
280 @ifnothtml
281 @uref{One Big Page,../lilypond.html}
282 @end ifnothtml 
283 which is is available for text search using your browser's search
284 facility.
285 @cindex search in manual
286 @cindex using the manual
287
288
289 If you are familiar with music notation, and music terminology
290 (especially if you are a foreigner), then it is advisable to consult
291 the glossary as well. This documents explains many terms, and includes
292 translations to various languages. It is a 
293 @ifhtml
294 @uref{separate document,../glossary.html}
295 @end ifhtml
296 @ifnothtml
297 separate document, and can be printed as well.
298 @end ifnothtml
299 @cindex idiom
300 @cindex jargon
301 @cindex terminology
302 @cindex foreign languages
303 @cindex language
304
305
306 This manual is not complete without a number of other documents. They
307 are not available in print, but should be included with the
308 documentation package for your platform
309
310 @itemize @bullet
311 @item
312 Generated internal documentation.
313 @ifhtml
314 available @uref{here,../lilypond-internals/lilypond-internals.html}
315 @end ifhtml
316
317 Almost all formatting functionality that is used internally, is
318 available directly to the user. For example, all variables that
319 control thicknesses, distances, etc, can be changed from input
320 files. There are a huge number of formatting options, and it would be
321 impossible to describe them all in a hand-written manual. The
322 generated internal documentation is a heavily crosslinked HTML
323 document, produced directly from the formatting definitions used.  It
324 the nit-gritty details of each and every LilyPond class, object and
325 function.
326
327 Each section of the reference manual has a @b{See also}
328 subsection, with links (in the HTML document, at least) to the
329 generated documentation.
330
331 @item
332   Templates
333 @ifhtml
334 available @uref{here,../../../input/templates/out-www/collated-files.html}
335 @end ifhtml
336
337   When you have gone through the tutorial, you theoretically should be
338 able to start writing input files. However, this turns out to be a
339 little intimidating.  To give you a headstart, we have collected a
340 number of often-used formats in example files. You can take one of
341 these example files, and add notes in the appropriate places to
342 generate output.
343
344 @item
345   Various input examples
346 @ifhtml
347 available @uref{here,../../../input/test/out-www/collated-files.html}
348 @end ifhtml
349 @cindex snippets
350
351 These small files show various applications of lilypond, and are
352 available as a big HTML document, with pictures and explanatory texts
353 included.
354
355
356 @item
357   The regression test
358 @ifhtml
359 available @uref{here,../../../input/regression/out-www/collated-files.html}
360 @end ifhtml
361
362 We strive to test each feature in a collection of input snippets. This
363 is primarily to help us debug the program, but it can be instructive
364 to see how we excercise the program. The format is like the input
365 examples.
366
367 @end itemize
368
369 @cindex adjusting output
370 @cindex variables
371 @cindex properties
372 @cindex lilypond-internals
373 @cindex internal documentation
374 @cindex Scheme
375 @cindex extending lilypond
376 @cindex bugreport
377 @cindex index