1 @c -*- coding: utf-8; mode: texinfo; -*-
4 Translation of GIT committish: e5d3fb33ceaec6d10e06af0c667e4e982a0028ce
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..
14 @chapter A kottaszedés
15 @translationof Music engraving
17 Ez az esszé leírja, miért született a LilyPond, és hogyan képes ilyen gyönyörű kottákat előállítani.
21 @c remove 3mm eps bounding box left padding for Sarabande (This will
22 @c require adding a new snippet option to lilypond-book.py
23 @c check formatting of HTML output
26 * A LilyPond története::
27 * A kottaszedés fortélyai::
28 * Automated engraving::
30 * Putting LilyPond to work::
31 * Engraved examples (BWV 861)::
34 @node A LilyPond története
35 @section A LilyPond története
36 @translationof The LilyPond story
38 Mielőtt a LilyPondot koncerteken használt csodaszép kották szedésére kezdtük volna használni, mielőtt zenetudományi dokumentumok zenei idézeteit vagy akár egyszerű dallamokat le lehetett volna vele kottázni, mielőtt szerte a világon a felhasználók széles körben kezdték volna használni, vagy ez az esszé megszületett volna, a LilyPond története egy kérdéssel kezdődött:
41 Miért nem adják vissza a számítógép által szedett kották a kézzel szedett kották szépségét és kiegyensúlyozottságát?
45 Erre többnyire választ kaphatunk, ha górcső alá vesszük a következő két kottát. Az első példa egy gondosan kézzel szedett kotta 1950-ből, a második egy modern, számítógéppel szedett kiadás.
50 Bärenreiter BA 320, @copyright{}1950:
52 @sourceimage{baer-suite1-fullpage,,,png}
57 Henle no. 666, @copyright{}2000:
59 @sourceimage{henle-suite1-fullpage,,,png}
63 J. S. Bach első, csellóra írt szólószvitjének két kiadása hangról hangra megegyezik, mégis megjelenésükben merőben különbözőek, különösen, ha kinyomtatjuk és megszokott távolságból szemléljük őket. Próbáljuk meg mindkét kottapéldát elolvasni, illetve játszani belőlük, és meg fogjuk állapítani, hogy a kézzel szedett kotta használata kellemesebb. Folyékonysága és dinamikája egy élő, lélegző zenemű érzetét kelti, miközben az újabb kiadás hidegnek és mechanikusnak hat.
65 Nehéz egyből észrevenni, miben rejlik a különbség a kották között. Az új kotta első ránézésre rendezett és pontos, talán még „jobb” is, mivel számítógéphez illőbb és egységes a megjelenése. Ez gondolkodóba ejtett minket egy időre. Javítani akartunk a számítógép által szedett kottaképen, de ehhez előbb rá kellett jönnünk, mi volt a gond vele.
67 A válasz az új kotta precíz, matematikai pontosságú egyformaságában rejlik. Keressük csak meg minden sor közepén az ütemvonalakat: a kézzel szedett változatban az ütemvonalak elhelyezkedése természetes módon változik, míg a számítógép szinte pontosan egymás alá, középre szedte őket. Ezt mutatja be a következő egyszerűsített ábra, melyen a kézzel (balra), ill. a komputerrel szedett változat (jobbra) elrendezése látható:
71 @sourceimage{pdf/page-layout-comparison,,,}
74 @sourceimage{page-layout-comparison,,,png}
79 A számítógép által előállított szedésben még az egyes kottafejek is függőlegesen egymáshoz lettek igazítva, ami azt az érzetet kelti, mintha a dallamvonal eltűnne egy szimbólumokból álló merev rács mögött.
81 További különbségek is vannak: a kézzel szedett változat függőleges vonalai erősebbek, a kötőívek szorosabban tapadnak a kottafejekhez, és a gerendák szögeiben is nagyobb változatosság figyelhető meg. Noha az ilyen részletes elemzés szőrszálhasogatásnak tűnhet, végeredménye egy olyan kotta, ami egyszerűbben olvasható. A számítógépes kottában minden sor szinte egyforma, és ha a zenész egy pillanatra máshová tekint, hamar elveszítheti a tájékozódást az oldalon.
83 A LilyPond megalkotásának célja az volt, hogy kiküszöböljük a többi kottaszedő szoftver szépséghibáit, és segítségével olyan kottákat lehessen előállítani, melyek szépsége a legigényesebb kézzel szedett kottákéval vetélkedik.
88 Bärenreiter BA 320, @copyright{}1950:
90 @sourceimage{baer-suite1-fullpage-hires,16cm,,}
93 Henle no. 666, @copyright{}2000:
95 @sourceimage{henle-suite1-fullpage-hires,16cm,,}
99 @node A kottaszedés fortélyai
100 @section A kottaszedés fortélyai
101 @translationof Engraving details
104 @cindex typography, music
105 @cindex music typography
106 @cindex plate engraving
107 @cindex music engraving
109 A zeneművek nyomdai előkészítését @emph{kottaszedésnek} nevezik. Ez a kifejezés a kották nyomtatásának hagyományos, kézi módszerére utal.@footnote{A régi idők nyomdászai különböző technikákat próbáltak ki, mint például a kézzel metszett fa nyomóformák (nyomódúc), a mozgatható betű- és nyomóelemek, illetve a gravírozott vékony fémlemezek. A mozgatható betű- és nyomóelemekkel való szedésnek megvolt az az előnye, hogy gyorsan bele lehetett javítani és egyszerűen lehetett szöveget is beleilleszteni. De csak a fémlemezre végzett hangjegymetszés tette lehetővé a hibátlan elrendezést és az új kottaelemek gyors bevezetését. Végül ez utóbbi technika lett a szabvány, és még a 20. század elején is ez volt a helyzet, pár korálkönyv és daloskönyv kivételével, ahol a sablonelemek használatát annak gazdaságossága és gyorsasága indokolta.} Ez a folyamat még a 20. században első felében is úgy nézett ki, hogy a kotta elemeit kivágták, majd tükrözve belemélyesztették egy cink- vagy ónlemezbe. A lemezre ezután festéket hordtak fel, és a festék a bemélyedésekben maradt. A lemez a papírra rányomva a kotta képét adta. A metszést teljesen kézzel végezték, és bárminemű javítás nagyon körülményes volt, így a kottakép elsőre tökéletes kellett, hogy legyen. A kottaszedés tudománya nagyon különleges szakma, ahol a kézművesnek körülbelül öt éves képzést kellett elvégeznie, mielőtt a mester címet kérvényezhette. További öt év volt szükséges ahhoz, hogy a szakma minden csínját-bínját valóban magáénak tudhassa.
113 @sourceimage{hader-slaan,,7cm,}
116 @sourceimage{hader-slaan,,,jpg}
120 A LilyPond megalkotását azok a kézzel szedett kották inspirálták, amelyeket a 20. század közepe felé az európai kottakiadók (többek között Bärenreiter, Duhem, Durand, Hofmeister, Peters és Schott) hoztak forgalomba. Munkásságukat bizonyos szempontból a hagyományos kottaszedés csúcsának lehet tekinteni. Kiadványaik tanulmányozásával rengeteget tanultunk arról, mik az ismertetőjelei egy szép tipográfiájú kottának, és milyen szempontokat szeretnénk a LilyPonddal utánozni.
122 @c Now all newly printed music is produced with computers. This has
123 @c obvious advantages: prints are cheaper to make, editorial work can be
124 @c delivered by email, and the original data can be easily stored.
125 @c Unfortunately, computer-generated scores rarely match the quality of
126 @c hand-engraved scores. Instead, computer printouts have a bland,
127 @c mechanical look, which makes them unpleasant to play from.
130 * A kottában használt betűtípusok::
134 * Why work so hard?::
137 @node A kottában használt betűtípusok
138 @unnumberedsubsec A kottában használt betűtípusok
139 @translationof Music fonts
141 A lenti ábra jól mutatja a különbséget egy hagyományosan és egy számítógép által szedett kottaelem közt. A bal oldali képen egy beszkennelt b módosítójel látható egy kézi Bärenreiter kiadásból, míg a jobb oldali ugyanennek a zeneműnek 2000-ben kiadott változatából származik. Noha mindkét képet ugyanolyan árnyalatú tintával nyomtatták, a régebbi verzió sötétebb: a kottasorok vonalai vastagabbak, és a Bärenreiter b-je gömbölyded, majdhogynem érzékien kerek. A jobb oldali kép vonalai ezzel szemben vékonyabbak, elrendezése szögletes, sarkai élesek.
143 @multitable @columnfractions .25 .25 .25 .25
147 @sourceimage{baer-flat-gray,,4cm,}
150 @sourceimage{baer-flat-gray,,,png}
155 @sourceimage{henle-flat-gray,,4cm,}
158 @sourceimage{henle-flat-gray,,,png}
163 @sourceimage{henle-flat-bw,,,png}
164 @sourceimage{baer-flat-bw,,,png}
165 @sourceimage{lily-flat-bw,,,png}
176 @cindex musical symbols
181 Amikor úgy döntöttük, hogy írunk egy kottaszedő programot, nem volt olyan, szabad felhasználású zenei betűtípus, ami jól passzolt volna kedvenc kottáink elegáns kottaképéhez. Ezen felbuzdulva megalkottunk egy zenei szimbólumokból álló betűtípust, amely a kézzel szedett kották szemrevaló kinézetét veszi alapul. A betűtípus megtervezése során szerzett tapasztalatok nélkül soha nem ismertük volna fel, milyen csúnyák is azok a betűtípusok, amiket eleinte csodáltunk.
183 Lent két zenei betűkészletre láthatunk példát: a felső a Sibelius alapbeállítású készlete (@emph{Opus}), az alsó a LilyPondé.
187 @sourceimage{pdf/OpusAndFeta,,,}
190 @sourceimage{OpusAndFeta,,,png}
194 A LilyPond kottaelemei vastagabbak, valamint vastagságuk konzisztensebb, ami miatt jóval egyszerűbb az olvasásuk. A vonalaknak, mint például a negyed szünet szárnyai, nem hegyes végük van, hanem finoman legömbölyített. Ennek oka, hogy a hegyes végek a hagyományos nyomóformán nagyon törékenyek, és a használat közben gyorsan elkopnak. Összefoglalva, a jelkészlet teltségét gondosan össze kell hangolni a vonalak (gerendák, ívek) vastagságával, hogy erős, mégis kiegyensúlyozott összképet kapjunk.
196 Vegyük észre továbbá, hogy a félkotta feje nem ellipszis, hanem enyhén rombusz alakú. A b módosítójel függőleges szára felfelé némileg kiszélesedik. A keresztet és a feloldójelet egyszerűbb távolról megkülönböztetni, mert ferde vonalaiknak eltérő a dőlésszöge, illetve függőleges vonalaik különböző vastagságúak.
198 @node Optical spacing
199 @unnumberedsubsec Optical spacing
201 In spacing, the distribution of space should reflect the durations
202 between notes. However, as we saw in the Bach Suite above, many modern
203 scores adhere to the durations with mathematical precision, which leads
204 to poor results. In the next example a motif is printed twice: the
205 first time using exact mathematical spacing, and the second with
206 corrections. Which do you prefer?
208 @cindex optical spacing
229 \override NoteSpacing.stem-spacing-correction = #0.0
230 \override NoteSpacing.same-direction-correction = #0.0
231 \override StaffSpacing.stem-spacing-correction = #0.0
257 \override NoteSpacing.stem-spacing-correction = #0.6
263 @cindex regular rhythms
264 @cindex regular spacing
265 @cindex spacing, regular
267 Each bar in the fragment only uses notes that are played in a constant
268 rhythm. The spacing should reflect that. Unfortunately, the eye deceives
269 us a little; not only does it notice the distance between note heads, it
270 also takes into account the distance between consecutive stems. As a
271 result, the notes of an up-stem/@/down-stem combination should be put
272 farther apart, and the notes of a down-stem/@/up-stem combination should
273 be put closer together, all depending on the combined vertical positions
274 of the notes. The lower two measures are printed with this correction,
275 the upper two measures, however, form down-stem/@/up-stem clumps of
276 notes. A master engraver would adjust the spacing as needed to please
279 The spacing algorithms in LilyPond even take the barlines into account,
280 which is why the final up-stem in the properly spaced example has been
281 given a little more space before the barline to keep it from looking
282 crowded. A down-stem would not need this adjustment.
285 @unnumberedsubsec Ledger lines
290 Ledger lines present a typographical challenge: they make it more
291 difficult to space musical symbols close together and they must be clear
292 enough to identify the pitch at a glance. In the example below, we see
293 that ledger lines should be thicker than normal staff lines and that an
294 expert engraver will shorten a ledger line to allow closer spacing with
295 accidentals. We have included this feature in LilyPond's engraving.
297 @multitable @columnfractions .25 .25 .25 .25
301 @sourceimage{baer-ledger,3cm,,}
304 @sourceimage{baer-ledger,,,png}
310 @sourceimage{lily-ledger,3cm,,}
313 @sourceimage{lily-ledger,,,png}
320 @unnumberedsubsec Optical sizing
322 Music may need to be printed in a range of sizes. Originally, this was
323 accomplished by creating punching dies in each of the required sizes,
324 which meant that each die was designed to look its best at that size.
325 With the advent of digital fonts, a single outline can be mathematically
326 scaled to any size, which is very convenient, but at the smaller sizes
327 the glyphs will appear very light.
329 In LilyPond, we have created fonts in a range of weights, corresponding
330 to a range of music sizes. This is a LilyPond engraving at staff size
335 @sourceimage{pdf/size26,,23mm,}
338 @sourceimage{size26,,,png}
343 and this is the same engraving set at staff size 11, then
344 magnified by 236% to print at the same size as the previous example:
348 @sourceimage{pdf/size11,,23mm,}
351 @sourceimage{size11,,,png}
356 At smaller sizes, LilyPond uses proportionally heavier lines so the
357 music will still read well.
359 This also allows staves of different sizes to coexist peacefully when
360 used together on the same page:
362 @c Grieg's Violin Sonata Op. 45
363 @lilypond[indent=1.5\cm]
376 \set Staff.instrumentName = #"Violin"
377 c'8.(\f^> b16 c d) ees8.(^> d16 c b)
378 g8.(^> b16 c ees) g8-.^> r r
382 \set PianoStaff.instrumentName = #"Piano"
383 \new Staff \relative {
386 s4. s8 r8 r16 <c' f aes c>
387 <c f aes c>4.^> <c ees g>8 r r
389 \new Staff \relative {
394 \once \override DynamicText.X-offset = #-3
396 <ees g c>4.~ <ees g c>8
399 <c g c,>4.~ <c g c,>8
402 r8 r16 <f, c' aes'>16
403 <f c' aes'>4.-> <c' g'>8 r r
411 @node Why work so hard?
412 @unnumberedsubsec Why work so hard?
414 Musicians are usually more absorbed with performing than with studying
415 the looks of a piece of music, so nitpicking typographical details may
416 seem academic. But it is not. Sheet music is performance material:
417 everything is done to aid the musician in letting her perform better,
418 and anything that is unclear or unpleasant to read is a hindrance.
420 Traditionally engraved music uses bold symbols on heavy staff to create
421 a strong, well-balanced look that stands out well when the music is far
422 away from the reader: for example, if it is on a music stand. A careful
423 distribution of white space allows music to be set very tightly without
424 crowding symbols together. The result minimizes the number of page
425 turns, which is a great advantage.
427 This is a common characteristic of typography. Layout should be pretty,
428 not only for its own sake, but especially because it helps the reader in
429 his task. For sheet music this is of double importance because musicians
430 have a limited amount of attention. The less attention they need for
431 reading, the more they can focus on playing the music. In other words,
432 better typography translates to better performances.
434 These examples demonstrate that music typography is an art that is
435 subtle and complex, and that producing it requires considerable
436 expertise, which musicians usually do not have. LilyPond is our
437 effort to bring the graphical excellence of hand-engraved music to
438 the computer age, and make it available to normal musicians. We
439 have tuned our algorithms, font-designs, and program settings to
440 produce prints that match the quality of the old editions we love
441 to see and love to play from.
444 @node Automated engraving
445 @section Automated engraving
447 @cindex engraving, automated
448 @cindex automated engraving
450 Here we describe what is required to create software that can mimic the
451 layout of engraved scores: a method of describing good layouts to the
452 computer and a lot of detailed comparisons with real engravings.
456 * Improvement by benchmarking::
457 * Getting things right::
460 @node Beauty contests
461 @unnumberedsubsec Beauty contests
463 How do we actually make formatting decisions? In other words, which
464 of the three configurations should we choose for the following slur?
469 \once \override Slur.positions = #'(1.5 . 1)
470 e8[( f] g[ a b d,)] r4
471 \once \override Slur.positions = #'(2 . 3)
472 e8[( f] g[ a b d,)] r4
473 e8[( f] g[ a b d,)] r4
477 There are a few books on the art of music engraving
478 available. Unfortunately, they contain simple rules of thumb and some
479 examples. Such rules can be instructive, but they are a far cry from
480 an algorithm that we could readily implement in a computer. Following
481 the instructions from literature leads to algorithms with lots of
482 hand-coded exceptions. Doing all this case analysis is a lot of work,
483 and often not all cases are covered completely:
487 @sourceimage{ross-beam-scan,7cm,,}
490 @sourceimage{ross-beam-scan,,,.jpg}
494 (Image source: Ted Ross, @emph{The Art of Music Engraving})
496 Rather than trying to write detailed layout rules for every possible
497 scenario, we only have to describe the objectives well enough that
498 LilyPond can judge the attractiveness of several alternatives. Then,
499 for each possible configuration we compute an ugliness score and we
500 choose the least ugly configuration.
502 For example, here are three possible slur configurations, and LilyPond
503 has given each one a score in @q{ugly points}. The first example gets
504 15.39 points for grazing one of the noteheads:
509 \once \override Slur.positions = #'(1.5 . 1)
510 e8[(_"15.39" f] g[ a b d,)] r4
515 second one is nicer, but the slur doesn't start or end on the note heads.
516 It gets 1.71 points for the left side and 9.37 points for the right
517 side, plus another 2 points because the slur ascends while the melody
518 descends for a total of 13.08 ugly points:
523 \once \override Slur.positions = #'(2 . 3)
524 e8[(_"13.08" f] g[ a b d,)] r4
528 The final slur gets 10.04
529 points for the gap on the right and 2 points for the upward slope, but
530 it is the most attractive of the three configurations, so LilyPond
536 e8[(_"12.04" f] g[ a b d,)] r4
540 This technique is quite general, and is used to make optimal decisions
541 for beam configurations, ties and dots in chords, line breaks, and page
542 breaks. The results of these decisions can be judged by comparison to
545 @node Improvement by benchmarking
546 @unnumberedsubsec Improvement by benchmarking
548 LilyPond's output has improved gradually over time, and it continues to
549 improve by comparing its output to hand-engraved scores.
551 For example, here is one line of a benchmark piece from a
552 hand-engraved edition (Bärenreiter BA320):
555 @sourceimage{baer-sarabande-hires,16cm,,}
558 @sourceimage{baer-sarabande,,,png}
562 and the same quotation as engraved by a very old version of LilyPond
563 (version 1.4, May 2001):
566 @sourceimage{pdf/lily14-sarabande,16cm,,}
569 @sourceimage{lily14-sarabande,,,png}
572 @noindent The LilyPond 1.4 output is certainly readable, but close
573 comparison with the hand-engraved score showed a lot of errors in the
577 @sourceimage{lily14-sarabande-annotated-hires,16cm,,}
580 @sourceimage{lily14-sarabande-annotated,,,png}
584 @item there is too much space before the time signature
585 @item the stems of the beamed notes are too long
586 @item the second and fourth measures are too narrow
587 @item the slur is awkward-looking
588 @item the trill marks are too big
589 @item the stems are too thin
593 (There were also two missing note heads, several missing editorial
594 annotations, and an incorrect pitch!)
596 By adjusting the layout rules and font design, the output has improved
597 considerably. Compare the same reference score and the output
598 from the current version of LilyPond (@version{}):
601 @sourceimage{baer-sarabande-hires,16cm,,}
604 @sourceimage{baer-sarabande,,,png}
607 @lilypond[staffsize=17.5,line-width=15.9\cm]
612 \mergeDifferentlyDottedOn
614 { \slurDashed d8.-\flageolet( e16) e4.-\trill( d16 e) }
619 <f' a, d,>4. e8( d c)
621 bes8 g' f e16( f g_1 a_2 bes_3 d,_2)
623 cis4.-\trill b8_3( a g)
625 { \slurDashed d'8.( e16) e4.-\trill( d16 e) }
633 The current output is not a clone of the reference edition, but it is
634 much closer to publication quality that the earlier output.
636 @node Getting things right
637 @unnumberedsubsec Getting things right
639 We can also measure LilyPond's ability to make music engraving decisions
640 automatically by comparing LilyPond's output to the output of a
641 commercial software product. In this case we have chosen Finale 2008,
642 which is one of the most popular commercial score writers, particularly
643 in North America. Sibelius is its major rival and appears to be
644 especially strong in the European market.
646 For our comparison we selected Bach's Fugue in G minor from the
647 Well-Tempered Clavier, Book I, BWV 861, whose opening subject is
654 r8 a16 bes c8 bes16 a bes8
660 We made our comparison by engraving the last seven measures of the piece
661 (28--34) in Finale and LilyPond. This is the point in the piece where
662 the subject returns in a three-part stretto and leads into the closing
663 section. In the Finale version, we have resisted the temptation to make
664 any adjustments to the default output because we are trying to show the
665 things that each software package gets right without assistance. The
666 only major edits that we made were adjusting the page size to match this
667 essay and forcing the music onto two systems to make the comparison
668 easier. By default Finale would have engraved two systems of three
669 measures each and a final, full-width system containing a single
672 Many of the differences between the two engravings are visible in
673 measures 28--29, as shown here with Finale first and LilyPond second:
676 @sourceimage{pdf/bwv861mm28-29,14cm,,}
679 @sourceimage{bwv861mm28-29,,,png}
682 @lilypond[staffsize=19.5,line-width=14\cm]
683 global = { \key g \minor }
687 fis'8 d' ees g, fis4 g
688 r8 a16 bes c8 bes16 a d8 r r4
693 d'4 r4 r8 d'16 c bes8 c16 d
697 partIII = \relative {
699 r2 r8 d' ees g, fis4 g r8 a16 bes c8 bes16 a
710 % \set Score.barNumberVisibility = #all-bar-numbers-visible
712 \set Score.currentBarNumber = #28
717 \new Voice = "voiceI" { \partI }
718 \new Voice = "voiceII" { \partII }
724 \new Voice = "voiceIII" { \partIII }
725 \new Voice = "voiceIV" { \partIV }
732 \remove "Time_signature_engraver"
736 \override StaffGrouper.staff-staff-spacing.padding = #1
742 Some shortcomings in the unedited Finale output include:
744 @item Most of the beams extend too far off the staff. A beam that points
745 towards the center of the staff should have a length of about one
746 octave, but engravers shorten this when the beam points away from the
747 staff in multi-voice music. The Finale beaming can easily be improved
748 with their Patterson Beams plug-in, but we elected to skip that step for
750 @item Finale doesn't adjust the positions of interlocking note heads,
751 which makes the music extremely difficult to read when the upper and
752 lower voices exchange positions temporarily:
755 collide = \once \override NoteColumn.force-hshift = #0
759 \new Voice = "sample" \relative c''{
762 { \voiceOne g4 \collide g4 }
763 \new Voice { \voiceTwo bes \collide bes }
766 \new Lyrics \lyricsto "sample" { "good " " bad" }
771 @item Finale has placed all of the rests at fixed heights on the staff.
772 The user is free to adjust them as needed, but the software makes no
773 attempt to consider the content of the other voice. As luck would have
774 it, there are no true collisions between notes and rests in this example,
775 but that has more to do with the positions of the notes than the rest.
776 In other words, Bach deserves more credit for avoiding a complete
777 collision than Finale does.
781 This example is not intended to suggest that Finale cannot be used to
782 produce publication-quality output. On the contrary, in the hands of a
783 skilled user it can and does, but it requires skill and time. One of the
784 fundamental differences between LilyPond and commercial scorewriters is
785 that LilyPond hopes to reduce the amount of human intervention to an
786 absolute minimum, while other packages try to provide an attractive
787 interface in which to make these types of edits.
789 One particularly glaring omission we found from Finale is a missing flat
794 @sourceimage{pdf/bwv861mm33-34-annotate,7.93cm,,}
797 @sourceimage{bwv861mm33-34-annotate,,,png}
802 The flat symbol is required to cancel out the natural in the same
803 measure, but Finale misses it because it occurred in a different voice.
804 So in addition to running a beaming plug-in and checking the spacing on
805 the noteheads and rests, the user must also check each measure for
806 cross-voice accidentals to avoid interrupting a rehearsal over an
809 If you are interested in examining these examples in more detail, the
810 full seven-measure excerpt can be found at the end of this essay along
811 with four different published engravings. Close examination reveals that
812 there is some acceptable variation among the hand-engravings, but that
813 LilyPond compares reasonably well to that acceptable range. There are
814 still some shortcomings in the LilyPond output, for example, it appears
815 a bit too aggressive in shortening some of the stems, so there is room
816 for further development and fine-tuning.
818 Of course, typography relies on human judgment of appearance, so people
819 cannot be replaced completely. However, much of the dull work can be
820 automated. If LilyPond solves most of the common situations correctly,
821 this will be a huge improvement over existing software. Over the course
822 of years, the software can be refined to do more and more things
823 automatically, so manual overrides are less and less necessary. Where
824 manual adjustments are needed, LilyPond's structure has been designed
825 with that flexibility in mind.
827 @node Building software
828 @section Building software
830 This section describes some of the programming decisions that we made
831 when designing LilyPond.
834 * Music representation::
835 * What symbols to engrave?::
836 * Flexible architecture::
840 @node Music representation
841 @unnumberedsubsec Music representation
844 @cindex recursive structures
846 Ideally, the input format for any high-level formatting system is
847 an abstract description of the content. In this case, that would
848 be the music itself. This poses a formidable problem: how can we
849 define what music really is? Instead of trying to find an answer,
850 we have reversed the question. We write a program capable of
851 producing sheet music, and adjust the format to be as lean as
852 possible. When the format can no longer be trimmed down, by
853 definition we are left with content itself. Our program serves as
854 a formal definition of a music document.
856 The syntax is also the user-interface for LilyPond, hence it is
866 to create a quarter note on middle C (C1) and an eighth note on
867 the D above middle C (D1).
875 On a microscopic scale, such syntax is easy to use. On a larger
876 scale, syntax also needs structure. How else can you enter
877 complex pieces like symphonies and operas? The structure is
878 formed by the concept of music expressions: by combining small
879 fragments of music into larger ones, more complex music can be
880 expressed. For example
882 @lilypond[quote,verbatim,fragment,relative=1]
887 Simultaneous notes can be constructed by enclosing them with
888 @code{<<} and @code{>>}:
894 @lilypond[quote,fragment,relative=1]
895 \new Voice { <<c4 d4 e>> }
899 This expression is put in sequence by enclosing it in curly braces
900 @code{@{@tie{}@dots{}@tie{}@}}:
903 @{ f4 <<c4 d4 e4>> @}
906 @lilypond[quote,relative=1,fragment]
911 The above is also an expression, and so it may be combined again
912 with another simultaneous expression (a half note) using
913 @code{<<}, @code{\\}, and @code{>>}:
916 << g2 \\ @{ f4 <<c4 d4 e4>> @} >>
919 @lilypond[quote,fragment,relative=2]
920 \new Voice { << g2 \\ { f4 <<c d e>> } >> }
923 Such recursive structures can be specified neatly and formally in
924 a context-free grammar. The parsing code is also generated from
925 this grammar. In other words, the syntax of LilyPond is clearly
926 and unambiguously defined.
928 User-interfaces and syntax are what people see and deal with most.
929 They are partly a matter of taste, and also the subject of much
930 discussion. Although discussions on taste do have their merit,
931 they are not very productive. In the larger picture of LilyPond,
932 the importance of input syntax is small: inventing neat syntax is
933 easy, while writing decent formatting code is much harder. This
934 is also illustrated by the line-counts for the respective
935 components: parsing and representation take up less than 10% of
938 When designing the structures used in LilyPond, we made some different
939 decisions than are apparent in other software. Consider the hierarchical
940 nature of music notation:
942 @lilypond[quote,fragment]
944 \new Staff \relative {
947 d''4 g,8 a b c d4 g, g
949 \new Staff \relative {
957 In this case, there are pitches grouped into chords that belong to
958 measures, which belong to staves. This resembles a tidy structure of
963 @sourceimage{pdf/nestedboxes,,4cm,}
966 @sourceimage{nestedboxes,,,png}
970 Unfortunately, the structure is tidy because it is based on some
971 excessively restrictive assumptions. This becomes apparent if we
972 consider a more complicated musical example:
978 \remove "Timing_translator"
979 \remove "Default_bar_line_engraver"
983 \consists "Timing_translator"
984 \consists "Default_bar_line_engraver"
990 \new Voice = "I" \relative {
993 \tuplet 7/6 { g''8 g g g g g g }
995 r4 <b,, fis' g bes> r4\fermata
997 \new Voice = "II" \relative {
1002 \change Staff = "LH" \oneVoice
1005 \override Stem.cross-staff = ##t
1006 \override Stem.length = #12
1010 \new Staff = "LH" <<
1011 \new Voice = "III" \relative {
1021 In this example, staves start and stop at will, voices jump around
1022 between staves, and the staves have different time signatures. Many
1023 software packages would struggle with reproducing this example because
1024 they are built on the nested box structure. With LilyPond, on the other
1025 hand, we have tried to keep the input format and the structure as
1026 flexible as possible.
1028 @node What symbols to engrave?
1029 @unnumberedsubsec What symbols to engrave?
1036 The formatting process decides where to place symbols. However,
1037 this can only be done once it is decided @emph{what} symbols
1038 should be printed -- in other words, what notation to use.
1040 Common music notation is a system of recording music that has
1041 evolved over the past 1000 years. The form that is now in common
1042 use dates from the early Renaissance. Although the basic form
1043 (i.e., note heads on a 5-line staff) has not changed, the details
1044 still evolve to express the innovations of contemporary notation.
1045 Hence, common music notation encompasses some 500 years of music.
1046 Its applications range from monophonic melodies to monstrous
1047 counterpoints for a large orchestra.
1049 How can we get a grip on such a seven-headed beast, and force it
1050 into the confines of a computer program? Our solution is to break
1051 up the problem of notation (as opposed to engraving, i.e.,
1052 typography) into digestible and programmable chunks: every type of
1053 symbol is handled by a separate module, a so-called plug-in. Each
1054 plug-in is completely modular and independent, so each can be
1055 developed and improved separately. Such plug-ins are called
1056 @code{engraver}s, by analogy with craftsmen who translate musical
1057 ideas to graphic symbols.
1059 In the following example, we start out with a plug-in for note
1060 heads, the @code{Note_heads_engraver}.
1062 @lilypond[quote,ragged-right]
1063 \include "engraver-example.ily"
1070 \remove "Stem_engraver"
1071 \remove "Phrasing_slur_engraver"
1072 \remove "Slur_engraver"
1073 \remove "Script_engraver"
1074 \remove "New_fingering_engraver"
1075 \remove "Beam_engraver"
1076 \remove "Auto_beam_engraver"
1080 \remove "Accidental_engraver"
1081 \remove "Key_engraver"
1082 \remove "Clef_engraver"
1083 \remove "Bar_engraver"
1084 \remove "Time_signature_engraver"
1085 \remove "Staff_symbol_engraver"
1086 \consists "Pitch_squash_engraver"
1093 Then a @code{Staff_symbol_engraver} adds the staff,
1095 @lilypond[quote,ragged-right]
1096 \include "engraver-example.ily"
1103 \remove "Stem_engraver"
1104 \remove "Phrasing_slur_engraver"
1105 \remove "Slur_engraver"
1106 \remove "Script_engraver"
1107 \remove "New_fingering_engraver"
1108 \remove "Beam_engraver"
1109 \remove "Auto_beam_engraver"
1113 \remove "Accidental_engraver"
1114 \remove "Key_engraver"
1115 \remove "Clef_engraver"
1116 \remove "Bar_engraver"
1117 \consists "Pitch_squash_engraver"
1118 \remove "Time_signature_engraver"
1125 the @code{Clef_engraver} defines a reference point for the staff,
1127 @lilypond[quote,ragged-right]
1128 \include "engraver-example.ily"
1135 \remove "Stem_engraver"
1136 \remove "Phrasing_slur_engraver"
1137 \remove "Slur_engraver"
1138 \remove "Script_engraver"
1139 \remove "New_fingering_engraver"
1140 \remove "Beam_engraver"
1141 \remove "Auto_beam_engraver"
1145 \remove "Accidental_engraver"
1146 \remove "Key_engraver"
1147 \remove "Bar_engraver"
1148 \remove "Time_signature_engraver"
1155 and the @code{Stem_engraver} adds stems.
1157 @lilypond[quote,ragged-right]
1158 \include "engraver-example.ily"
1165 \remove "Phrasing_slur_engraver"
1166 \remove "Slur_engraver"
1167 \remove "Script_engraver"
1168 \remove "New_fingering_engraver"
1169 \remove "Beam_engraver"
1170 \remove "Auto_beam_engraver"
1174 \remove "Accidental_engraver"
1175 \remove "Key_engraver"
1176 \remove "Bar_engraver"
1177 \remove "Time_signature_engraver"
1184 The @code{Stem_engraver} is notified of any note head coming
1185 along. Every time one (or more, for a chord) note head is seen, a
1186 stem object is created and connected to the note head. By adding
1187 engravers for beams, slurs, accents, accidentals, bar lines, time
1188 signature, and key signature, we get a complete piece of notation.
1190 @lilypond[quote,ragged-right]
1191 \include "engraver-example.ily"
1192 \score { \topVoice }
1196 @cindex engraving multiple voices
1199 This system works well for monophonic music, but what about
1200 polyphony? In polyphonic notation, many voices can share a staff.
1202 @lilypond[quote,ragged-right]
1203 \include "engraver-example.ily"
1204 \new Staff << \topVoice \\ \botVoice >>
1207 In this situation, the accidentals and staff are shared, but the
1208 stems, slurs, beams, etc., are private to each voice. Hence,
1209 engravers should be grouped. The engravers for note heads, stems,
1210 slurs, etc., go into a group called @q{Voice context}, while the
1211 engravers for key, accidental, bar, etc., go into a group called
1212 @q{Staff context}. In the case of polyphony, a single Staff
1213 context contains more than one Voice context. Similarly, multiple
1214 Staff contexts can be put into a single Score context. The Score
1215 context is the top level notation context.
1217 @lilypond[quote,ragged-right]
1218 \include "engraver-example.ily"
1221 \new Staff << \topVoice \\ \botVoice >>
1222 \new Staff << \pah \\ \hoom >>
1228 Internals Reference: @rinternals{Contexts}.
1230 @node Flexible architecture
1231 @unnumberedsubsec Flexible architecture
1233 When we started, we wrote the LilyPond program entirely in the C++
1234 programming language; the program's functionality was set in stone
1235 by the developers. That proved to be unsatisfactory for a number
1240 @item When LilyPond makes mistakes, users need to override
1241 formatting decisions. Therefore, the user must have access to the
1242 formatting engine. Hence, rules and settings cannot be fixed by
1243 us at compile-time but must be accessible for users at run-time.
1245 @item Engraving is a matter of visual judgment, and therefore a
1246 matter of taste. As knowledgeable as we are, users can disagree
1247 with our personal decisions. Therefore, the definitions of
1248 typographical style must also be accessible to the user.
1250 @item Finally, we continually refine the formatting algorithms, so
1251 we need a flexible approach to rules. The C++ language forces a
1252 certain method of grouping rules that cannot readily be applied to
1253 formatting music notation.
1257 @cindex Scheme programming language
1259 These problems have been addressed by integrating an interpreter
1260 for the Scheme programming language and rewriting parts of
1261 LilyPond in Scheme. The current formatting architecture is built
1262 around the notion of graphical objects, described by Scheme
1263 variables and functions. This architecture encompasses formatting
1264 rules, typographical style and individual formatting decisions.
1265 The user has direct access to most of these controls.
1267 Scheme variables control layout decisions. For example, many
1268 graphical objects have a direction variable that encodes the
1269 choice between up and down (or left and right). Here you see two
1270 chords, with accents and arpeggios. In the first chord, the
1271 graphical objects have all directions down (or left). The second
1272 chord has all directions up (right).
1274 @lilypond[quote,ragged-right]
1277 \stemDown <e' g b>4_>-\arpeggio
1278 \override Arpeggio.direction = #RIGHT
1279 \stemUp <e g b>4^>-\arpeggio
1284 \override SpacingSpanner.spacing-increment = #3
1291 @cindex score formatting
1292 @cindex formatting a score
1293 @cindex formatting rules
1296 The process of formatting a score consists of reading and writing
1297 the variables of graphical objects. Some variables have a preset
1298 value. For example, the thickness of many lines -- a
1299 characteristic of typographical style -- is a variable with a
1300 preset value. You are free to alter this value, giving your score
1301 a different typographical impression.
1303 @lilypond[quote,ragged-right]
1306 c'4-~ c'16 as g f e16 g bes c' des'4
1309 \new Staff \fragment
1311 \override Beam.beam-thickness = #0.3
1312 \override Stem.thickness = #0.5
1313 \override Bar.thickness = #3.6
1314 \override Tie.thickness = #2.2
1315 \override StaffSymbol.thickness = #3.0
1316 \override Tie.extra-offset = #'(0 . 0.3)
1322 Formatting rules are also preset variables: each object has
1323 variables containing procedures. These procedures perform the
1324 actual formatting, and by substituting different ones, we can
1325 change the appearance of objects. In the following example, the
1326 rule governing which note head objects are used to produce the
1327 note head symbol is changed during the music fragment.
1329 @lilypond[quote,ragged-right]
1330 #(set-global-staff-size 30)
1332 #(define (mc-squared grob orig current)
1333 (let* ((interfaces (ly:grob-interfaces grob))
1334 (pos (ly:grob-property grob 'staff-position)))
1335 (if (memq 'note-head-interface interfaces)
1337 (ly:grob-set-property! grob 'stencil
1338 (grob-interpret-markup grob
1339 (make-lower-markup 0.5
1343 ((-2) (make-smaller-markup (make-bold-markup "2")))
1344 (else "bla")))))))))
1346 \new Voice \relative {
1348 \set autoBeaming = ##f
1351 \once \override NoteHead.stencil = #note-head::brew-ez-stencil
1352 \once \override NoteHead.font-size = #-7
1353 \once \override NoteHead.font-family = #'sans
1354 \once \override NoteHead.font-series = #'bold
1356 \once \override NoteHead.style = #'cross
1358 \applyOutput Voice #mc-squared
1361 { d8[ es-( fis^^ g] fis2-) }
1362 \repeat unfold 5 { \applyOutput Voice #mc-squared s8 }
1369 @node Putting LilyPond to work
1370 @section Putting LilyPond to work
1372 @cindex simple examples
1373 @cindex examples, simple
1375 We have written LilyPond as an experiment of how to condense the
1376 art of music engraving into a computer program. Thanks to all
1377 that hard work, the program can now be used to perform useful
1378 tasks. The simplest application is printing notes.
1380 @lilypond[quote,relative=1]
1388 By adding chord names and lyrics we obtain a lead sheet.
1390 @lilypond[quote,ragged-right]
1392 \chords { c2 c f2 c }
1398 \addlyrics { twin -- kle twin -- kle lit -- tle star }
1402 Polyphonic notation and piano music can also be printed. The
1403 following example combines some more exotic constructs.
1405 @lilypond[quote,line-width=15.9\cm]
1407 title = "Screech and boink"
1408 subtitle = "Random complex notation"
1409 composer = "Han-Wen Nienhuys"
1413 \context PianoStaff <<
1418 \revert Stem.direction
1419 \change Staff = down
1420 \set subdivideBeams = ##t
1424 \change Staff = down
1428 \change Staff = down
1432 \set followVoice = ##t
1433 c'''32([ b''16 a''16 gis''16 g''32)]
1435 s4 \tuplet 3/2 { d'16[ f' g'] } as'32[ b''32 e'' d'']
1437 s4 \autoBeamOff d''8.. f''32
1443 \new Staff = "down" {
1446 \set subdivideBeams = ##f
1447 \override Stem.french-beaming = ##t
1448 \override Beam.beam-thickness = #0.3
1449 \override Stem.thickness = #4.0
1450 g'16[ b16 fis16 g16]
1456 \override Staff.Arpeggio.arpeggio-direction =#down
1457 <cis, e, gis, b, cis>4\arpeggio
1467 \consists "Horizontal_bracket_engraver"
1473 The fragments shown above have all been written by hand, but that
1474 is not a requirement. Since the formatting engine is mostly
1475 automatic, it can serve as an output means for other programs that
1476 manipulate music. For example, it can also be used to convert
1477 databases of musical fragments to images for use on websites and
1478 multimedia presentations.
1480 This manual also shows an application: the input format is text, and can
1481 therefore be easily embedded in other text-based formats such as
1482 @LaTeX{}, HTML, or in the case of this manual, Texinfo. Using the
1483 @command{lilypond-book} program, included with LilyPond, the input
1484 fragments can be replaced by music images in the resulting PDF or HTML
1485 output files. Another example is the third-party OOoLilyPond extension
1486 for OpenOffice.org or LibreOffice, which makes it extremely easy to
1487 embed musical examples in documents.
1489 For more examples of LilyPond in action, full documentation, and the
1490 software itself, see our main website: www.lilypond.org.
1493 @node Engraved examples (BWV 861)
1494 @section Engraved examples (BWV 861)
1496 This section contains four reference engravings and two
1497 software-engraved versions of Bach's Fugue in G minor from the
1498 Well-Tempered Clavier, Book I, BWV 861 (the last seven measures).
1501 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1505 @sourceimage{bwv861-baer,16cm,,}
1508 @sourceimage{bwv861-baer-small,,,png}
1512 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1513 1989), an alternate musical source. Aside from the textual differences,
1514 this demonstrates slight variations in the engraving decisions, even
1515 from the same publisher and edition:
1518 @sourceimage{bwv861-baer-alt,16cm,,}
1521 @sourceimage{bwv861-baer-alt-small,,,png}
1525 Breitkopf & Härtel, edited by Ferruccio Busoni (Wiesbaden, 1894), also
1526 available from the Petrucci Music Library (IMSLP #22081). The editorial
1527 markings (fingerings, articulations, etc.) have been removed for clearer
1528 comparison with the other editions here:
1531 @sourceimage{bwv861-breitkopf,16cm,,}
1534 @sourceimage{bwv861-breitkopf-small,,,png}
1538 Bach-Gesellschaft edition (Leipzig, 1866), available from the Petrucci
1539 Music Library (IMSPL #02221):
1542 @sourceimage{bwv861-gessellschaft,16cm,,}
1545 @sourceimage{bwv861-gessellschaft-small,,,png}
1552 @sourceimage{pdf/bwv861-finale2008a,,,}
1555 @sourceimage{bwv861-finale2008a,,,png}
1560 LilyPond, version @version{}:
1562 @lilypond[staffsize=14.3,line-width=15.9\cm]
1563 global = {\key g \minor}
1567 fis'8 d' ees g, fis4 g
1568 r8 a16 bes c8 bes16 a d8 r r4
1569 r2 r8 d16 ees f8 ees16 d
1570 ees4 ~ 16 d c bes a4 r8 ees'16 d
1571 c8 d16 ees d8 e16 fis g8 fis16 g a4 ~
1572 8 d, g f ees d c bes
1573 a2 g\fermata \bar "|."
1576 partII = \relative {
1578 d'4 r4 r8 d'16 c bes8 c16 d
1579 ees8 d c ees a, r r4
1580 r8 fis16 g a8 g16 fis g2 ~
1582 fis4 g r8 a16 bes c8 bes16 a
1583 bes4. <g b>8 <a c> r <d, g> r
1586 partIII = \relative {
1588 r2 r8 d' ees g, fis4 g r8 a16 bes c8 bes16 a
1589 bes2 ~ 8 b16 a g8 a16 b
1593 r8 a16 bes c8 bes16 a b2
1595 partIV = \relative {
1599 d,8 d'16 c bes8 c16 d ees2 ~
1600 8 ees16 d c8 d16 ees fis,8 a16 g fis8 g16 a
1601 d,8 d'16 c bes8 c16 d ees8 c a fis'
1608 % \set Score.barNumberVisibility = #all-bar-numbers-visible
1610 \set Score.currentBarNumber = #28
1613 \new Staff = "RH" <<
1615 \new Voice = "voiceI" { \partI }
1616 \new Voice = "voiceII" { \partII }
1619 \new Staff = "LH" <<
1622 \new Voice = "voiceIII" { \partIII }
1623 \new Voice = "voiceIV" { \partIV }
1630 \remove "Time_signature_engraver"
1634 \override StaffGrouper.staff-staff-spacing.padding = #1