]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/essay/engraving.itely
5b5fe67b7d7b1c4f69a0e0346e0b6d42445845de
[lilypond.git] / Documentation / essay / engraving.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.13.4"
11
12 @node Music engraving
13 @chapter Music engraving
14
15 This section covers the overall goals and architecture of
16 LilyPond.
17
18 @c TODO:
19 @c remove 3mm eps bounding box left padding for Sarabande (This will
20 @c     require adding a new snippet option to lilypond-book.py
21 @c check formatting of HTML output
22 @c
23
24 @c Notes:
25 @c Incorrect beaming in the Sarabande is a known bug.
26
27 @menu
28 * The LilyPond story::          
29 * Engraving details::           
30 * Automated engraving::         
31 * What symbols to engrave?::    
32 * Music representation::        
33 * Example applications::        
34 * Appendix::                    
35 @end menu
36
37 @node The LilyPond story
38 @unnumberedsec The LilyPond story
39
40 Before LilyPond had a community of users around the world, before it had
41 been used to produce university course notes or world-premier opera
42 performance scores, before there was an essay on music engraving or any
43 computer code or even an organized team of developers, LilyPond began
44 with a question:
45
46 @quotation
47 Why does most computer output fail to achieve the beauty and balance of
48 a hand-engraved score?
49 @end quotation
50
51 @noindent
52 Some of the answers can be found by examining the two scores
53 @ifnottex
54 below.
55 @end ifnottex
56 @iftex
57 on the following pages.
58 @end iftex
59 The first score is a beautiful hand-engraved score from 1950 and the
60 second is a modern, computer-engraved edition.
61
62 @ifnottex
63 @noindent
64 Bärenreiter BA 320, @copyright{}1950:
65
66 @sourceimage{baer-suite1-fullpage,,,png}
67
68 @noindent
69 Henle no. 666, @copyright{}2000:
70
71 @sourceimage{henle-suite1-fullpage,,,png}
72 @end ifnottex
73
74 The notes here are identical, taken from Bach's first Suite for solo
75 cello, but the appearance is different, especially if you print them out
76 and veiw them from a distance.
77 @ifnottex
78 (The PDF version of this manual has high-resolution images suitable for
79 printing.)
80 @end ifnottex
81 Try reading or playing from each of the scores and you will find that
82 the hand-engraved score is more enjoyable to use. It has flowing lines
83 and movement, and it feels like a living, breathing piece of music,
84 while the newer edition seems cold and mechanical.
85
86 It is kind of hard to immediately see what makes the difference with the
87 newer edition. Everything looks neat and tiny, possibly even ``better''
88 because it looks more computerized and uniform. This really puzzled us
89 for quite a while. We wanted to improve computer notation, but we first
90 had to figure out what was wrong with it.
91
92 The answer lies in the precise, mathematical uniformity of the newer
93 edition. Find the barline in the middle of each line: in the
94 hand-engraved score the position of these barlines has some natural
95 natural variation, while in the newer version they line up almost
96 perfectly. This is shown in these simplified page layout diagrams,
97 traced from the hand-engraved (left) and computer-generated music
98 (right):
99
100 @quotation
101 @iftex
102 @sourceimage{pdf/page-layout-comparison,,,}
103 @end iftex
104 @ifnottex
105 @sourceimage{page-layout-comparison,,,png}
106 @end ifnottex
107 @end quotation
108 @noindent
109
110 In the computer-generated output, even the individual noteheads are
111 aligned in vertical columns, making the contour of the melody disappear
112 into a rigid grid of musical markings.
113
114 There are other differences as well: in the hand-engraved edition the
115 vertical lines are all stronger, the slurs lie closer to the noteheads,
116 and there is more visual variety in the placement of the beams. Although
117 such details may seem like nitpicking, the result is a score that is
118 easier to read. In the computer-generated output, each line is nearly
119 identical and if the musician looks away for a moment, she will be lost
120 on the page.
121
122 LilyPond was designed to solve the problems we found in existing
123 software and to create beautiful music that mimics the finest
124 hand-engraved scores. Along the way, we have learned a great deal about
125 the work that goes into a well-engraved score. In this essay we describe
126 several of those aspects that we have tried to imitate in LilyPond.
127
128 @iftex
129 @page
130 @noindent
131 Bärenreiter BA 320, @copyright{}1950:
132
133 @sourceimage{baer-suite1-fullpage,16cm,,}
134 @page
135 @noindent
136 Henle no. 666, @copyright{}2000:
137 @sp 3
138 @sourceimage{henle-suite1-fullpage,16cm,,}
139 @page
140 @end iftex
141
142 @node Engraving details
143 @unnumberedsec Engraving details
144
145 @cindex engraving
146 @cindex typography, music
147 @cindex music typography
148 @cindex plate engraving
149 @cindex music engraving
150
151 The art of music typography is called @emph{(plate) engraving}, a term
152 that derives from the manual process of music printing@footnote{Early
153 european printers explored several processes, including hand-carved
154 wooden blocks, movable type, and engraved sheets of thin metal.
155 Typesetting had the advantage of being more easily corrected and
156 facilitating the inclusion of text and lyrics, but only engraving
157 offered the ability to do unimpeded layout and unanticipated notation.
158 In the end, hand-engraved scores became the standard for all printed
159 music, with the exception of some hymnals and songbooks where
160 typesetting was justified by its ease and economy, even into the
161 twentieth century.}. Just a few decades ago, sheet music was made by
162 cutting and stamping the music into a zinc or pewter plate in mirror
163 image. The plate would be inked, and the depressions caused by the
164 cutting and stamping would hold ink. An image was formed by pressing
165 paper to the plate. The stamping and cutting was done completely by hand
166 and making a correction was cumbersome, so the engraving had to be
167 nearly perfect in one go. Engraving was a highly specialized skill; a
168 craftsman had to complete around five years of training before earning
169 the title of master engraver, and another five years of experience were
170 necessary to become truly skilled.
171
172 @quotation
173 @iftex
174 @sourceimage{hader-slaan,,7cm,}
175 @end iftex
176 @ifnottex
177 @sourceimage{hader-slaan,,,jpg}
178 @end ifnottex
179 @end quotation
180
181 LilyPond is inspired by traditional manual engravings published by
182 European music publishers in and towards the end of the first half of
183 the twentieth century, inlcuding Baerenreiter, Duhem, Durand,
184 Hofmeister, Peters, and Schott. This is sometimes regarded as the peak
185 of traditional musical engraving practice.
186
187 @c Now all newly printed music is produced with computers. This has
188 @c obvious advantages: prints are cheaper to make, editorial work can be
189 @c delivered by email, and the original data can be easily stored.
190 @c Unfortunately, computer-generated scores rarely match the quality of
191 @c hand-engraved scores. Instead, computer printouts have a bland,
192 @c mechanical look, which makes them unpleasant to play from.
193
194 @menu
195 * Music fonts::                 
196 * Optical spacing::             
197 * Ledger lines::                
198 * Optical sizing::              
199 * Why work so hard?::           
200 @end menu
201
202 @node Music fonts
203 @unnumberedsubsec Music fonts
204
205 The images below illustrate some differences between traditional
206 engraving and typical computer output. The left picture shows a scan of
207 a flat symbol from a hand-engraved Bärenreiter edition, while the right
208 picture depicts a symbol from an edition of the same music published in
209 2000. Although both images are printed in the same shade of ink, the
210 earlier version looks darker: the staff lines are heavier, and the
211 Bärenreiter flat has a bold, almost voluptuous rounded look. The right
212 scan, on the other hand, has thinner lines and a straight layout with
213 sharp corners.
214
215 @multitable @columnfractions .25 .25 .25 .25
216 @item @tab
217 @ifnotinfo
218 @iftex
219 @sourceimage{baer-flat-gray,,4cm,}
220 @end iftex
221 @ifnottex
222 @sourceimage{baer-flat-gray,,,png}
223 @end ifnottex
224
225 @tab
226 @iftex
227 @sourceimage{henle-flat-gray,,4cm,}
228 @end iftex
229 @ifnottex
230 @sourceimage{henle-flat-gray,,,png}
231 @end ifnottex
232
233 @end ifnotinfo
234 @ifinfo
235 @sourceimage{henle-flat-bw,,,png}
236 @sourceimage{baer-flat-bw,,,png}
237 @sourceimage{lily-flat-bw,,,png}
238 @end ifinfo
239
240
241 @item @tab
242 Bärenreiter (1950)
243 @tab
244 Henle (2000)
245
246 @end multitable
247
248 @cindex musical symbols
249 @cindex font
250 @cindex blackness
251 @cindex balance
252
253 When we wanted to write a computer program to create music typography,
254 there were no musical fonts freely available that could match the
255 elegance of our favorite scores. Undeterred, we created a font of
256 musical symbols, relying on nice printouts of hand-engraved music. The
257 experience helped develop a typographical taste, and it made us
258 appreciate subtle design details. Without that experience, we would not
259 have realized how ugly the fonts were that we admired at first.
260
261 Below is a sample of two music fonts: the upper set is the default font
262 in the Sibelius software (the @emph{Opus} font), and the lower set is
263 our own LilyPond font.
264
265 @quotation
266 @iftex
267 @sourceimage{pdf/OpusAndFeta,,,}
268 @end iftex
269 @ifnottex
270 @sourceimage{OpusAndFeta,,,png}
271 @end ifnottex
272 @end quotation
273
274 The LilyPond symbols are heavier and their weight is more consistent,
275 which makes them easier to read. Fine endings, such as the ones on the
276 sides of the quarter rest, should not end in sharp points, but rather
277 in rounded shapes. This is because sharp corners of the punching dies
278 are fragile and quickly wear out when stamping in metal. Taken together,
279 the blackness of the font must be carefully tuned together with the
280 thickness of lines, beams and slurs to give a strong yet balanced
281 overall impression.
282
283 Also, notice that our half-notehead is not elliptic but slightly diamond
284 shaped. The vertical stem of a flat symbol is slightly brushed, becoming
285 wider at the top. The sharp and the natural are easier to distinguish
286 from a distance because their angled lines have different slopes and the
287 vertical strokes are heavier.
288
289 @node Optical spacing
290 @unnumberedsubsec Optical spacing
291
292 In spacing, the distribution of space should reflect the durations
293 between notes. However, as we saw in the Bach Suite above, many modern
294 scores adhere to the durations with mathematical precision, which leads
295 to poor results. In the next example a motive is printed twice: the
296 first time using exact mathematical spacing, and the second with
297 corrections. Which do you prefer?
298
299 @cindex optical spacing
300
301 @lilypond
302 \paper {
303   ragged-right = ##t
304   indent = #0.0
305 }
306
307 music = {
308    c'4 e''4 e'4 b'4 |
309    \stemDown
310    b'8[ e'' a' e'']
311    \stemNeutral
312    e'8[ e'8 e'8 e'8]
313 }
314 \score
315 {
316   \music
317   \layout {
318     \context {
319       \Staff
320       \override NoteSpacing #'stem-spacing-correction = #0.0
321       \override NoteSpacing #'same-direction-correction = #0.0
322       \override StaffSpacing #'stem-spacing-correction = #0.0
323     }
324   }
325 }
326 @end lilypond
327
328 @lilypond
329 \paper {
330   ragged-right = ##t
331   indent = #0.0
332 }
333
334 music = {
335    c'4 e''4 e'4 b'4 |
336    \stemDown
337    b'8[ e'' a' e'']
338    \stemNeutral
339    e'8[ e'8 e'8 e'8]
340 }
341
342 \score
343 {
344   \music
345   \layout {
346     \context {
347       \Staff
348       \override NoteSpacing #'stem-spacing-correction = #0.6
349     }
350   }
351 }
352 @end lilypond
353
354 @cindex regular rhythms
355 @cindex regular spacing
356 @cindex spacing, regular
357
358 Each bar in the fragment only uses notes that are played in a constant
359 rhythm. The spacing should reflect that. Unfortunately, the eye deceives
360 us a little; not only does it notice the distance between note heads, it
361 also takes into account the distance between consecutive stems. As a
362 result, the notes of an up-stem/@/down-stem combination should be put
363 farther apart, and the notes of a down-stem/@/up-stem combination should
364 be put closer together, all depending on the combined vertical positions
365 of the notes. The lower two measures are printed with this correction,
366 the upper two measures, however, form down-stem/@/up-stem clumps of
367 notes. A master engraver would adjust the spacing as needed to please
368 the eye.
369
370 Another example of optical spacing is the visual interplay between the
371 stems and the bar lines. When an up-stem precedes the bar line, a little
372 more space is needed to keep it from feeling crowded:
373
374 @lilypond
375 \paper {
376   ragged-right = ##t
377 }
378
379 \score {
380   {
381     c''8 c'' c'' c'' c'' c'' c'' c'' \break
382     a' a' a' a' a' a' a' a'
383   }
384   \layout {
385     \context {
386       \Staff
387       \remove "Time_signature_engraver"
388       \override NoteSpacing #'stem-spacing-correction = #0.7
389     }
390     \context {
391       \Score
392       \remove "Bar_number_engraver"
393     }
394   }
395 }
396 @end lilypond
397
398 @node Ledger lines
399 @unnumberedsubsec Ledger lines
400
401 @cindex ledger lines
402 @cindex collisions
403
404 Ledger lines present a typographical challenge: they make it more
405 difficult to space musical symbols close together and they must be clear
406 enough to identify the pitch at a glance. In the example below, we see
407 that ledger lines should be thicker than normal staff lines and that an
408 expert engraver will shorten a ledger line to allow closer spacing with
409 accidentals. We have included this feature in LilyPond's engraving.
410
411 @multitable @columnfractions .25 .25 .25 .25
412 @item @tab
413
414 @iftex
415 @sourceimage{baer-ledger,3cm,,}
416 @end iftex
417 @ifnottex
418 @sourceimage{baer-ledger,,,png}
419 @end ifnottex
420
421 @tab
422
423 @iftex
424 @sourceimage{lily-ledger,3cm,,}
425 @end iftex
426 @ifnottex
427 @sourceimage{lily-ledger,,,png}
428 @end ifnottex
429
430 @end multitable
431
432
433 @node Optical sizing
434 @unnumberedsubsec Optical sizing
435
436 Music may need to be printed in a range of sizes. Originally, this was
437 accomplished by creating punching dies in each of the required sizes,
438 which meant that each die was designed to look its best at that size.
439 With the advent of digital fonts, a single outline can be mathematically
440 scaled to any size, which is very convenient, but at the smaller sizes
441 the glyphs will appear very light.
442
443 In LilyPond, we have created fonts in a range of weights, corresponding
444 to a range of music sizes. This is a LilyPond engraving at staff size
445 26:
446
447 @quotation
448 @iftex
449 @sourceimage{pdf/size26,,23mm,}
450 @end iftex
451 @ifnottex
452 @sourceimage{size26,,,png}
453 @end ifnottex
454 @end quotation
455
456 @noindent
457 and this is the same engraving set at staff size 11, then
458 magnified by 236% to print at the same size as the previous example:
459
460 @quotation
461 @iftex
462 @sourceimage{pdf/size11,,23mm,}
463 @end iftex
464 @ifnottex
465 @sourceimage{size11,,,png}
466 @end ifnottex
467 @end quotation
468
469 @noindent
470 At smaller sizes, LilyPond uses proportionally heavier lines so the
471 music will still read well.
472
473 @ignore
474 This also allows staves of different sizes to coexist peacefully when
475 used together on the same page:
476
477 @c TODO: are the stems in this example the right thickness? How should
478 @c line wieghts be scaled for small staves?
479
480 @c Grieg's Violin Sonata Op. 45
481 @lilypond[indent=1.5cm]
482 global = {
483   \time 6/8
484   \key c \minor
485 }
486
487 \new Score <<
488   \new Staff \with {
489       fontSize = #-4
490       \override StaffSymbol #'staff-space = #(magstep -4)
491       \override StaffSymbol #'thickness = #(magstep -3)
492     }
493     \relative c' {
494       \global
495       \set Staff.instrumentName = #"Violin"
496       c8.(\f^> b16 c d) ees8.(^> d16 c b)
497       g8.(^> b16 c ees) g8-.^> r r
498       R2.
499     }
500   \new PianoStaff <<
501     \set PianoStaff.instrumentName = #"Piano"
502     \new Staff \relative c' {
503       \global
504       s2.
505       s4. s8 r8 r16 <c f aes c>
506       <c f aes c>4.^> <c ees g>8 r r
507     }
508     \new Staff \relative c {
509       \global
510       \clef "bass"
511       << {
512         \once \override DynamicText #'X-offset = #-3
513         <ees g c>2.~->^\f
514         <ees g c>4.~ <ees g c>8
515       } \\ {
516         <c g c,>2.~
517         <c g c,>4.~ <c g c,>8
518       } >>
519       r8 r16 <f, c' aes'>16
520       <f c' aes'>4.-> <c' g'>8 r r
521     }
522   >>
523 >>
524 @end lilypond
525 @end ignore
526
527 @node Why work so hard?
528 @unnumberedsubsec Why work so hard?
529
530 Musicians are usually more absorbed with performing than with studying
531 the looks of a piece of music, so nitpicking typographical details may
532 seem academic. But it is not. Sheet music is performance material:
533 everything is done to aid the musician in letting her perform better,
534 and anything that is unclear or unpleasant to read is a hinderance.
535
536 Traditionally engraved music uses bold symbols on heavy staff to create
537 a strong, well-balanced look that stands out well when the music is far
538 away from the reader: for example, if it is on a music stand. A careful
539 distribution of white space allows music to be set very tightly without
540 crowding symbols together. The result minimizes the number of page
541 turns, which is a great advantage.
542
543 This is a common characteristic of typography. Layout should be pretty,
544 not only for its own sake, but especially because it helps the reader in
545 his task. For sheet music this is of double importance because musicians
546 have a limited amount of attention. The less attention they need for
547 reading, the more they can focus on playing the music. In other words,
548 better typography translates to better performances.
549
550 These examples demonstrate that music typography is an art that is
551 subtle and complex, and that producing it requires considerable
552 expertise, which musicians usually do not have.  LilyPond is our
553 effort to bring the graphical excellence of hand-engraved music to
554 the computer age, and make it available to normal musicians.  We
555 have tuned our algorithms, font-designs, and program settings to
556 produce prints that match the quality of the old editions we love
557 to see and love to play from.
558
559
560 @node Automated engraving
561 @unnumberedsec Automated engraving
562
563 @cindex engraving, automated
564 @cindex automated engraving
565
566 This section describes what is required to create software that can
567 mimic the layout of engraved scores: a method of explaining good
568 layouts to the computer, detailed comparisons with real engravings,
569 and enough flexibility to deal with the wide range of challenges
570 that printed music can present.
571
572 @menu
573 * Beauty contests::             
574 * Notation benchmarking::       
575 * Flexible architecture::       
576 @end menu
577
578 @node Beauty contests
579 @unnumberedsubsec Beauty contests
580
581 How do we actually make formatting decisions?  In other words, which
582 of the three configurations should we choose for the following slur?
583
584 @lilypond
585 \relative c {
586     \clef bass
587     \once \override Slur #'positions = #'(1.5 . 1)
588     e8[( f] g[ a b d,)] r4
589     \once \override Slur #'positions = #'(2 . 3)
590     e8[( f] g[ a b d,)] r4
591     e8[( f] g[ a b d,)] r4
592 }
593 @end lilypond
594
595 There are a few books on the art of music engraving
596 available. Unfortunately, they contain rules of simple thumbs and some
597 examples.  Such rules can be instructive, but they are a far cry from
598 an algorithm that we could readily implement in a computer.  Following
599 the instructions from literature leads to algorithms with lots of
600 handcoded exceptions. Doing all this case analysis is a lot of work,
601 and often not all cases are covered completely:
602
603 @quotation
604 @iftex
605 @sourceimage{ross-beam-scan,7cm,,}
606 @end iftex
607 @ifnottex
608 @sourceimage{ross-beam-scan,,,.jpg}
609 @end ifnottex
610 @end quotation
611
612 (Image source: Ted Ross, @emph{The Art of Music Engraving})
613
614 Rather than trying to write detailed layout rules for every possible
615 scenario, we only have to describe the objectives well enough that
616 LilyPond can judge the attractiveness of several alternatives. Then,
617 for each possible configuration we compute an ugliness score and we
618 choose the least ugly configuration.
619
620 For example, here are three possible slur configurations, and LilyPond
621 has given each one a score in `ugly points'. The first example gets 15.39
622 points for grazing one of the notes:
623
624 @lilypond
625 \relative c {
626     \clef bass
627     \once \override Slur #'positions = #'(1.5 . 1)
628     e8[(_"15.39" f] g[ a b d,)] r4
629 }
630 @end lilypond
631
632 The
633 second one is nicer, but the slur doesn't start or end on the noteheads.
634 It gets 1.71 points for the left side and 9.37 points for the right
635 side, plus another 2 points because the slur ascends while the melody
636 descends for a total of 13.08 ulgy points:
637
638 @lilypond
639 \relative c {
640     \clef bass
641     \once \override Slur #'positions = #'(2 . 3)
642     e8[(_"13.08" f] g[ a b d,)] r4
643 }
644 @end lilypond
645
646 The final slur gets 10.04
647 points for the gap on the right and 2 points for the upward slope, but
648 it is the most attractive of the three configurations, so LilyPond
649 selects this one:
650
651 @lilypond
652 \relative c {
653     \clef bass
654     e8[(_"12.04" f] g[ a b d,)] r4
655 }
656 @end lilypond
657
658 This technique is quite general, and is used to make optimal decisions
659 for beam configurations, ties and dots in chords, line breaks, and page
660 breaks. The results of these decisions can be judged by comparison to
661 real engravings.
662
663 @node Improvement by benchmarking
664 @unnumberedsubsec Improvement by benchmarking
665
666 LilyPond's output has improved gradually over time, and it continues to
667 improve by comparing its output to hand-engraved scores.
668
669 For example, here is one line of a benchmark piece from a
670 hand-engraved edition (Bärenreiter BA320):
671
672 @iftex
673 @sourceimage{baer-sarabande-hires,16cm,,}
674 @end iftex
675 @ifnottex
676 @sourceimage{baer-sarabande,,,png}
677 @end ifnottex
678
679 @noindent
680 and the same quotation as engraved by a very old version of LilyPond
681 (version 1.4, May 2001):
682
683 @iftex
684 @sourceimage{pdf/lily14-sarabande,16cm,,}
685 @end iftex
686 @ifnottex
687 @sourceimage{lily14-sarabande,,,png}
688 @end ifnottex
689
690 @noindent The LilyPond 1.4 output is certainly readable, but close
691 comparison with the hand-engraved score showed a lot of errors in the
692 formatting details:
693
694 @iftex
695 @sourceimage{lily14-sarabande-annotated-hires,16cm,,}
696 @end iftex
697 @ifnottex
698 @sourceimage{lily14-sarabande-annotated,,,png}
699 @end ifnottex
700
701 @itemize @bullet
702 @item there is too much space before the time signature
703 @item the stems of the beamed notes are too long
704 @item the second and fourth measures are too narrow
705 @item the slur is awkward-looking
706 @item the trill marks are too big
707 @item the stems are too thin
708 @end itemize
709
710 @noindent
711 (There were also two missing noteheads, several missing editorial
712 annotations, and an incorrect pitch!)
713
714 By adjusting the layout rules and font design, the output has improved
715 considerably. Compare the same reference score and the output
716 from the current version of LilyPond (@version{}):
717
718 @iftex
719 @sourceimage{baer-sarabande-hires,16cm,,}
720 @end iftex
721 @ifnottex
722 @sourceimage{baer-sarabande,,,png}
723 @end ifnottex
724
725 @lilypond[staffsize=17.5,line-width=15.9\cm]
726 \relative c {
727   \clef "bass"
728   \key d \minor
729   \time 3/4
730   \mergeDifferentlyDottedOn
731   << {\slurDashed d8.-\flageolet( e16) e4.-\trill( d16 e)}
732      \\ {d4_2 a2}
733   >>
734   \slurDashed
735   <f' a, d,>4. e8( d c)
736   \slurSolid
737   bes g' f e16( f g_1 a_2 bes_3 d,_2)
738   \slurDashed
739   cis4.-\trill b8_3( a g)
740   << {\slurDashed d'8.( e16) e4.-\trill( d16 e)}
741      \\ {<f, a>4 a2}
742   >>
743 }
744 @end lilypond
745
746 @noindent
747 The current output is not a clone of the reference edition, but it is
748 much closer to publication quality that the earlier output.
749
750 @node Getting things right
751 @unnumberedsubsec Getting things right
752
753 We can also measure LilyPond's ability to make music engraving decisions
754 automatically by comparing LilyPond's output to the output of a
755 commercial software product. In this case we have chosen Finale 2008,
756 which is one of the most popular commercial scorewriters, particularly
757 in North America. Sibelius is their major rival and they appear to be
758 especially strong in the European market.
759
760 For our comparison we chose Bach's Fugue in G minor from the
761 Well-Tempered Clavier, Book I, BWV 861, whose opening subject is
762
763 @lilypond
764 \relative c' {
765   \key g \minor
766   \clef "treble_8"
767   r8 d ees g, fis4 g
768   r8 a16 bes c8 bes16 a bes8
769 }
770 @end lilypond
771
772 @noindent
773
774 We made our comparison by engraving the last seven measures of the piece
775 (28--34) in Finale and LilyPond. This is the point in the piece where
776 the subject returns in a three-part stretto and leads into the closing
777 section. In the Finale version, we have resisted the temptation to make
778 any adjustments to the default output because we are trying to show the
779 things that each software package gets right without assistance.
780
781 Many of the differences between the two engravings are visible in
782 measures 28--29, as shown here with Finale first and LilyPond second:
783
784 @iftex
785 @sourceimage{pdf/bwv861mm28-29,14cm,,}
786 @end iftex
787 @ifnottex
788 @sourceimage{bwv861mm28-29,,,png}
789 @end ifnottex
790
791 @lilypond[staffsize=19.5,line-width=14\cm]
792 global = {\key g \minor}
793
794 partI = \relative c' {
795   \voiceOne
796   fis8 d' ees g, fis4 g
797   r8 a16 bes c8 bes16 a d8 r r4
798 }
799
800 partII = \relative c' {
801   \voiceTwo
802   d4 r4 r8 d'16 c bes8 c16 d
803   ees8 d c ees a, r r4
804 }
805 partIII = \relative c' {
806   \voiceOne
807   r2 r8 d ees g, fis4 g r8 a16 bes c8 bes16 a
808 }
809 partIV = \relative c {
810   \voiceTwo
811   d4 r r2
812   r8 d ees g, fis4 a
813 }
814
815 \score {
816   <<
817     % \set Score.barNumberVisibility = #all-bar-numbers-visible
818     % required in 2.13
819     \set Score.currentBarNumber = #28
820     \bar ""
821     \new PianoStaff <<
822       \new Staff = "RH" <<
823         \global
824         \new Voice = "voiceI" { \partI }
825         \new Voice = "voiceII" { \partII }
826       >>
827
828       \new Staff = "LH" <<
829         \clef "bass"
830         \global
831         \new Voice = "voiceIII" { \partIII }
832         \new Voice = "voiceIV" { \partIV }
833       >>
834     >>
835   >>
836   \layout {
837     \context {
838       \Staff
839       \remove "Time_signature_engraver"
840     }
841     \context {
842       \PianoStaff
843       \override StaffGrouper #'between-staff-spacing #'padding = #1
844     }
845   }
846 }
847 @end lilypond
848
849 Some shortcomings in the unedited Finale output include:
850 @itemize @bullet
851 @item Most of the beams extend too far off the staff. A beam that points
852 towards the center of the staff should have a length of about one
853 octave, but engravers shorten this when the beam points away from the
854 staff in multi-voice music. The Finale beaming can be easily improved
855 with the Patterson Beams plug-in, but we elected to skip that step for
856 this example.
857 @item Finale doesn't adjust the positions of interlocking noteheads,
858 which makes the music extremely difficult to read when the upper and
859 lower voices exchange positions temporarily:
860
861 @lilypond
862 collide = \once \override NoteColumn #'force-hshift = #0
863 \new Score <<
864   \new Voice = "sample" \relative c''{
865     \key g \minor
866     <<
867       {\voiceOne g4 \collide g4}
868       \new Voice {\voiceTwo bes \collide bes}
869     >>
870   }
871   \new Lyrics \lyricsto "sample" \lyricmode { "good " " bad" }
872 >>
873 @end lilypond
874
875 @item Finale has placed all of the rests at fixed heights on the staff.
876 The user is free to adjust them as needed, but the software makes no
877 attempt to consider the content of the other voice. As luck would have
878 it, there are no true collsions between notes and rests in this example,
879 but that has more to do with the positions of the notes than the rest.
880 In other words, Bach deserves more credit for avoiding a complete
881 collision that Finale does.
882
883 @end itemize
884
885 This example is not intended to suggest that Finale cannot be used to
886 produce beautiful output. On the contrary, in the hands of a skilled
887 user it can and does, but it requires skill and time. One of the
888 fundamental differences between LilyPond and commercial scorewriters is
889 that LilyPond hopes to reduce the amount of human intervention to an
890 absolute minimum, while other packages try to provide an attractive
891 interface in which to make these types of edits.
892
893 One particularly glaring omission we found in the Finale sample is a
894 missing flat in measure 33:
895
896 @quotation
897 @iftex
898 @sourceimage{pdf/bwv861mm33-34-annotate,7.93cm,,}
899 @end iftex
900 @ifnottex
901 @sourceimage{bwv861mm33-34-annotate,,,png}
902 @end ifnottex
903 @end quotation
904
905 @noindent
906 The flat symbol is required to cancel out the natural in the same
907 measure, but Finale misses it because it occurred in a different voice.
908 The user must not only remember to run a beaming plug-in and respace the
909 noteheads and rests, she must also check each measure for cross-voice
910 accidentals if she is to avoid interrupting a rehearsal for an engraving
911 error.
912
913 If you are interested in examining these examples in more detail, the
914 full seven-measure excerpt can be found at the end of this essay in
915 engravings by Finale and LilyPond along with four different published
916 engravings. Close examination reveals that there is some acceptible
917 variation among the hand-engravings, but that LilyPond compares
918 reasonably well to that acceptible range. There are still some
919 shortcomings in the LilyPond output, for example, it appears a bit too
920 agressive in shortening some of the stems, so there is room for further
921 development and fine-tuning.
922
923 Of course, typography relies on human judgment of appearance, so people
924 cannot be replaced completely. However, much of the dull work can be
925 automated. If LilyPond solves most of the common situations correctly,
926 this will be a huge improvement over existing software. Over the course
927 of years, the software can be refined to do more and more things
928 automatically, so manual overrides are less and less necessary. Where
929 manual adjustments are needed, LilyPond's structure has been designed
930 with that flexibility in mind.
931
932 @node Flexible architecture
933 @unnumberedsubsec Flexible architecture
934
935 When we started, we wrote the LilyPond program entirely in the C++
936 programming language; the program's functionality was set in stone
937 by the developers.  That proved to be unsatisfactory for a number
938 of reasons:
939
940 @itemize
941
942 @item When LilyPond makes mistakes, users need to override
943 formatting decisions.  Therefore, the user must have access to the
944 formatting engine.  Hence, rules and settings cannot be fixed by
945 us at compile-time but must be accessible for users at run-time.
946
947 @item Engraving is a matter of visual judgment, and therefore a
948 matter of taste.  As knowledgeable as we are, users can disagree
949 with our personal decisions.  Therefore, the definitions of
950 typographical style must also be accessible to the user.
951
952 @item Finally, we continually refine the formatting algorithms, so
953 we need a flexible approach to rules.  The C++ language forces a
954 certain method of grouping rules that cannot readily be applied to
955 formatting music notation.
956
957 @end itemize
958
959 @cindex Scheme programming language
960
961 These problems have been addressed by integrating an interpreter
962 for the Scheme programming language and rewriting parts of
963 LilyPond in Scheme.  The current formatting architecture is built
964 around the notion of graphical objects, described by Scheme
965 variables and functions.  This architecture encompasses formatting
966 rules, typographical style and individual formatting decisions.
967 The user has direct access to most of these controls.
968
969 Scheme variables control layout decisions.  For example, many
970 graphical objects have a direction variable that encodes the
971 choice between up and down (or left and right).  Here you see two
972 chords, with accents and arpeggios.  In the first chord, the
973 graphical objects have all directions down (or left).  The second
974 chord has all directions up (right).
975
976 @lilypond[quote,ragged-right]
977 \new Score \with {
978    \override SpacingSpanner #'spacing-increment = #3
979    \override TimeSignature #'transparent = ##t
980 } \relative c' {
981    \stemDown <e g b>4_>-\arpeggio
982    \override Arpeggio #'direction = #RIGHT
983    \stemUp <e g b>4^>-\arpeggio
984 }
985 @end lilypond
986
987 @cindex score formatting
988 @cindex formatting a score
989 @cindex formatting rules
990
991 @noindent
992 The process of formatting a score consists of reading and writing
993 the variables of graphical objects.  Some variables have a preset
994 value.  For example, the thickness of many lines -- a
995 characteristic of typographical style -- is a variable with a
996 preset value.  You are free to alter this value, giving your score
997 a different typographical impression.
998
999 @lilypond[quote,ragged-right]
1000 fragment = {
1001    \clef bass f8 as8
1002    c'4-~ c'16 as g f e16 g bes c' des'4
1003 }
1004 <<
1005    \new Staff \fragment
1006    \new Staff \with {
1007       \override Beam #'beam-thickness = #0.3
1008       \override Stem #'thickness = #0.5
1009       \override Bar #'thickness = #3.6
1010       \override Tie #'thickness = #2.2
1011       \override StaffSymbol #'thickness = #3.0
1012       \override Tie #'extra-offset = #'(0 .  0.3)
1013       }
1014       \fragment
1015 >>
1016 @end lilypond
1017
1018 Formatting rules are also preset variables: each object has
1019 variables containing procedures.  These procedures perform the
1020 actual formatting, and by substituting different ones, we can
1021 change the appearance of objects.  In the following example, the
1022 rule governing which note head objects are used to produce the
1023 note head symbol is changed during the music fragment.
1024
1025 @lilypond[quote,ragged-right]
1026 #(set-global-staff-size 30)
1027
1028 #(define (mc-squared grob orig current)
1029   (let* ((interfaces (ly:grob-interfaces grob))
1030          (pos (ly:grob-property grob 'staff-position)))
1031     (if (memq 'note-head-interface interfaces)
1032         (begin
1033           (ly:grob-set-property! grob 'stencil
1034             (grob-interpret-markup grob
1035               (make-lower-markup 0.5
1036                 (case pos
1037                   ((-5) "m")
1038                   ((-3) "c ")
1039                   ((-2) (make-smaller-markup (make-bold-markup "2")))
1040                   (else "bla")))))))))
1041
1042 \new Voice \relative c' {
1043   \stemUp
1044   \set autoBeaming = ##f
1045   \time 2/4
1046   <d f g>4
1047   \once \override NoteHead #'stencil = #note-head::brew-ez-stencil
1048   \once \override NoteHead #'font-size = #-7
1049   \once \override NoteHead #'font-family = #'sans
1050   \once \override NoteHead #'font-series = #'bold
1051   <d f g>4
1052   \once \override NoteHead #'style = #'cross
1053   <d f g>4
1054   \applyOutput #'Voice #mc-squared
1055   <d f g>4
1056   <<
1057     { d8[ es-( fis^^ g] fis2-) }
1058     \repeat unfold 5 { \applyOutput #'Voice #mc-squared s8 }
1059   >>
1060 }
1061 @end lilypond
1062
1063
1064 @node What symbols to engrave?
1065 @unnumberedsec What symbols to engrave?
1066
1067 @cindex engraving
1068 @cindex typography
1069 @cindex engraver
1070 @cindex plug-in
1071
1072 The formatting process decides where to place symbols.  However,
1073 this can only be done once it is decided @emph{what} symbols
1074 should be printed -- in other words, what notation to use.
1075
1076 Common music notation is a system of recording music that has
1077 evolved over the past 1000 years.  The form that is now in common
1078 use dates from the early Renaissance.  Although the basic form
1079 (i.e., note heads on a 5-line staff) has not changed, the details
1080 still evolve to express the innovations of contemporary notation.
1081 Hence, common music notation encompasses some 500 years of music.
1082 Its applications range from monophonic melodies to monstrous
1083 counterpoints for a large orchestra.
1084
1085 How can we get a grip on such a seven-headed beast, and force it
1086 into the confines of a computer program?  Our solution is to break
1087 up the problem of notation (as opposed to engraving, i.e.,
1088 typography) into digestible and programmable chunks: every type of
1089 symbol is handled by a separate module, a so-called plug-in.  Each
1090 plug-in is completely modular and independent, so each can be
1091 developed and improved separately.  Such plug-ins are called
1092 @code{engraver}s, by analogy with craftsmen who translate musical
1093 ideas to graphic symbols.
1094
1095 In the following example, we start out with a plug-in for note
1096 heads, the @code{Note_heads_engraver}.
1097
1098 @lilypond[quote,ragged-right]
1099 \include "engraver-example.ily"
1100
1101 \score {
1102   \topVoice
1103   \layout {
1104     \context {
1105       \Voice
1106       \remove "Stem_engraver"
1107       \remove "Phrasing_slur_engraver"
1108       \remove "Slur_engraver"
1109       \remove "Script_engraver"
1110       \remove "Beam_engraver"
1111       \remove "Auto_beam_engraver"
1112     }
1113     \context {
1114       \Staff
1115       \remove "Accidental_engraver"
1116       \remove "Key_engraver"
1117       \remove "Clef_engraver"
1118       \remove "Bar_engraver"
1119       \remove "Time_signature_engraver"
1120       \remove "Staff_symbol_engraver"
1121       \consists "Pitch_squash_engraver"
1122     }
1123   }
1124 }
1125 @end lilypond
1126
1127 @noindent
1128 Then a @code{Staff_symbol_engraver} adds the staff,
1129
1130 @lilypond[quote,ragged-right]
1131 \include "engraver-example.ily"
1132
1133 \score {
1134   \topVoice
1135   \layout {
1136     \context {
1137       \Voice
1138       \remove "Stem_engraver"
1139       \remove "Phrasing_slur_engraver"
1140       \remove "Slur_engraver"
1141       \remove "Script_engraver"
1142       \remove "Beam_engraver"
1143       \remove "Auto_beam_engraver"
1144     }
1145     \context {
1146       \Staff
1147       \remove "Accidental_engraver"
1148       \remove "Key_engraver"
1149       \remove "Clef_engraver"
1150       \remove "Bar_engraver"
1151       \consists "Pitch_squash_engraver"
1152       \remove "Time_signature_engraver"
1153     }
1154   }
1155 }
1156 @end lilypond
1157
1158 @noindent
1159 the @code{Clef_engraver} defines a reference point for the staff,
1160
1161 @lilypond[quote,ragged-right]
1162 \include "engraver-example.ily"
1163
1164 \score {
1165   \topVoice
1166   \layout {
1167     \context {
1168       \Voice
1169       \remove "Stem_engraver"
1170       \remove "Phrasing_slur_engraver"
1171       \remove "Slur_engraver"
1172       \remove "Script_engraver"
1173       \remove "Beam_engraver"
1174       \remove "Auto_beam_engraver"
1175     }
1176     \context {
1177       \Staff
1178       \remove "Accidental_engraver"
1179       \remove "Key_engraver"
1180       \remove "Bar_engraver"
1181       \remove "Time_signature_engraver"
1182     }
1183   }
1184 }
1185 @end lilypond
1186
1187 @noindent
1188 and the @code{Stem_engraver} adds stems.
1189
1190 @lilypond[quote,ragged-right]
1191 \include "engraver-example.ily"
1192
1193 \score {
1194   \topVoice
1195   \layout {
1196     \context {
1197       \Voice
1198       \remove "Phrasing_slur_engraver"
1199       \remove "Slur_engraver"
1200       \remove "Script_engraver"
1201       \remove "Beam_engraver"
1202       \remove "Auto_beam_engraver"
1203     }
1204     \context {
1205       \Staff
1206       \remove "Accidental_engraver"
1207       \remove "Key_engraver"
1208       \remove "Bar_engraver"
1209       \remove "Time_signature_engraver"
1210     }
1211   }
1212 }
1213 @end lilypond
1214
1215 @noindent
1216 The @code{Stem_engraver} is notified of any note head coming
1217 along.  Every time one (or more, for a chord) note head is seen, a
1218 stem object is created and connected to the note head.  By adding
1219 engravers for beams, slurs, accents, accidentals, bar lines, time
1220 signature, and key signature, we get a complete piece of notation.
1221
1222 @lilypond[quote,ragged-right]
1223 \include "engraver-example.ily"
1224 \score { \topVoice }
1225 @end lilypond
1226
1227 @cindex polyphony
1228 @cindex engraving multiple voices
1229 @cindex contexts
1230
1231 This system works well for monophonic music, but what about
1232 polyphony?  In polyphonic notation, many voices can share a staff.
1233
1234 @lilypond[quote,ragged-right]
1235 \include "engraver-example.ily"
1236 \new Staff << \topVoice \\ \botVoice >>
1237 @end lilypond
1238
1239 In this situation, the accidentals and staff are shared, but the
1240 stems, slurs, beams, etc., are private to each voice.  Hence,
1241 engravers should be grouped.  The engravers for note heads, stems,
1242 slurs, etc., go into a group called @q{Voice context,} while the
1243 engravers for key, accidental, bar, etc., go into a group called
1244 @q{Staff context.}  In the case of polyphony, a single Staff
1245 context contains more than one Voice context.  Similarly, multiple
1246 Staff contexts can be put into a single Score context.  The Score
1247 context is the top level notation context.
1248
1249
1250 @seealso
1251 Internals Reference: @rinternals{Contexts}.
1252
1253
1254 @lilypond[quote,ragged-right]
1255 \include "engraver-example.ily"
1256 \score {
1257    <<
1258       \new Staff << \topVoice \\ \botVoice >>
1259       \new Staff << \pah \\ \hoom >>
1260    >>
1261 }
1262 @end lilypond
1263
1264
1265 @node Music representation
1266 @unnumberedsec Music representation
1267
1268 @cindex syntax
1269 @cindex recursive structures
1270
1271 Ideally, the input format for any high-level formatting system is
1272 an abstract description of the content.  In this case, that would
1273 be the music itself.  This poses a formidable problem: how can we
1274 define what music really is? Instead of trying to find an answer,
1275 we have reversed the question.  We write a program capable of
1276 producing sheet music, and adjust the format to be as lean as
1277 possible.  When the format can no longer be trimmed down, by
1278 definition we are left with content itself.  Our program serves as
1279 a formal definition of a music document.
1280
1281 The syntax is also the user-interface for LilyPond, hence it is
1282 easy to type:
1283
1284 @example
1285 @{
1286   c'4 d'8
1287 @}
1288 @end example
1289
1290 @noindent
1291 to create a quarter note on middle C (C1) and an eighth note on
1292 the D above middle C (D1).
1293
1294 @lilypond[quote]
1295 {
1296   c'4 d'8
1297 }
1298 @end lilypond
1299
1300 On a microscopic scale, such syntax is easy to use.  On a larger
1301 scale, syntax also needs structure.  How else can you enter
1302 complex pieces like symphonies and operas?  The structure is
1303 formed by the concept of music expressions: by combining small
1304 fragments of music into larger ones, more complex music can be
1305 expressed.  For example
1306
1307 @lilypond[quote,verbatim,fragment,relative=1]
1308 f4
1309 @end lilypond
1310
1311 @noindent
1312 Simultaneous notes can be constructed by enclosing them with
1313 @code{<<} and @code{>>}:
1314
1315 @example
1316 <<c4 d4 e4>>
1317 @end example
1318
1319 @lilypond[quote,fragment,relative=1]
1320 \new Voice { <<c4 d4 e>> }
1321 @end lilypond
1322
1323 @noindent
1324 This expression is put in sequence by enclosing it in curly braces
1325 @code{@{@tie{}@dots{}@tie{}@}}:
1326
1327 @example
1328 @{ f4 <<c4 d4 e4>> @}
1329 @end example
1330
1331 @lilypond[quote,relative=1,fragment]
1332 { f4 <<c d e4>> }
1333 @end lilypond
1334
1335 @noindent
1336 The above is also an expression, and so it may be combined again
1337 with another simultaneous expression (a half note) using
1338 @code{<<}, @code{\\}, and @code{>>}:
1339
1340 @example
1341 << g2 \\ @{ f4 <<c4 d4 e4>> @} >>
1342 @end example
1343
1344 @lilypond[quote,fragment,relative=2]
1345 \new Voice { << g2 \\ { f4 <<c d e>> } >> }
1346 @end lilypond
1347
1348 Such recursive structures can be specified neatly and formally in
1349 a context-free grammar.  The parsing code is also generated from
1350 this grammar.  In other words, the syntax of LilyPond is clearly
1351 and unambiguously defined.
1352
1353 User-interfaces and syntax are what people see and deal with most.
1354 They are partly a matter of taste, and also the subject of much
1355 discussion.  Although discussions on taste do have their merit,
1356 they are not very productive.  In the larger picture of LilyPond,
1357 the importance of input syntax is small: inventing neat syntax is
1358 easy, while writing decent formatting code is much harder.  This
1359 is also illustrated by the line-counts for the respective
1360 components: parsing and representation take up less than 10% of
1361 the source code.
1362
1363
1364 @node Example applications
1365 @unnumberedsec Example applications
1366
1367 @cindex simple examples
1368 @cindex examples, simple
1369
1370 We have written LilyPond as an experiment of how to condense the
1371 art of music engraving into a computer program.  Thanks to all
1372 that hard work, the program can now be used to perform useful
1373 tasks.  The simplest application is printing notes.
1374
1375 @lilypond[quote,relative=1]
1376 {
1377   \time 2/4
1378   c4 c g'4 g a4 a g2
1379 }
1380 @end lilypond
1381
1382 @noindent
1383 By adding chord names and lyrics we obtain a lead sheet.
1384
1385 @lilypond[quote,ragged-right]
1386 <<
1387    \chords { c2 c f2 c }
1388    \new Staff
1389    \relative c' {
1390      \time 2/4
1391      c4 c g' g a a g2
1392    }
1393    \addlyrics { twin -- kle twin -- kle lit -- tle star }
1394 >>
1395 @end lilypond
1396
1397 Polyphonic notation and piano music can also be printed.  The
1398 following example combines some more exotic constructs.
1399
1400 @lilypond[quote]
1401 \header {
1402   title = "Screech and boink"
1403   subtitle = "Random complex notation"
1404   composer = "Han-Wen Nienhuys"
1405 }
1406
1407 \score {
1408   \context PianoStaff <<
1409     \new Staff = "up" {
1410       \time 4/8
1411       \key c \minor
1412       << {
1413         \revert Stem #'direction
1414         \change Staff = down
1415         \set subdivideBeams = ##t
1416         g16.[
1417           \change Staff = up
1418           c'''32
1419           \change Staff = down
1420           g32
1421           \change Staff = up
1422           c'''32
1423           \change Staff = down
1424           g16]
1425         \change Staff = up
1426         \stemUp
1427         \set followVoice = ##t
1428         c'''32([ b''16 a''16 gis''16 g''32)]
1429       } \\ {
1430         s4 \times 2/3 { d'16[ f' g'] } as'32[ b''32 e'' d'']
1431       } \\ {
1432         s4 \autoBeamOff d''8.. f''32
1433       } \\ {
1434         s4 es''4
1435       } >>
1436     }
1437
1438     \new Staff = "down" {
1439       \clef bass
1440       \key c \minor
1441       \set subdivideBeams = ##f
1442       \override Stem  #'french-beaming = ##t
1443       \override Beam  #'beam-thickness = #0.3
1444       \override Stem  #'thickness = #4.0
1445       g'16[ b16 fis16 g16]
1446       << \makeClusters {
1447         as16 <as b>
1448         <g b>
1449         <g cis>
1450       } \\ {
1451         \override Staff.Arpeggio  #'arpeggio-direction =#down
1452         <cis, e, gis, b, cis>4\arpeggio
1453       }
1454     >> }
1455   >>
1456   \midi {
1457     \context {
1458       \Score
1459       tempoWholesPerMinute = #(ly:make-moment 60 8)
1460     }
1461   }
1462   \layout {
1463     \context {
1464       \Staff
1465       \consists Horizontal_bracket_engraver
1466     }
1467   }
1468 }
1469 @end lilypond
1470
1471 The fragments shown above have all been written by hand, but that
1472 is not a requirement.  Since the formatting engine is mostly
1473 automatic, it can serve as an output means for other programs that
1474 manipulate music.  For example, it can also be used to convert
1475 databases of musical fragments to images for use on websites and
1476 multimedia presentations.
1477
1478 This manual also shows an application: the input format is text,
1479 and can therefore be easily embedded in other text-based formats
1480 such as @LaTeX{}, HTML, or in the case of this manual, Texinfo.
1481 By means of a special program, the input fragments can be replaced
1482 by music images in the resulting PDF or HTML output files.  This
1483 makes it easy to mix music and text in documents.
1484
1485
1486 TODO: add extra chapter for computer aesthetics?
1487
1488 @page
1489 @node Appendix
1490 @unnumberedsec Appendix
1491
1492 This appendix contaions four reference engravings and two
1493 software-engraved versions of Bach's Fugue in G minor from the
1494 Well-Tempered Clavier, Book I, BWV 861 (the last seven measures).
1495
1496 @noindent
1497 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1498 1989):
1499
1500 @iftex
1501 @sourceimage{bwv861-baer,16cm,,}
1502 @end iftex
1503 @ifnottex
1504 @sourceimage{bwv861-baer-small,,,png}
1505 @end ifnottex
1506
1507 @noindent
1508 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1509 1989), an alternate musical source. Aside from the textual differences,
1510 this demsontrates slight variations in the engraving decisions, even
1511 from the same publisher and edition:
1512
1513 @iftex
1514 @sourceimage{bwv861-baer-alt,16cm,,}
1515 @end iftex
1516 @ifnottex
1517 @sourceimage{bwv861-baer-alt-small,,,png}
1518 @end ifnottex
1519
1520 @noindent
1521 Breitkopf & Härtel, edited by Ferruccio Busoni (Wiesbaden, 1894), also
1522 available from the Petrucci Music Library (IMSLP #22081). The editorial
1523 markings (fingerings, articulations, etc.) have been removed for clearer
1524 comparison with the other editions here:
1525
1526 @iftex
1527 @sourceimage{bwv861-breitkopf,16cm,,}
1528 @end iftex
1529 @ifnottex
1530 @sourceimage{bwv861-breitkopf-small,,,png}
1531 @end ifnottex
1532
1533 @noindent
1534 Bach-Gessellschaft edition (Leipzig, 1866), available from the Petrucci
1535 Music Library (IMSPL #02221):
1536
1537 @iftex
1538 @sourceimage{bwv861-gessellschaft,16cm,,}
1539 @end iftex
1540 @ifnottex
1541 @sourceimage{bwv861-gessellschaft-small,,,png}
1542 @end ifnottex
1543
1544 @noindent
1545 Finale 2008:
1546
1547 @iftex
1548 @sourceimage{pdf/bwv861-finale2008a,,,}
1549 @end iftex
1550 @ifnottex
1551 @sourceimage{bwv861-finale2008a,,,png}
1552 @end ifnottex
1553
1554 @sp 4
1555 @noindent
1556 LilyPond, version @version{}:
1557
1558 @lilypond[staffsize=14.3,line-width=15.9\cm]
1559 global = {\key g \minor}
1560
1561 partI = \relative c' {
1562   \voiceOne
1563   fis8 d' ees g, fis4 g
1564   r8 a16 bes c8 bes16 a d8 r r4
1565   r2 r8 d16 ees f8 ees16 d
1566   ees4 ~ ees16 d c bes a4 r8 ees'16 d
1567   c8 d16 ees d8 e16 fis g8 fis16 g a4 ~
1568   a8 d, g f ees d c bes
1569   a2 g\fermata \bar "|."
1570 }
1571
1572 partII = \relative c' {
1573   \voiceTwo
1574   d4 r4 r8 d'16 c bes8 c16 d
1575   ees8 d c ees a, r r4
1576   r8 fis16 g a8 g16 fis g2 ~
1577   g2 r8 d' ees g,
1578   fis4 g r8 a16 bes c8 bes16 a
1579   bes4. <g b>8 <a c> r <d, g> r
1580   <ees g>4 <d fis> d2
1581 }
1582 partIII = \relative c' {
1583   \voiceOne
1584   r2 r8 d ees g, fis4 g r8 a16 bes c8 bes16 a
1585   bes2 ~ bes8 b16 a g8 a16 b
1586   c4 r r2
1587   R1
1588   r8 d ees g, fis4 g
1589   r8 a16 bes c8 bes16 a b2
1590 }
1591 partIV = \relative c {
1592   \voiceTwo
1593   d4 r r2
1594   r8 d ees g, fis4 a
1595   d,8 d'16 c bes8 c16 d ees2 ~
1596   ees8 ees16 d c8 d16 ees fis,8 a16 g fis8 g16 a
1597   d,8 d'16 c bes8 c16 d ees8 c a fis'
1598   g f ees d c bes a g
1599   c a d d, g2\fermata
1600 }
1601
1602 \score {
1603   <<
1604     % \set Score.barNumberVisibility = #all-bar-numbers-visible
1605     % required in 2.13
1606     \set Score.currentBarNumber = #28
1607     \bar ""
1608     \new PianoStaff <<
1609       \new Staff = "RH" <<
1610         \global
1611         \new Voice = "voiceI" { \partI }
1612         \new Voice = "voiceII" { \partII }
1613       >>
1614
1615       \new Staff = "LH" <<
1616         \clef "bass"
1617         \global
1618         \new Voice = "voiceIII" { \partIII }
1619         \new Voice = "voiceIV" { \partIV }
1620       >>
1621     >>
1622   >>
1623   \layout {
1624     \context {
1625       \Staff
1626       \remove "Time_signature_engraver"
1627     }
1628     \context {
1629       \PianoStaff
1630       \override StaffGrouper #'between-staff-spacing #'padding = #1
1631     }
1632   }
1633 }
1634 @end lilypond