]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/essay/engraving.itely
Doc build: oops, forgot to commit before pushing.
[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 * Improvement by benchmarking::  
575 * Getting things right::        
576 * Flexible architecture::       
577 @end menu
578
579 @node Beauty contests
580 @unnumberedsubsec Beauty contests
581
582 How do we actually make formatting decisions?  In other words, which
583 of the three configurations should we choose for the following slur?
584
585 @lilypond
586 \relative c {
587     \clef bass
588     \once \override Slur #'positions = #'(1.5 . 1)
589     e8[( f] g[ a b d,)] r4
590     \once \override Slur #'positions = #'(2 . 3)
591     e8[( f] g[ a b d,)] r4
592     e8[( f] g[ a b d,)] r4
593 }
594 @end lilypond
595
596 There are a few books on the art of music engraving
597 available. Unfortunately, they contain rules of simple thumbs and some
598 examples.  Such rules can be instructive, but they are a far cry from
599 an algorithm that we could readily implement in a computer.  Following
600 the instructions from literature leads to algorithms with lots of
601 handcoded exceptions. Doing all this case analysis is a lot of work,
602 and often not all cases are covered completely:
603
604 @quotation
605 @iftex
606 @sourceimage{ross-beam-scan,7cm,,}
607 @end iftex
608 @ifnottex
609 @sourceimage{ross-beam-scan,,,.jpg}
610 @end ifnottex
611 @end quotation
612
613 (Image source: Ted Ross, @emph{The Art of Music Engraving})
614
615 Rather than trying to write detailed layout rules for every possible
616 scenario, we only have to describe the objectives well enough that
617 LilyPond can judge the attractiveness of several alternatives. Then,
618 for each possible configuration we compute an ugliness score and we
619 choose the least ugly configuration.
620
621 For example, here are three possible slur configurations, and LilyPond
622 has given each one a score in `ugly points'. The first example gets 15.39
623 points for grazing one of the notes:
624
625 @lilypond
626 \relative c {
627     \clef bass
628     \once \override Slur #'positions = #'(1.5 . 1)
629     e8[(_"15.39" f] g[ a b d,)] r4
630 }
631 @end lilypond
632
633 The
634 second one is nicer, but the slur doesn't start or end on the noteheads.
635 It gets 1.71 points for the left side and 9.37 points for the right
636 side, plus another 2 points because the slur ascends while the melody
637 descends for a total of 13.08 ulgy points:
638
639 @lilypond
640 \relative c {
641     \clef bass
642     \once \override Slur #'positions = #'(2 . 3)
643     e8[(_"13.08" f] g[ a b d,)] r4
644 }
645 @end lilypond
646
647 The final slur gets 10.04
648 points for the gap on the right and 2 points for the upward slope, but
649 it is the most attractive of the three configurations, so LilyPond
650 selects this one:
651
652 @lilypond
653 \relative c {
654     \clef bass
655     e8[(_"12.04" f] g[ a b d,)] r4
656 }
657 @end lilypond
658
659 This technique is quite general, and is used to make optimal decisions
660 for beam configurations, ties and dots in chords, line breaks, and page
661 breaks. The results of these decisions can be judged by comparison to
662 real engravings.
663
664 @node Improvement by benchmarking
665 @unnumberedsubsec Improvement by benchmarking
666
667 LilyPond's output has improved gradually over time, and it continues to
668 improve by comparing its output to hand-engraved scores.
669
670 For example, here is one line of a benchmark piece from a
671 hand-engraved edition (Bärenreiter BA320):
672
673 @iftex
674 @sourceimage{baer-sarabande-hires,16cm,,}
675 @end iftex
676 @ifnottex
677 @sourceimage{baer-sarabande,,,png}
678 @end ifnottex
679
680 @noindent
681 and the same quotation as engraved by a very old version of LilyPond
682 (version 1.4, May 2001):
683
684 @iftex
685 @sourceimage{pdf/lily14-sarabande,16cm,,}
686 @end iftex
687 @ifnottex
688 @sourceimage{lily14-sarabande,,,png}
689 @end ifnottex
690
691 @noindent The LilyPond 1.4 output is certainly readable, but close
692 comparison with the hand-engraved score showed a lot of errors in the
693 formatting details:
694
695 @iftex
696 @sourceimage{lily14-sarabande-annotated-hires,16cm,,}
697 @end iftex
698 @ifnottex
699 @sourceimage{lily14-sarabande-annotated,,,png}
700 @end ifnottex
701
702 @itemize @bullet
703 @item there is too much space before the time signature
704 @item the stems of the beamed notes are too long
705 @item the second and fourth measures are too narrow
706 @item the slur is awkward-looking
707 @item the trill marks are too big
708 @item the stems are too thin
709 @end itemize
710
711 @noindent
712 (There were also two missing noteheads, several missing editorial
713 annotations, and an incorrect pitch!)
714
715 By adjusting the layout rules and font design, the output has improved
716 considerably. Compare the same reference score and the output
717 from the current version of LilyPond (@version{}):
718
719 @iftex
720 @sourceimage{baer-sarabande-hires,16cm,,}
721 @end iftex
722 @ifnottex
723 @sourceimage{baer-sarabande,,,png}
724 @end ifnottex
725
726 @lilypond[staffsize=17.5,line-width=15.9\cm]
727 \relative c {
728   \clef "bass"
729   \key d \minor
730   \time 3/4
731   \mergeDifferentlyDottedOn
732   << {\slurDashed d8.-\flageolet( e16) e4.-\trill( d16 e)}
733      \\ {d4_2 a2}
734   >>
735   \slurDashed
736   <f' a, d,>4. e8( d c)
737   \slurSolid
738   bes g' f e16( f g_1 a_2 bes_3 d,_2)
739   \slurDashed
740   cis4.-\trill b8_3( a g)
741   << {\slurDashed d'8.( e16) e4.-\trill( d16 e)}
742      \\ {<f, a>4 a2}
743   >>
744 }
745 @end lilypond
746
747 @noindent
748 The current output is not a clone of the reference edition, but it is
749 much closer to publication quality that the earlier output.
750
751 @node Getting things right
752 @unnumberedsubsec Getting things right
753
754 We can also measure LilyPond's ability to make music engraving decisions
755 automatically by comparing LilyPond's output to the output of a
756 commercial software product. In this case we have chosen Finale 2008,
757 which is one of the most popular commercial scorewriters, particularly
758 in North America. Sibelius is their major rival and they appear to be
759 especially strong in the European market.
760
761 For our comparison we chose Bach's Fugue in G minor from the
762 Well-Tempered Clavier, Book I, BWV 861, whose opening subject is
763
764 @lilypond
765 \relative c' {
766   \key g \minor
767   \clef "treble_8"
768   r8 d ees g, fis4 g
769   r8 a16 bes c8 bes16 a bes8
770 }
771 @end lilypond
772
773 @noindent
774
775 We made our comparison by engraving the last seven measures of the piece
776 (28--34) in Finale and LilyPond. This is the point in the piece where
777 the subject returns in a three-part stretto and leads into the closing
778 section. In the Finale version, we have resisted the temptation to make
779 any adjustments to the default output because we are trying to show the
780 things that each software package gets right without assistance.
781
782 Many of the differences between the two engravings are visible in
783 measures 28--29, as shown here with Finale first and LilyPond second:
784
785 @iftex
786 @sourceimage{pdf/bwv861mm28-29,14cm,,}
787 @end iftex
788 @ifnottex
789 @sourceimage{bwv861mm28-29,,,png}
790 @end ifnottex
791
792 @lilypond[staffsize=19.5,line-width=14\cm]
793 global = {\key g \minor}
794
795 partI = \relative c' {
796   \voiceOne
797   fis8 d' ees g, fis4 g
798   r8 a16 bes c8 bes16 a d8 r r4
799 }
800
801 partII = \relative c' {
802   \voiceTwo
803   d4 r4 r8 d'16 c bes8 c16 d
804   ees8 d c ees a, r r4
805 }
806 partIII = \relative c' {
807   \voiceOne
808   r2 r8 d ees g, fis4 g r8 a16 bes c8 bes16 a
809 }
810 partIV = \relative c {
811   \voiceTwo
812   d4 r r2
813   r8 d ees g, fis4 a
814 }
815
816 \score {
817   <<
818     % \set Score.barNumberVisibility = #all-bar-numbers-visible
819     % required in 2.13
820     \set Score.currentBarNumber = #28
821     \bar ""
822     \new PianoStaff <<
823       \new Staff = "RH" <<
824         \global
825         \new Voice = "voiceI" { \partI }
826         \new Voice = "voiceII" { \partII }
827       >>
828
829       \new Staff = "LH" <<
830         \clef "bass"
831         \global
832         \new Voice = "voiceIII" { \partIII }
833         \new Voice = "voiceIV" { \partIV }
834       >>
835     >>
836   >>
837   \layout {
838     \context {
839       \Staff
840       \remove "Time_signature_engraver"
841     }
842     \context {
843       \PianoStaff
844       \override StaffGrouper #'between-staff-spacing #'padding = #1
845     }
846   }
847 }
848 @end lilypond
849
850 Some shortcomings in the unedited Finale output include:
851 @itemize @bullet
852 @item Most of the beams extend too far off the staff. A beam that points
853 towards the center of the staff should have a length of about one
854 octave, but engravers shorten this when the beam points away from the
855 staff in multi-voice music. The Finale beaming can be easily improved
856 with the Patterson Beams plug-in, but we elected to skip that step for
857 this example.
858 @item Finale doesn't adjust the positions of interlocking noteheads,
859 which makes the music extremely difficult to read when the upper and
860 lower voices exchange positions temporarily:
861
862 @lilypond
863 collide = \once \override NoteColumn #'force-hshift = #0
864 \new Score <<
865   \new Voice = "sample" \relative c''{
866     \key g \minor
867     <<
868       {\voiceOne g4 \collide g4}
869       \new Voice {\voiceTwo bes \collide bes}
870     >>
871   }
872   \new Lyrics \lyricsto "sample" \lyricmode { "good " " bad" }
873 >>
874 @end lilypond
875
876 @item Finale has placed all of the rests at fixed heights on the staff.
877 The user is free to adjust them as needed, but the software makes no
878 attempt to consider the content of the other voice. As luck would have
879 it, there are no true collsions between notes and rests in this example,
880 but that has more to do with the positions of the notes than the rest.
881 In other words, Bach deserves more credit for avoiding a complete
882 collision that Finale does.
883
884 @end itemize
885
886 This example is not intended to suggest that Finale cannot be used to
887 produce beautiful output. On the contrary, in the hands of a skilled
888 user it can and does, but it requires skill and time. One of the
889 fundamental differences between LilyPond and commercial scorewriters is
890 that LilyPond hopes to reduce the amount of human intervention to an
891 absolute minimum, while other packages try to provide an attractive
892 interface in which to make these types of edits.
893
894 One particularly glaring omission we found in the Finale sample is a
895 missing flat in measure 33:
896
897 @quotation
898 @iftex
899 @sourceimage{pdf/bwv861mm33-34-annotate,7.93cm,,}
900 @end iftex
901 @ifnottex
902 @sourceimage{bwv861mm33-34-annotate,,,png}
903 @end ifnottex
904 @end quotation
905
906 @noindent
907 The flat symbol is required to cancel out the natural in the same
908 measure, but Finale misses it because it occurred in a different voice.
909 The user must not only remember to run a beaming plug-in and respace the
910 noteheads and rests, she must also check each measure for cross-voice
911 accidentals if she is to avoid interrupting a rehearsal for an engraving
912 error.
913
914 If you are interested in examining these examples in more detail, the
915 full seven-measure excerpt can be found at the end of this essay in
916 engravings by Finale and LilyPond along with four different published
917 engravings. Close examination reveals that there is some acceptible
918 variation among the hand-engravings, but that LilyPond compares
919 reasonably well to that acceptible range. There are still some
920 shortcomings in the LilyPond output, for example, it appears a bit too
921 agressive in shortening some of the stems, so there is room for further
922 development and fine-tuning.
923
924 Of course, typography relies on human judgment of appearance, so people
925 cannot be replaced completely. However, much of the dull work can be
926 automated. If LilyPond solves most of the common situations correctly,
927 this will be a huge improvement over existing software. Over the course
928 of years, the software can be refined to do more and more things
929 automatically, so manual overrides are less and less necessary. Where
930 manual adjustments are needed, LilyPond's structure has been designed
931 with that flexibility in mind.
932
933 @node Flexible architecture
934 @unnumberedsubsec Flexible architecture
935
936 When we started, we wrote the LilyPond program entirely in the C++
937 programming language; the program's functionality was set in stone
938 by the developers.  That proved to be unsatisfactory for a number
939 of reasons:
940
941 @itemize
942
943 @item When LilyPond makes mistakes, users need to override
944 formatting decisions.  Therefore, the user must have access to the
945 formatting engine.  Hence, rules and settings cannot be fixed by
946 us at compile-time but must be accessible for users at run-time.
947
948 @item Engraving is a matter of visual judgment, and therefore a
949 matter of taste.  As knowledgeable as we are, users can disagree
950 with our personal decisions.  Therefore, the definitions of
951 typographical style must also be accessible to the user.
952
953 @item Finally, we continually refine the formatting algorithms, so
954 we need a flexible approach to rules.  The C++ language forces a
955 certain method of grouping rules that cannot readily be applied to
956 formatting music notation.
957
958 @end itemize
959
960 @cindex Scheme programming language
961
962 These problems have been addressed by integrating an interpreter
963 for the Scheme programming language and rewriting parts of
964 LilyPond in Scheme.  The current formatting architecture is built
965 around the notion of graphical objects, described by Scheme
966 variables and functions.  This architecture encompasses formatting
967 rules, typographical style and individual formatting decisions.
968 The user has direct access to most of these controls.
969
970 Scheme variables control layout decisions.  For example, many
971 graphical objects have a direction variable that encodes the
972 choice between up and down (or left and right).  Here you see two
973 chords, with accents and arpeggios.  In the first chord, the
974 graphical objects have all directions down (or left).  The second
975 chord has all directions up (right).
976
977 @lilypond[quote,ragged-right]
978 \new Score \with {
979    \override SpacingSpanner #'spacing-increment = #3
980    \override TimeSignature #'transparent = ##t
981 } \relative c' {
982    \stemDown <e g b>4_>-\arpeggio
983    \override Arpeggio #'direction = #RIGHT
984    \stemUp <e g b>4^>-\arpeggio
985 }
986 @end lilypond
987
988 @cindex score formatting
989 @cindex formatting a score
990 @cindex formatting rules
991
992 @noindent
993 The process of formatting a score consists of reading and writing
994 the variables of graphical objects.  Some variables have a preset
995 value.  For example, the thickness of many lines -- a
996 characteristic of typographical style -- is a variable with a
997 preset value.  You are free to alter this value, giving your score
998 a different typographical impression.
999
1000 @lilypond[quote,ragged-right]
1001 fragment = {
1002    \clef bass f8 as8
1003    c'4-~ c'16 as g f e16 g bes c' des'4
1004 }
1005 <<
1006    \new Staff \fragment
1007    \new Staff \with {
1008       \override Beam #'beam-thickness = #0.3
1009       \override Stem #'thickness = #0.5
1010       \override Bar #'thickness = #3.6
1011       \override Tie #'thickness = #2.2
1012       \override StaffSymbol #'thickness = #3.0
1013       \override Tie #'extra-offset = #'(0 .  0.3)
1014       }
1015       \fragment
1016 >>
1017 @end lilypond
1018
1019 Formatting rules are also preset variables: each object has
1020 variables containing procedures.  These procedures perform the
1021 actual formatting, and by substituting different ones, we can
1022 change the appearance of objects.  In the following example, the
1023 rule governing which note head objects are used to produce the
1024 note head symbol is changed during the music fragment.
1025
1026 @lilypond[quote,ragged-right]
1027 #(set-global-staff-size 30)
1028
1029 #(define (mc-squared grob orig current)
1030   (let* ((interfaces (ly:grob-interfaces grob))
1031          (pos (ly:grob-property grob 'staff-position)))
1032     (if (memq 'note-head-interface interfaces)
1033         (begin
1034           (ly:grob-set-property! grob 'stencil
1035             (grob-interpret-markup grob
1036               (make-lower-markup 0.5
1037                 (case pos
1038                   ((-5) "m")
1039                   ((-3) "c ")
1040                   ((-2) (make-smaller-markup (make-bold-markup "2")))
1041                   (else "bla")))))))))
1042
1043 \new Voice \relative c' {
1044   \stemUp
1045   \set autoBeaming = ##f
1046   \time 2/4
1047   <d f g>4
1048   \once \override NoteHead #'stencil = #note-head::brew-ez-stencil
1049   \once \override NoteHead #'font-size = #-7
1050   \once \override NoteHead #'font-family = #'sans
1051   \once \override NoteHead #'font-series = #'bold
1052   <d f g>4
1053   \once \override NoteHead #'style = #'cross
1054   <d f g>4
1055   \applyOutput #'Voice #mc-squared
1056   <d f g>4
1057   <<
1058     { d8[ es-( fis^^ g] fis2-) }
1059     \repeat unfold 5 { \applyOutput #'Voice #mc-squared s8 }
1060   >>
1061 }
1062 @end lilypond
1063
1064
1065 @node What symbols to engrave?
1066 @unnumberedsec What symbols to engrave?
1067
1068 @cindex engraving
1069 @cindex typography
1070 @cindex engraver
1071 @cindex plug-in
1072
1073 The formatting process decides where to place symbols.  However,
1074 this can only be done once it is decided @emph{what} symbols
1075 should be printed -- in other words, what notation to use.
1076
1077 Common music notation is a system of recording music that has
1078 evolved over the past 1000 years.  The form that is now in common
1079 use dates from the early Renaissance.  Although the basic form
1080 (i.e., note heads on a 5-line staff) has not changed, the details
1081 still evolve to express the innovations of contemporary notation.
1082 Hence, common music notation encompasses some 500 years of music.
1083 Its applications range from monophonic melodies to monstrous
1084 counterpoints for a large orchestra.
1085
1086 How can we get a grip on such a seven-headed beast, and force it
1087 into the confines of a computer program?  Our solution is to break
1088 up the problem of notation (as opposed to engraving, i.e.,
1089 typography) into digestible and programmable chunks: every type of
1090 symbol is handled by a separate module, a so-called plug-in.  Each
1091 plug-in is completely modular and independent, so each can be
1092 developed and improved separately.  Such plug-ins are called
1093 @code{engraver}s, by analogy with craftsmen who translate musical
1094 ideas to graphic symbols.
1095
1096 In the following example, we start out with a plug-in for note
1097 heads, the @code{Note_heads_engraver}.
1098
1099 @lilypond[quote,ragged-right]
1100 \include "engraver-example.ily"
1101
1102 \score {
1103   \topVoice
1104   \layout {
1105     \context {
1106       \Voice
1107       \remove "Stem_engraver"
1108       \remove "Phrasing_slur_engraver"
1109       \remove "Slur_engraver"
1110       \remove "Script_engraver"
1111       \remove "Beam_engraver"
1112       \remove "Auto_beam_engraver"
1113     }
1114     \context {
1115       \Staff
1116       \remove "Accidental_engraver"
1117       \remove "Key_engraver"
1118       \remove "Clef_engraver"
1119       \remove "Bar_engraver"
1120       \remove "Time_signature_engraver"
1121       \remove "Staff_symbol_engraver"
1122       \consists "Pitch_squash_engraver"
1123     }
1124   }
1125 }
1126 @end lilypond
1127
1128 @noindent
1129 Then a @code{Staff_symbol_engraver} adds the staff,
1130
1131 @lilypond[quote,ragged-right]
1132 \include "engraver-example.ily"
1133
1134 \score {
1135   \topVoice
1136   \layout {
1137     \context {
1138       \Voice
1139       \remove "Stem_engraver"
1140       \remove "Phrasing_slur_engraver"
1141       \remove "Slur_engraver"
1142       \remove "Script_engraver"
1143       \remove "Beam_engraver"
1144       \remove "Auto_beam_engraver"
1145     }
1146     \context {
1147       \Staff
1148       \remove "Accidental_engraver"
1149       \remove "Key_engraver"
1150       \remove "Clef_engraver"
1151       \remove "Bar_engraver"
1152       \consists "Pitch_squash_engraver"
1153       \remove "Time_signature_engraver"
1154     }
1155   }
1156 }
1157 @end lilypond
1158
1159 @noindent
1160 the @code{Clef_engraver} defines a reference point for the staff,
1161
1162 @lilypond[quote,ragged-right]
1163 \include "engraver-example.ily"
1164
1165 \score {
1166   \topVoice
1167   \layout {
1168     \context {
1169       \Voice
1170       \remove "Stem_engraver"
1171       \remove "Phrasing_slur_engraver"
1172       \remove "Slur_engraver"
1173       \remove "Script_engraver"
1174       \remove "Beam_engraver"
1175       \remove "Auto_beam_engraver"
1176     }
1177     \context {
1178       \Staff
1179       \remove "Accidental_engraver"
1180       \remove "Key_engraver"
1181       \remove "Bar_engraver"
1182       \remove "Time_signature_engraver"
1183     }
1184   }
1185 }
1186 @end lilypond
1187
1188 @noindent
1189 and the @code{Stem_engraver} adds stems.
1190
1191 @lilypond[quote,ragged-right]
1192 \include "engraver-example.ily"
1193
1194 \score {
1195   \topVoice
1196   \layout {
1197     \context {
1198       \Voice
1199       \remove "Phrasing_slur_engraver"
1200       \remove "Slur_engraver"
1201       \remove "Script_engraver"
1202       \remove "Beam_engraver"
1203       \remove "Auto_beam_engraver"
1204     }
1205     \context {
1206       \Staff
1207       \remove "Accidental_engraver"
1208       \remove "Key_engraver"
1209       \remove "Bar_engraver"
1210       \remove "Time_signature_engraver"
1211     }
1212   }
1213 }
1214 @end lilypond
1215
1216 @noindent
1217 The @code{Stem_engraver} is notified of any note head coming
1218 along.  Every time one (or more, for a chord) note head is seen, a
1219 stem object is created and connected to the note head.  By adding
1220 engravers for beams, slurs, accents, accidentals, bar lines, time
1221 signature, and key signature, we get a complete piece of notation.
1222
1223 @lilypond[quote,ragged-right]
1224 \include "engraver-example.ily"
1225 \score { \topVoice }
1226 @end lilypond
1227
1228 @cindex polyphony
1229 @cindex engraving multiple voices
1230 @cindex contexts
1231
1232 This system works well for monophonic music, but what about
1233 polyphony?  In polyphonic notation, many voices can share a staff.
1234
1235 @lilypond[quote,ragged-right]
1236 \include "engraver-example.ily"
1237 \new Staff << \topVoice \\ \botVoice >>
1238 @end lilypond
1239
1240 In this situation, the accidentals and staff are shared, but the
1241 stems, slurs, beams, etc., are private to each voice.  Hence,
1242 engravers should be grouped.  The engravers for note heads, stems,
1243 slurs, etc., go into a group called @q{Voice context,} while the
1244 engravers for key, accidental, bar, etc., go into a group called
1245 @q{Staff context.}  In the case of polyphony, a single Staff
1246 context contains more than one Voice context.  Similarly, multiple
1247 Staff contexts can be put into a single Score context.  The Score
1248 context is the top level notation context.
1249
1250
1251 @seealso
1252 Internals Reference: @rinternals{Contexts}.
1253
1254
1255 @lilypond[quote,ragged-right]
1256 \include "engraver-example.ily"
1257 \score {
1258    <<
1259       \new Staff << \topVoice \\ \botVoice >>
1260       \new Staff << \pah \\ \hoom >>
1261    >>
1262 }
1263 @end lilypond
1264
1265
1266 @node Music representation
1267 @unnumberedsec Music representation
1268
1269 @cindex syntax
1270 @cindex recursive structures
1271
1272 Ideally, the input format for any high-level formatting system is
1273 an abstract description of the content.  In this case, that would
1274 be the music itself.  This poses a formidable problem: how can we
1275 define what music really is? Instead of trying to find an answer,
1276 we have reversed the question.  We write a program capable of
1277 producing sheet music, and adjust the format to be as lean as
1278 possible.  When the format can no longer be trimmed down, by
1279 definition we are left with content itself.  Our program serves as
1280 a formal definition of a music document.
1281
1282 The syntax is also the user-interface for LilyPond, hence it is
1283 easy to type:
1284
1285 @example
1286 @{
1287   c'4 d'8
1288 @}
1289 @end example
1290
1291 @noindent
1292 to create a quarter note on middle C (C1) and an eighth note on
1293 the D above middle C (D1).
1294
1295 @lilypond[quote]
1296 {
1297   c'4 d'8
1298 }
1299 @end lilypond
1300
1301 On a microscopic scale, such syntax is easy to use.  On a larger
1302 scale, syntax also needs structure.  How else can you enter
1303 complex pieces like symphonies and operas?  The structure is
1304 formed by the concept of music expressions: by combining small
1305 fragments of music into larger ones, more complex music can be
1306 expressed.  For example
1307
1308 @lilypond[quote,verbatim,fragment,relative=1]
1309 f4
1310 @end lilypond
1311
1312 @noindent
1313 Simultaneous notes can be constructed by enclosing them with
1314 @code{<<} and @code{>>}:
1315
1316 @example
1317 <<c4 d4 e4>>
1318 @end example
1319
1320 @lilypond[quote,fragment,relative=1]
1321 \new Voice { <<c4 d4 e>> }
1322 @end lilypond
1323
1324 @noindent
1325 This expression is put in sequence by enclosing it in curly braces
1326 @code{@{@tie{}@dots{}@tie{}@}}:
1327
1328 @example
1329 @{ f4 <<c4 d4 e4>> @}
1330 @end example
1331
1332 @lilypond[quote,relative=1,fragment]
1333 { f4 <<c d e4>> }
1334 @end lilypond
1335
1336 @noindent
1337 The above is also an expression, and so it may be combined again
1338 with another simultaneous expression (a half note) using
1339 @code{<<}, @code{\\}, and @code{>>}:
1340
1341 @example
1342 << g2 \\ @{ f4 <<c4 d4 e4>> @} >>
1343 @end example
1344
1345 @lilypond[quote,fragment,relative=2]
1346 \new Voice { << g2 \\ { f4 <<c d e>> } >> }
1347 @end lilypond
1348
1349 Such recursive structures can be specified neatly and formally in
1350 a context-free grammar.  The parsing code is also generated from
1351 this grammar.  In other words, the syntax of LilyPond is clearly
1352 and unambiguously defined.
1353
1354 User-interfaces and syntax are what people see and deal with most.
1355 They are partly a matter of taste, and also the subject of much
1356 discussion.  Although discussions on taste do have their merit,
1357 they are not very productive.  In the larger picture of LilyPond,
1358 the importance of input syntax is small: inventing neat syntax is
1359 easy, while writing decent formatting code is much harder.  This
1360 is also illustrated by the line-counts for the respective
1361 components: parsing and representation take up less than 10% of
1362 the source code.
1363
1364
1365 @node Example applications
1366 @unnumberedsec Example applications
1367
1368 @cindex simple examples
1369 @cindex examples, simple
1370
1371 We have written LilyPond as an experiment of how to condense the
1372 art of music engraving into a computer program.  Thanks to all
1373 that hard work, the program can now be used to perform useful
1374 tasks.  The simplest application is printing notes.
1375
1376 @lilypond[quote,relative=1]
1377 {
1378   \time 2/4
1379   c4 c g'4 g a4 a g2
1380 }
1381 @end lilypond
1382
1383 @noindent
1384 By adding chord names and lyrics we obtain a lead sheet.
1385
1386 @lilypond[quote,ragged-right]
1387 <<
1388    \chords { c2 c f2 c }
1389    \new Staff
1390    \relative c' {
1391      \time 2/4
1392      c4 c g' g a a g2
1393    }
1394    \addlyrics { twin -- kle twin -- kle lit -- tle star }
1395 >>
1396 @end lilypond
1397
1398 Polyphonic notation and piano music can also be printed.  The
1399 following example combines some more exotic constructs.
1400
1401 @lilypond[quote]
1402 \header {
1403   title = "Screech and boink"
1404   subtitle = "Random complex notation"
1405   composer = "Han-Wen Nienhuys"
1406 }
1407
1408 \score {
1409   \context PianoStaff <<
1410     \new Staff = "up" {
1411       \time 4/8
1412       \key c \minor
1413       << {
1414         \revert Stem #'direction
1415         \change Staff = down
1416         \set subdivideBeams = ##t
1417         g16.[
1418           \change Staff = up
1419           c'''32
1420           \change Staff = down
1421           g32
1422           \change Staff = up
1423           c'''32
1424           \change Staff = down
1425           g16]
1426         \change Staff = up
1427         \stemUp
1428         \set followVoice = ##t
1429         c'''32([ b''16 a''16 gis''16 g''32)]
1430       } \\ {
1431         s4 \times 2/3 { d'16[ f' g'] } as'32[ b''32 e'' d'']
1432       } \\ {
1433         s4 \autoBeamOff d''8.. f''32
1434       } \\ {
1435         s4 es''4
1436       } >>
1437     }
1438
1439     \new Staff = "down" {
1440       \clef bass
1441       \key c \minor
1442       \set subdivideBeams = ##f
1443       \override Stem  #'french-beaming = ##t
1444       \override Beam  #'beam-thickness = #0.3
1445       \override Stem  #'thickness = #4.0
1446       g'16[ b16 fis16 g16]
1447       << \makeClusters {
1448         as16 <as b>
1449         <g b>
1450         <g cis>
1451       } \\ {
1452         \override Staff.Arpeggio  #'arpeggio-direction =#down
1453         <cis, e, gis, b, cis>4\arpeggio
1454       }
1455     >> }
1456   >>
1457   \midi {
1458     \context {
1459       \Score
1460       tempoWholesPerMinute = #(ly:make-moment 60 8)
1461     }
1462   }
1463   \layout {
1464     \context {
1465       \Staff
1466       \consists Horizontal_bracket_engraver
1467     }
1468   }
1469 }
1470 @end lilypond
1471
1472 The fragments shown above have all been written by hand, but that
1473 is not a requirement.  Since the formatting engine is mostly
1474 automatic, it can serve as an output means for other programs that
1475 manipulate music.  For example, it can also be used to convert
1476 databases of musical fragments to images for use on websites and
1477 multimedia presentations.
1478
1479 This manual also shows an application: the input format is text,
1480 and can therefore be easily embedded in other text-based formats
1481 such as @LaTeX{}, HTML, or in the case of this manual, Texinfo.
1482 By means of a special program, the input fragments can be replaced
1483 by music images in the resulting PDF or HTML output files.  This
1484 makes it easy to mix music and text in documents.
1485
1486
1487 TODO: add extra chapter for computer aesthetics?
1488
1489 @page
1490 @node Appendix
1491 @unnumberedsec Appendix
1492
1493 This appendix contaions four reference engravings and two
1494 software-engraved versions of Bach's Fugue in G minor from the
1495 Well-Tempered Clavier, Book I, BWV 861 (the last seven measures).
1496
1497 @noindent
1498 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1499 1989):
1500
1501 @iftex
1502 @sourceimage{bwv861-baer,16cm,,}
1503 @end iftex
1504 @ifnottex
1505 @sourceimage{bwv861-baer-small,,,png}
1506 @end ifnottex
1507
1508 @noindent
1509 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1510 1989), an alternate musical source. Aside from the textual differences,
1511 this demsontrates slight variations in the engraving decisions, even
1512 from the same publisher and edition:
1513
1514 @iftex
1515 @sourceimage{bwv861-baer-alt,16cm,,}
1516 @end iftex
1517 @ifnottex
1518 @sourceimage{bwv861-baer-alt-small,,,png}
1519 @end ifnottex
1520
1521 @noindent
1522 Breitkopf & Härtel, edited by Ferruccio Busoni (Wiesbaden, 1894), also
1523 available from the Petrucci Music Library (IMSLP #22081). The editorial
1524 markings (fingerings, articulations, etc.) have been removed for clearer
1525 comparison with the other editions here:
1526
1527 @iftex
1528 @sourceimage{bwv861-breitkopf,16cm,,}
1529 @end iftex
1530 @ifnottex
1531 @sourceimage{bwv861-breitkopf-small,,,png}
1532 @end ifnottex
1533
1534 @noindent
1535 Bach-Gessellschaft edition (Leipzig, 1866), available from the Petrucci
1536 Music Library (IMSPL #02221):
1537
1538 @iftex
1539 @sourceimage{bwv861-gessellschaft,16cm,,}
1540 @end iftex
1541 @ifnottex
1542 @sourceimage{bwv861-gessellschaft-small,,,png}
1543 @end ifnottex
1544
1545 @noindent
1546 Finale 2008:
1547
1548 @iftex
1549 @sourceimage{pdf/bwv861-finale2008a,,,}
1550 @end iftex
1551 @ifnottex
1552 @sourceimage{bwv861-finale2008a,,,png}
1553 @end ifnottex
1554
1555 @sp 4
1556 @noindent
1557 LilyPond, version @version{}:
1558
1559 @lilypond[staffsize=14.3,line-width=15.9\cm]
1560 global = {\key g \minor}
1561
1562 partI = \relative c' {
1563   \voiceOne
1564   fis8 d' ees g, fis4 g
1565   r8 a16 bes c8 bes16 a d8 r r4
1566   r2 r8 d16 ees f8 ees16 d
1567   ees4 ~ ees16 d c bes a4 r8 ees'16 d
1568   c8 d16 ees d8 e16 fis g8 fis16 g a4 ~
1569   a8 d, g f ees d c bes
1570   a2 g\fermata \bar "|."
1571 }
1572
1573 partII = \relative c' {
1574   \voiceTwo
1575   d4 r4 r8 d'16 c bes8 c16 d
1576   ees8 d c ees a, r r4
1577   r8 fis16 g a8 g16 fis g2 ~
1578   g2 r8 d' ees g,
1579   fis4 g r8 a16 bes c8 bes16 a
1580   bes4. <g b>8 <a c> r <d, g> r
1581   <ees g>4 <d fis> d2
1582 }
1583 partIII = \relative c' {
1584   \voiceOne
1585   r2 r8 d ees g, fis4 g r8 a16 bes c8 bes16 a
1586   bes2 ~ bes8 b16 a g8 a16 b
1587   c4 r r2
1588   R1
1589   r8 d ees g, fis4 g
1590   r8 a16 bes c8 bes16 a b2
1591 }
1592 partIV = \relative c {
1593   \voiceTwo
1594   d4 r r2
1595   r8 d ees g, fis4 a
1596   d,8 d'16 c bes8 c16 d ees2 ~
1597   ees8 ees16 d c8 d16 ees fis,8 a16 g fis8 g16 a
1598   d,8 d'16 c bes8 c16 d ees8 c a fis'
1599   g f ees d c bes a g
1600   c a d d, g2\fermata
1601 }
1602
1603 \score {
1604   <<
1605     % \set Score.barNumberVisibility = #all-bar-numbers-visible
1606     % required in 2.13
1607     \set Score.currentBarNumber = #28
1608     \bar ""
1609     \new PianoStaff <<
1610       \new Staff = "RH" <<
1611         \global
1612         \new Voice = "voiceI" { \partI }
1613         \new Voice = "voiceII" { \partII }
1614       >>
1615
1616       \new Staff = "LH" <<
1617         \clef "bass"
1618         \global
1619         \new Voice = "voiceIII" { \partIII }
1620         \new Voice = "voiceIV" { \partIV }
1621       >>
1622     >>
1623   >>
1624   \layout {
1625     \context {
1626       \Staff
1627       \remove "Time_signature_engraver"
1628     }
1629     \context {
1630       \PianoStaff
1631       \override StaffGrouper #'between-staff-spacing #'padding = #1
1632     }
1633   }
1634 }
1635 @end lilypond