1 @c -*- coding: utf-8; mode: texinfo; -*-
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
13 @chapter Music engraving
15 This section covers the overall goals and architecture of
20 * Automated engraving::
21 * What symbols to engrave?::
22 * Music representation::
23 * Example applications::
29 @unnumberedsec Engraving
32 @cindex typography, music
33 @cindex music typography
34 @cindex plate engraving
35 @cindex music engraving
37 The art of music typography is called @emph{(plate) engraving}. The term
38 derives from the traditional process of music printing. Just a few
39 decades ago, sheet music was made by cutting and stamping the music into
40 a zinc or pewter plate in mirror image. The plate would be inked, and
41 the depressions caused by the cutting and stamping would hold ink. An
42 image was formed by pressing paper to the plate. The stamping and
43 cutting was done completely by hand. Making a correction was cumbersome,
44 so the engraving had to be nearly perfect in one go. Engraving was a
45 highly specialized skill; a craftsman had to complete around five years
46 of training before earning the title of master engraver, and another
47 five years of experience were necessary to become truly skilled.
51 @sourceimage{hader-slaan,,7cm,}
54 @sourceimage{hader-slaan,,,jpg}
58 Nowadays, all newly printed music is produced with computers. This has
59 obvious advantages: prints are cheaper to make, editorial work can be
60 delivered by email, and the original data can be easily stored.
61 Unfortunately, computer-generated scores rarely match the quality of
62 hand-engraved scores. Instead, computer printouts have a bland,
63 mechanical look, which makes them unpleasant to play from.
65 From the beginning, we designed LilyPond to mimic the beauty of
66 traditional music engraving. Along the way, we have learned a great deal
67 about the work that goes into a well-engraved score. Below we describe
68 several of those aspects that we have tried to imitate in LilyPond.
79 @unnumberedsubsec Music fonts
81 The images below illustrate some differences between traditional
82 engraving and typical computer output. The left picture shows a scan of
83 a flat symbol from a hand-engraved Bärenreiter edition, while the right
84 picture depicts a symbol from an edition of the same music published in
85 2000. Although both images are printed in the shame shade of ink, the
86 earlier version looks darker: the staff lines are heavier, and the
87 Bärenreiter flat has a bold, almost voluptuous rounded look. The right
88 scan, on the other hand, has thinner lines and a straight layout with
91 @multitable @columnfractions .25 .25 .25 .25
95 @sourceimage{baer-flat-gray,,4cm,}
98 @sourceimage{baer-flat-gray,,,png}
103 @sourceimage{henle-flat-gray,,4cm,}
106 @sourceimage{henle-flat-gray,,,png}
111 @sourceimage{henle-flat-bw,,,png}
112 @sourceimage{baer-flat-bw,,,png}
113 @sourceimage{lily-flat-bw,,,png}
124 @cindex musical symbols
129 When we wanted to write a computer program to create music typography,
130 there were no musical fonts freely available that could match the
131 elegance of our favorite scores. Not let down, we created a font of
132 musical symbols, relying on nice printouts of hand-engraved music. The
133 experience helped develop a typographical taste, and it made us
134 appreciate subtle design details. Without that experience, we would not
135 have realized how ugly the fonts were that we admired at first.
137 Below is a sample of two music fonts: the upper set is the default font
138 in the Sibelius software (the @emph{Opus} font), and the lower set is
139 our own LilyPond font.
143 @sourceimage{pdf/OpusAndFeta,,,}
146 @sourceimage{OpusAndFeta,,,png}
150 The LilyPond symbols are heavier and their weight is more consistent,
151 which makes them easier to read. Fine endings, such as the one on the
152 bottom of the quarter rest, should not end in sharp points, but rather
153 in rounded shapes. This is because sharp corners of the punching dies
154 are fragile and quickly wear out when stamping in metal. Taken together,
155 the blackness of the font must be carefully tuned together with the
156 thickness of lines, beams and slurs to give a strong yet balanced
159 Also, notice that our half-notehead is not elliptic but slightly diamond
160 shaped. The vertical stem of a flat symbol is slightly brushed, becoming
161 wider at the top. The sharp and the natural are easier to distinguish
162 from a distance because their angled lines have different slopes and the
163 vertical strokes are heavier.
165 @node Optical spacing
166 @unnumberedsubsec Optical spacing
168 In spacing, the distribution of space should reflect the durations
169 between notes. However, many modern scores adhere to the
170 durations with mathematical precision, which leads to poor
171 results. In the next example a motive is printed twice: the first time
172 using exact mathematical spacing, and the second with corrections.
175 @cindex optical spacing
196 \override NoteSpacing #'stem-spacing-correction = #0.0
197 \override NoteSpacing #'same-direction-correction = #0.0
198 \override StaffSpacing #'stem-spacing-correction = #0.0
224 \override NoteSpacing #'stem-spacing-correction = #0.6
230 @cindex regular rhythms
231 @cindex regular spacing
232 @cindex spacing, regular
234 Each bar in the fragment only uses notes that are played in a
235 constant rhythm. The spacing should reflect that. Unfortunately,
236 the eye deceives us a little; not only does it notice the distance
237 between note heads, it also takes into account the distance
238 between consecutive stems. As a result, the notes of an
239 up-stem/@/down-stem combination should be put farther apart, and
240 the notes of a down-stem/@/up-stem combination should be put
241 closer together, all depending on the combined vertical positions
242 of the notes. The upper two measures are printed with this
243 correction, the lower two measures, however, form down-stem/@/up-stem
244 clumps of notes. A master engraver would adjust the spacing as needed to
247 Another example of optical spacing is the visual interplay between the
248 stems and the bar lines. When an up-stem precedes the bar line, a little
249 more space is needed to keep it from feeling crowded:
258 c''8 c'' c'' c'' c'' c'' c'' c'' \break
259 a' a' a' a' a' a' a' a'
264 \remove "Time_signature_engraver"
265 \override NoteSpacing #'stem-spacing-correction = #0.7
272 @unnumberedsubsec Ledger lines
277 Ledger lines present a typographical challenge: they make it more
278 difficult to space musical symbols close together and they must be clear
279 enough to identify the pitch at a glance. In the example below, we see
280 that ledger lines should be thicker than normal staff lines and that an
281 expert engraver will shorten a ledger line to allow closer spacing with
282 accidentals. We have included this feature in LilyPond's engraving.
284 @multitable @columnfractions .25 .25 .25 .25
288 @sourceimage{baer-ledger,3cm,,}
291 @sourceimage{baer-ledger,,,png}
297 @sourceimage{lily-ledger,3cm,,}
300 @sourceimage{lily-ledger,,,png}
307 @unnumberedsubsec Optical sizing
309 Music may need to be printed in a range of sizes. Originally, this was
310 accomplished by creating punching dies in each of the required sizes,
311 which meant that each die was designed to look its best at that size.
312 With the advent of digital fonts, a single outline can be mathematically
313 scaled to any size, which is very convenient, but at the smaller sizes
314 the glyphs will appear very light.
316 In LilyPond, we have created fonts in a range of weights, corresponding
317 to a range of music sizes. This is a LilyPond engraving at staff size
322 @sourceimage{pdf/size26,,23mm,}
325 @sourceimage{size26,,,png}
330 and this is the same engraving set at staff size 11, then
331 magnified by 236% to print at the same size as the previous example:
335 @sourceimage{pdf/size11,,23mm,}
338 @sourceimage{size11,,,png}
342 At smaller sizes, LilyPond uses proportionally heavier lines and so the
343 music will still read well. This also allows staves of different
344 sizes to coexist peacefully when used together on the same page:
346 @c Grieg's Violin Sonata Op. 45
347 @lilypond[indent=1.5cm]
356 \override StaffSymbol #'staff-space = #(magstep -4)
357 \override StaffSymbol #'thickness = #(magstep -3)
361 \set Staff.instrumentName = #"Violin"
362 c8.(\f^> b16 c d) ees8.(^> d16 c b)
363 g8.(^> b16 c ees) g8-.^> r r
367 \set PianoStaff.instrumentName = #"Piano"
368 \new Staff \relative c' {
371 s4. s8 r8 r16 <c f aes c>
372 <c f aes c>4.^> <c ees g>8 r r
374 \new Staff \relative c {
378 \once \override DynamicText #'X-offset = #-3
380 <ees g c>4.~ <ees g c>8
383 <c g c,>4.~ <c g c,>8
385 r8 r16 <f, c' aes'>16
386 <f c' aes'>4.-> <c' g'>8 r r
392 @node Why work so hard?
393 @unnumberedsubsec Why work so hard?
395 Musicians are usually more absorbed with performing than with studying
396 the looks of a piece of music, so nitpicking typographical details may
397 seem academic. But it is not. Sheet music is performance material:
398 everything is done to aid the musician in letting her perform better,
399 and anything that is unclear or unpleasant to read is a hinderance.
401 Traditionally engraved music uses bold symbols on heavy staff to create
402 a strong, well-balanced look that stands out well when the music is far
403 away from the reader: for example, if it is on a music stand. A careful
404 distribution of white space allows music to be set very tightly without
405 crowding symbols together. The result minimizes the number of page
406 turns, which is a great advantage.
408 This is a common characteristic of typography. Layout should be pretty,
409 not only for its own sake, but especially because it helps the reader in
410 his task. For sheet music this is of double importance because musicians
411 have a limited amount of attention. The less attention they need for
412 reading, the more they can focus on playing the music. In other words,
413 better typography translates to better performances.
415 These examples demonstrate that music typography is an art that is
416 subtle and complex, and that producing it requires considerable
417 expertise, which musicians usually do not have. LilyPond is our
418 effort to bring the graphical excellence of hand-engraved music to
419 the computer age, and make it available to normal musicians. We
420 have tuned our algorithms, font-designs, and program settings to
421 produce prints that match the quality of the old editions we love
422 to see and love to play from.
425 @node Automated engraving
426 @unnumberedsec Automated engraving
428 @cindex engraving, automated
429 @cindex automated engraving
433 * Notation benchmarking::
434 * Flexible architecture::
437 @node Beauty contests
438 @unnumberedsubsec Beauty contests
440 Rather than trying to write rules that describe how to draw an
441 attractive slur for every possible scenario, we have written rules that
442 describe an attractive slur and LilyPond finds the nicest possibility.
443 For example, here are three possible slur configurations, and LilyPond
444 has given each one a score in `ugly points':
447 %\layout { #(define debug-slur-scoring #t) }
451 \once \override Slur #'positions = #'(1.5 . 1)
452 e8[(_"15.39" f] g[ a b d,)] r4
453 \once \override Slur #'positions = #'(2 . 3)
454 e8[(_"13.08" f] g[ a b d,)] r4
455 e8[(_"12.04" f] g[ a b d,)] r4
461 The first example gets 15.39 points for grazing one of the notes. The
462 second one is nicer, but the slur doesn't start or end on the noteheads.
463 It gets 1.71 points for the left side and 9.37 points for the right
464 side, plus another 2 points because the slur ascends while the melody
465 descends for a total of 13.08 ulgy points. The final slur gets 10.04
466 points for the gap on the right and 2 points for the upward slope, but
467 it is the most attractive of the three configurations, so LilyPond
470 This technique is quite general, and is used to select beam
471 configurations, ties and dots in chords, line breaks, and page breaks.
473 @node Notation benchmarking
474 @unnumberedsubsec Notation benchmarking
476 We have tuned LilyPond's layout rules by comparing its output to
477 hand-engraved scores. Here is one line of a benchmark piece from a
478 hand-engraved edition (Bärenreiter BA320), and as engraved by LilyPond
482 @sourceimage{baer-sarabande-hires,16cm,,}
485 @sourceimage{baer-sarabande,,,png}
489 @sourceimage{lily14-sarabande,16cm,,}
492 @sourceimage{lily14-sarabande,,,png}
496 On careful inspection, there are a number of errors in the LilyPond 1.4
500 @item most of the stems are too long
501 @item the trill marks are too big
502 @item the second and fourth measures are too narrow
503 @item the slur is awkward-looking
504 @item the stems are too thin
508 (There were also two missing notes, and one wrong one!)
510 By adjusting the layout rules and font design, the output has improved
511 considerably. This is the same piece, engraved by the current version of
512 LilyPond (@version{}):
514 @lilypond[staffsize=19,line-width=15.9\cm]
519 \mergeDifferentlyDottedOn
520 << {\slurDashed d8.-\flageolet( e16) e4.-\trill( d16 e)}
524 <f' a, d,>4. e8( d c)
526 bes g' f e16( f g_1 a_2 bes_3 d,_2)
528 cis4.-\trill b8_3( a g)
529 << {\slurDashed d'8.( e16) e4.-\trill( d16 e)}
535 [AH: I have not written or edited beyond this point. Here I want to do a
536 comparison of the last seven measures of Bach's Fugue in G minor from
537 the Well-Tempered Clavier, Book I, BWV 861. The appendix has all of the
538 source material, but I have some writing to do. This should demonstrate
539 LilyPond's excellent output, particularly compared to the default Finale
540 output, but more fairly than was done before. This will also show that
541 there are always situations that can be improved with some human
542 intervention, leading nicely into the next section.]
545 @node Flexible architecture
546 @unnumberedsubsec Flexible architecture
548 How do we go about implementing typography? If craftsmen need
549 over ten years to become true masters, how could we simple hackers
550 ever write a program to take over their jobs?
552 The answer is: we cannot. Typography relies on human judgment of
553 appearance, so people cannot be replaced completely. However,
554 much of the dull work can be automated. If LilyPond solves most
555 of the common situations correctly, this will be a huge
556 improvement over existing software. The remaining cases can be
557 tuned by hand. Over the course of years, the software can be
558 refined to do more and more things automatically, so manual
559 overrides are less and less necessary.
561 When we started, we wrote the LilyPond program entirely in the C++
562 programming language; the program's functionality was set in stone
563 by the developers. That proved to be unsatisfactory for a number
568 @item When LilyPond makes mistakes, users need to override
569 formatting decisions. Therefore, the user must have access to the
570 formatting engine. Hence, rules and settings cannot be fixed by
571 us at compile-time but must be accessible for users at run-time.
573 @item Engraving is a matter of visual judgment, and therefore a
574 matter of taste. As knowledgeable as we are, users can disagree
575 with our personal decisions. Therefore, the definitions of
576 typographical style must also be accessible to the user.
578 @item Finally, we continually refine the formatting algorithms, so
579 we need a flexible approach to rules. The C++ language forces a
580 certain method of grouping rules that cannot readily be applied to
581 formatting music notation.
585 @cindex Scheme programming language
587 These problems have been addressed by integrating an interpreter
588 for the Scheme programming language and rewriting parts of
589 LilyPond in Scheme. The current formatting architecture is built
590 around the notion of graphical objects, described by Scheme
591 variables and functions. This architecture encompasses formatting
592 rules, typographical style and individual formatting decisions.
593 The user has direct access to most of these controls.
595 Scheme variables control layout decisions. For example, many
596 graphical objects have a direction variable that encodes the
597 choice between up and down (or left and right). Here you see two
598 chords, with accents and arpeggios. In the first chord, the
599 graphical objects have all directions down (or left). The second
600 chord has all directions up (right).
602 @lilypond[quote,ragged-right]
604 \override SpacingSpanner #'spacing-increment = #3
605 \override TimeSignature #'transparent = ##t
607 \stemDown <e g b>4_>-\arpeggio
608 \override Arpeggio #'direction = #RIGHT
609 \stemUp <e g b>4^>-\arpeggio
613 @cindex score formatting
614 @cindex formatting a score
615 @cindex formatting rules
618 The process of formatting a score consists of reading and writing
619 the variables of graphical objects. Some variables have a preset
620 value. For example, the thickness of many lines -- a
621 characteristic of typographical style -- is a variable with a
622 preset value. You are free to alter this value, giving your score
623 a different typographical impression.
625 @lilypond[quote,ragged-right]
628 c'4-~ c'16 as g f e16 g bes c' des'4
633 \override Beam #'beam-thickness = #0.3
634 \override Stem #'thickness = #0.5
635 \override Bar #'thickness = #3.6
636 \override Tie #'thickness = #2.2
637 \override StaffSymbol #'thickness = #3.0
638 \override Tie #'extra-offset = #'(0 . 0.3)
644 Formatting rules are also preset variables: each object has
645 variables containing procedures. These procedures perform the
646 actual formatting, and by substituting different ones, we can
647 change the appearance of objects. In the following example, the
648 rule governing which note head objects are used to produce the
649 note head symbol is changed during the music fragment.
651 @lilypond[quote,ragged-right]
652 #(set-global-staff-size 30)
654 #(define (mc-squared grob orig current)
655 (let* ((interfaces (ly:grob-interfaces grob))
656 (pos (ly:grob-property grob 'staff-position)))
657 (if (memq 'note-head-interface interfaces)
659 (ly:grob-set-property! grob 'stencil
660 (grob-interpret-markup grob
661 (make-lower-markup 0.5
665 ((-2) (make-smaller-markup (make-bold-markup "2")))
668 \new Voice \relative c' {
670 \set autoBeaming = ##f
673 \once \override NoteHead #'stencil = #note-head::brew-ez-stencil
674 \once \override NoteHead #'font-size = #-7
675 \once \override NoteHead #'font-family = #'sans
676 \once \override NoteHead #'font-series = #'bold
678 \once \override NoteHead #'style = #'cross
680 \applyOutput #'Voice #mc-squared
683 { d8[ es-( fis^^ g] fis2-) }
684 \repeat unfold 5 { \applyOutput #'Voice #mc-squared s8 }
690 @node What symbols to engrave?
691 @unnumberedsec What symbols to engrave?
698 The formatting process decides where to place symbols. However,
699 this can only be done once it is decided @emph{what} symbols
700 should be printed -- in other words, what notation to use.
702 Common music notation is a system of recording music that has
703 evolved over the past 1000 years. The form that is now in common
704 use dates from the early Renaissance. Although the basic form
705 (i.e., note heads on a 5-line staff) has not changed, the details
706 still evolve to express the innovations of contemporary notation.
707 Hence, common music notation encompasses some 500 years of music.
708 Its applications range from monophonic melodies to monstrous
709 counterpoints for a large orchestra.
711 How can we get a grip on such a seven-headed beast, and force it
712 into the confines of a computer program? Our solution is to break
713 up the problem of notation (as opposed to engraving, i.e.,
714 typography) into digestible and programmable chunks: every type of
715 symbol is handled by a separate module, a so-called plug-in. Each
716 plug-in is completely modular and independent, so each can be
717 developed and improved separately. Such plug-ins are called
718 @code{engraver}s, by analogy with craftsmen who translate musical
719 ideas to graphic symbols.
721 In the following example, we start out with a plug-in for note
722 heads, the @code{Note_heads_engraver}.
724 @lilypond[quote,ragged-right]
725 \include "engraver-example.ily"
732 \remove "Stem_engraver"
733 \remove "Phrasing_slur_engraver"
734 \remove "Slur_engraver"
735 \remove "Script_engraver"
736 \remove "Beam_engraver"
737 \remove "Auto_beam_engraver"
741 \remove "Accidental_engraver"
742 \remove "Key_engraver"
743 \remove "Clef_engraver"
744 \remove "Bar_engraver"
745 \remove "Time_signature_engraver"
746 \remove "Staff_symbol_engraver"
747 \consists "Pitch_squash_engraver"
754 Then a @code{Staff_symbol_engraver} adds the staff,
756 @lilypond[quote,ragged-right]
757 \include "engraver-example.ily"
764 \remove "Stem_engraver"
765 \remove "Phrasing_slur_engraver"
766 \remove "Slur_engraver"
767 \remove "Script_engraver"
768 \remove "Beam_engraver"
769 \remove "Auto_beam_engraver"
773 \remove "Accidental_engraver"
774 \remove "Key_engraver"
775 \remove "Clef_engraver"
776 \remove "Bar_engraver"
777 \consists "Pitch_squash_engraver"
778 \remove "Time_signature_engraver"
785 the @code{Clef_engraver} defines a reference point for the staff,
787 @lilypond[quote,ragged-right]
788 \include "engraver-example.ily"
795 \remove "Stem_engraver"
796 \remove "Phrasing_slur_engraver"
797 \remove "Slur_engraver"
798 \remove "Script_engraver"
799 \remove "Beam_engraver"
800 \remove "Auto_beam_engraver"
804 \remove "Accidental_engraver"
805 \remove "Key_engraver"
806 \remove "Bar_engraver"
807 \remove "Time_signature_engraver"
814 and the @code{Stem_engraver} adds stems.
816 @lilypond[quote,ragged-right]
817 \include "engraver-example.ily"
824 \remove "Phrasing_slur_engraver"
825 \remove "Slur_engraver"
826 \remove "Script_engraver"
827 \remove "Beam_engraver"
828 \remove "Auto_beam_engraver"
832 \remove "Accidental_engraver"
833 \remove "Key_engraver"
834 \remove "Bar_engraver"
835 \remove "Time_signature_engraver"
842 The @code{Stem_engraver} is notified of any note head coming
843 along. Every time one (or more, for a chord) note head is seen, a
844 stem object is created and connected to the note head. By adding
845 engravers for beams, slurs, accents, accidentals, bar lines, time
846 signature, and key signature, we get a complete piece of notation.
848 @lilypond[quote,ragged-right]
849 \include "engraver-example.ily"
854 @cindex engraving multiple voices
857 This system works well for monophonic music, but what about
858 polyphony? In polyphonic notation, many voices can share a staff.
860 @lilypond[quote,ragged-right]
861 \include "engraver-example.ily"
862 \new Staff << \topVoice \\ \botVoice >>
865 In this situation, the accidentals and staff are shared, but the
866 stems, slurs, beams, etc., are private to each voice. Hence,
867 engravers should be grouped. The engravers for note heads, stems,
868 slurs, etc., go into a group called @q{Voice context,} while the
869 engravers for key, accidental, bar, etc., go into a group called
870 @q{Staff context.} In the case of polyphony, a single Staff
871 context contains more than one Voice context. Similarly, multiple
872 Staff contexts can be put into a single Score context. The Score
873 context is the top level notation context.
877 Internals Reference: @rinternals{Contexts}.
880 @lilypond[quote,ragged-right]
881 \include "engraver-example.ily"
884 \new Staff << \topVoice \\ \botVoice >>
885 \new Staff << \pah \\ \hoom >>
891 @node Music representation
892 @unnumberedsec Music representation
895 @cindex recursive structures
897 Ideally, the input format for any high-level formatting system is
898 an abstract description of the content. In this case, that would
899 be the music itself. This poses a formidable problem: how can we
900 define what music really is? Instead of trying to find an answer,
901 we have reversed the question. We write a program capable of
902 producing sheet music, and adjust the format to be as lean as
903 possible. When the format can no longer be trimmed down, by
904 definition we are left with content itself. Our program serves as
905 a formal definition of a music document.
907 The syntax is also the user-interface for LilyPond, hence it is
917 to create a quarter note on middle C (C1) and an eighth note on
918 the D above middle C (D1).
926 On a microscopic scale, such syntax is easy to use. On a larger
927 scale, syntax also needs structure. How else can you enter
928 complex pieces like symphonies and operas? The structure is
929 formed by the concept of music expressions: by combining small
930 fragments of music into larger ones, more complex music can be
931 expressed. For example
933 @lilypond[quote,verbatim,fragment,relative=1]
938 Simultaneous notes can be constructed by enclosing them with
939 @code{<<} and @code{>>}:
945 @lilypond[quote,fragment,relative=1]
946 \new Voice { <<c4 d4 e>> }
950 This expression is put in sequence by enclosing it in curly braces
951 @code{@{@tie{}@dots{}@tie{}@}}:
954 @{ f4 <<c4 d4 e4>> @}
957 @lilypond[quote,relative=1,fragment]
962 The above is also an expression, and so it may be combined again
963 with another simultaneous expression (a half note) using
964 @code{<<}, @code{\\}, and @code{>>}:
967 << g2 \\ @{ f4 <<c4 d4 e4>> @} >>
970 @lilypond[quote,fragment,relative=2]
971 \new Voice { << g2 \\ { f4 <<c d e>> } >> }
974 Such recursive structures can be specified neatly and formally in
975 a context-free grammar. The parsing code is also generated from
976 this grammar. In other words, the syntax of LilyPond is clearly
977 and unambiguously defined.
979 User-interfaces and syntax are what people see and deal with most.
980 They are partly a matter of taste, and also the subject of much
981 discussion. Although discussions on taste do have their merit,
982 they are not very productive. In the larger picture of LilyPond,
983 the importance of input syntax is small: inventing neat syntax is
984 easy, while writing decent formatting code is much harder. This
985 is also illustrated by the line-counts for the respective
986 components: parsing and representation take up less than 10% of
990 @node Example applications
991 @unnumberedsec Example applications
993 @cindex simple examples
994 @cindex examples, simple
996 We have written LilyPond as an experiment of how to condense the
997 art of music engraving into a computer program. Thanks to all
998 that hard work, the program can now be used to perform useful
999 tasks. The simplest application is printing notes.
1001 @lilypond[quote,relative=1]
1009 By adding chord names and lyrics we obtain a lead sheet.
1011 @lilypond[quote,ragged-right]
1013 \chords { c2 c f2 c }
1019 \addlyrics { twin -- kle twin -- kle lit -- tle star }
1023 Polyphonic notation and piano music can also be printed. The
1024 following example combines some more exotic constructs.
1028 title = "Screech and boink"
1029 subtitle = "Random complex notation"
1030 composer = "Han-Wen Nienhuys"
1034 \context PianoStaff <<
1039 \revert Stem #'direction
1040 \change Staff = down
1041 \set subdivideBeams = ##t
1045 \change Staff = down
1049 \change Staff = down
1053 \set followVoice = ##t
1054 c'''32([ b''16 a''16 gis''16 g''32)]
1056 s4 \times 2/3 { d'16[ f' g'] } as'32[ b''32 e'' d'']
1058 s4 \autoBeamOff d''8.. f''32
1064 \new Staff = "down" {
1067 \set subdivideBeams = ##f
1068 \override Stem #'french-beaming = ##t
1069 \override Beam #'beam-thickness = #0.3
1070 \override Stem #'thickness = #4.0
1071 g'16[ b16 fis16 g16]
1077 \override Staff.Arpeggio #'arpeggio-direction =#down
1078 <cis, e, gis, b, cis>4\arpeggio
1085 tempoWholesPerMinute = #(ly:make-moment 60 8)
1091 \consists Horizontal_bracket_engraver
1097 The fragments shown above have all been written by hand, but that
1098 is not a requirement. Since the formatting engine is mostly
1099 automatic, it can serve as an output means for other programs that
1100 manipulate music. For example, it can also be used to convert
1101 databases of musical fragments to images for use on websites and
1102 multimedia presentations.
1104 This manual also shows an application: the input format is text,
1105 and can therefore be easily embedded in other text-based formats
1106 such as @LaTeX{}, HTML, or in the case of this manual, Texinfo.
1107 By means of a special program, the input fragments can be replaced
1108 by music images in the resulting PDF or HTML output files. This
1109 makes it easy to mix music and text in documents.
1112 TODO: add extra chapter for computer aesthetics?
1116 @unnumberedsec Appendix
1118 This appendix contaions four reference engravings and two
1119 software-engraved versions of Bach's Fugue in G minor from the
1120 Well-Tempered Clavier, Book I, BWV 861 (the last seven measures).
1123 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1127 @sourceimage{bwv861-baer,16cm,,}
1130 @sourceimage{bwv861-baer-small,,,png}
1134 Bärenreiter BA5070 (Neue Ausgabe Sämtlicher Werke, Serie V, Band 6.1,
1135 1989), an alternate musical source. Aside from the textual differences,
1136 this demsontrates slight variations in the engraving decisions, even
1137 from the same publisher and edition:
1140 @sourceimage{bwv861-baer-alt,16cm,,}
1143 @sourceimage{bwv861-baer-alt-small,,,png}
1147 Breitkopf & Härtel, edited by Ferruccio Busoni (Wiesbaden, 1894), also
1148 available from the Petrucci Music Library (IMSLP #22081). The editorial
1149 markings (fingerings, articulations, etc.) have been removed for clearer
1150 comparison with the other editions here:
1153 @sourceimage{bwv861-breitkopf,16cm,,}
1156 @sourceimage{bwv861-breitkopf-small,,,png}
1160 Bach-Gessellschaft edition (Leipzig, 1866), available from the Petrucci
1161 Music Library (IMSPL #02221):
1164 @sourceimage{bwv861-gessellschaft,16cm,,}
1167 @sourceimage{bwv861-gessellschaft-small,,,png}
1174 @sourceimage{pdf/bwv861-finale2008a,,,}
1177 @sourceimage{bwv861-finale2008a,,,png}
1181 LilyPond, version @version{}:
1183 @lilypond[staffsize=14.3,line-width=15.9\cm]
1184 global = {\key g \minor}
1186 partI = \relative c' {
1188 fis8 d' ees g, fis4 g
1189 r8 a16 bes c8 bes16 a d8 r r4
1190 r2 r8 d16 ees f8 ees16 d
1191 ees4 ~ ees16 d c bes a4 r8 ees'16 d
1192 c8 d16 ees d8 e16 fis g8 fis16 g a4 ~
1193 a8 d, g f ees d c bes
1194 a2 g\fermata \bar "|."
1197 partII = \relative c' {
1199 d4 r4 r8 d'16 c bes8 c16 d
1200 ees8 d c ees a, r r4
1201 r8 fis16 g a8 g16 fis g2 ~
1203 fis4 g r8 a16 bes c8 bes16 a
1204 bes4. <g b>8 <a c> r <d, g> r
1207 partIII = \relative c' {
1209 r2 r8 d ees g, fis4 g r8 a16 bes c8 bes16 a
1210 bes2 ~ bes8 b16 a g8 a16 b
1214 r8 a16 bes c8 bes16 a b2
1216 partIV = \relative c {
1220 d,8 d'16 c bes8 c16 d ees2 ~
1221 ees8 ees16 d c8 d16 ees fis,8 a16 g fis8 g16 a
1222 d,8 d'16 c bes8 c16 d ees8 c a fis'
1229 % \set Score.barNumberVisibility = #all-bar-numbers-visible
1231 \set Score.currentBarNumber = #28
1234 \new Staff = "RH" <<
1236 \new Voice = "voiceI" { \partI }
1237 \new Voice = "voiceII" { \partII }
1240 \new Staff = "LH" <<
1243 \new Voice = "voiceIII" { \partIII }
1244 \new Voice = "voiceIV" { \partIV }
1251 \remove "Time_signature_engraver"