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