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