lilypond 1 learning

Upload: max-uno-pierini

Post on 07-Apr-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 LILYPOND 1 Learning

    1/198

    LilyPondThe music typesetter

    Learning Manual

    The LilyPond development team

    This le provides an introduction to LilyPond version 2.14.2.

    For more inormation about how this manual ts with the other documentation, or to read thismanual in other ormats, see Section Manuals in General Inormation.

    I you are missing any manuals, the complete documentation can be ound athttp://www.lilypond.org/ .

    Copyright c 19992011 by the authors.

    Permission is granted to copy, distribute and/or modiy this document under theterms o the GNU Free Documentation License, Version 1.1 or any later versionpublished by the Free Sotware Foundation; with no Invariant Sections. A copy othe license is included in the section entitled GNU Free Documentation License.

    For LilyPond version 2.14.2

    http://web.pdf/http://web.pdf/http://www.lilypond.org/http://www.lilypond.org/http://web.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    2/198

    i

    Table o Contents

    1 Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    11.1 Compiling a le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.1.1 Entering input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1.2 MacOS X. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.3 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.1.4 Command-line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.2 How to write input les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.2.1 Simple notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.2.2 Working on input les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    1.3 Dealing with errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.3.1 General troubleshooting tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    1.3.2 Some common errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    191.4 How to read the manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    1.4.1 Omitted material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.4.2 Clickable examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.4.3 Overview o manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    2 Common notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.1 Single staf notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    2.1.1 Bar checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.1.2 Accidentals and key signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.1.3 Ties and slurs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1.4 Articulation and dynamics

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24

    2.1.5 Adding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.1.6 Automatic and manual beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.1.7 Advanced rhythmic commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    2.2 Multiple notes at once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.2.1 Music expressions explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.2.2 Multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.2.3 Staf groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.2.4 Combining notes into chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.2.5 Single staf polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.3 Songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.3.1 Setting simple songs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    312.3.2 Aligning lyrics to a melody . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.3.3 Lyrics to multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.4 Final touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.4.1 Organizing pieces with variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.4.2 Adding titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.4.3 Absolute note names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.4.4 Ater the tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    3 Fundamental concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.1 How LilyPond input les work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.1.1 Introduction to the LilyPond le structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    413.1.2 Score is a (single) compound musical expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.1.3 Nesting music expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

  • 8/4/2019 LILYPOND 1 Learning

    3/198

    ii

    3.1.4 On the un-nestedness o brackets and ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.2 Voices contain music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    3.2.1 Im hearing Voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483.2.2 Explicitly instantiating voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.2.3 Voices and vocals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    3.3 Contexts and engravers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    583.3.1 Contexts explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.3.2 Creating contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593.3.3 Engravers explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613.3.4 Modiying context properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623.3.5 Adding and removing engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    3.4 Extending the templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.4.1 Soprano and cello . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.4.2 Four-part SATB vocal score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723.4.3 Building a score rom scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783.4.4 Saving typing with variables and unctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833.4.5 Scores and parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    4 Tweaking output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.1 Tweaking basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

    4.1.1 Introduction to tweaks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.1.2 Objects and interaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.1.3 Naming conventions o objects and properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884.1.4 Tweaking methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

    4.2 The Internals Reerence manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.2.1 Properties o layout objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.2.2 Properties ound in interaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954.2.3 Types o properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

    4.3 Appearance o objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    984.3.1 Visibility and color o objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984.3.2 Size o objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024.3.3 Length and thickness o objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    4.4 Placement o objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1064.4.1 Automatic behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1064.4.2 Within-staf objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    Fingering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084.4.3 Outside-staf objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    4.5 Collisions o objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1164.5.1 Moving objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    4.5.2 Fixing overlapping notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    1184.5.3 Real music example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

    4.6 Further tweaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1314.6.1 Other uses or tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1314.6.2 Using variables or tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1334.6.3 Style sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1354.6.4 Other sources o inormation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1394.6.5 Advanced tweaks with Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

  • 8/4/2019 LILYPOND 1 Learning

    4/198

    iii

    Appendix A Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142A.1 Single staf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    A.1.1 Notes only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142A.1.2 Notes and lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142A.1.3 Notes and chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

    A.1.4 Notes, lyrics, and chords.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    143A.2 Piano templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

    A.2.1 Solo piano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144A.2.2 Piano and melody with lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145A.2.3 Piano centered lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146A.2.4 Piano centered dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

    A.3 String quartet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148A.3.1 String quartet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148A.3.2 String quartet parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    A.4 Vocal ensembles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152A.4.1 SATB vocal score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    A.4.2 SATB vocal score and automatic piano reduction. . . . . . . . . . . . . . . . . . . . . . . . . . .

    154A.4.3 SATB with aligned contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156A.4.4 SATB on our staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157A.4.5 Solo verse and two-part rerain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159A.4.6 Hymn tunes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161A.4.7 Psalms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

    A.5 Orchestral templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166A.5.1 Orchestra, choir and piano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    A.6 Ancient notation templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169A.6.1 Transcription o mensural music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169A.6.2 Gregorian transcription template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    A.7 Other templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

    A.7.1 Jazz combo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    175

    Appendix B GNU Free Documentation License . . . . . . . . . . . 182

    Appendix C LilyPond index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

  • 8/4/2019 LILYPOND 1 Learning

    5/198

    Chapter 1: Tutorial 1

    1 Tutorial

    This chapter gives a basic introduction to working with LilyPond.

    1.1 Compiling a le

    This section introduces compilingthe processing o LilyPond input les (written by you) toproduce output les.

    1.1.1 Entering input

    Compiling is the term used or processing an input le in LilyPond ormat to produce outputle(s). Output les are generally PDF (or printing or viewing), MIDI (or playing), and PNG(or online use). LilyPond input les are simple text les.

    This example shows a simple input le:

    \version "2.14.2"

    {

    c' e' g' e'

    }

    The graphical output is:

    Note: Notes and lyrics in LilyPond input must always be surroundedby { curly braces }. The braces should also be surrounded by a spaceunless they are at the beginning or end o a line to avoid ambiguities.They may be omitted in some examples in this manual, but dont orgetthem in your own music! For more inormation about the display oexamples in the manual, see Section 1.4 [How to read the manuals],page 19.

    In addition, LilyPond input is case sensitive. { c d e } is valid input; { C D E } will producean error message.

    Producing outputThe method o producing output depends on your operating system and the program(s) youuse.

    Section 1.1.2 [MacOS X], page 2 Section 1.1.2 [MacOS X], page 2 (graphical)

    Section 1.1.3 [Windows], page 6 Section 1.1.3 [Windows], page 6 (graphical)

    Section 1.1.4 [Command-line], page 13 Section 1.1.4 [Command-line], page 13 (command-line)

    There are several other text editors available with specic support or LilyPond. For moreinormation, see Section Easier editing in General Inormation.

    Note: The rst time you ever run LilyPond, it may take a minute ortwo because all o the system onts have to be analyzed rst. Ater this,LilyPond will be much aster!

    http://web.pdf/http://web.pdf/http://web.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    6/198

    Chapter 1: Tutorial 2

    1.1.2 MacOS X

    Note: These instructions assume that you are using the LilyPond appli-cation. I you are using any o the programs described in Section Easierediting in General Inormation, please consult the documentation orthose programs i you have any problems.

    Step 1. Create your .ly le

    Double click the LilyPond.app, an example le will open.

    http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    7/198

    Chapter 1: Tutorial 3

    From the menus along the top let o your screen, select File > Save.

    Choose a name or your le, or example test.ly.

  • 8/4/2019 LILYPOND 1 Learning

    8/198

    Chapter 1: Tutorial 4

    Step 2. Compile (with LilyPad)

    From the same menus, select Compile > Typeset.

    A new window will open showing a progress log o the compilation o the le you have justsaved.

  • 8/4/2019 LILYPOND 1 Learning

    9/198

    Chapter 1: Tutorial 5

    Step 3. View output

    Once the compilation has nished, a PDF le will be created with the same name as the original

    le and will be automatically opened in the deault PDF viewer and displayed on your screen.

    Other commandsTo create new les or LilyPond, begin by selecting File > New

  • 8/4/2019 LILYPOND 1 Learning

    10/198

    Chapter 1: Tutorial 6

    or File > Open to open and edit existing les you have saved previously.

    You must save any new edits you make to your le beore you Compile > Typeset and i the

    PDF le is not displayed check the window with the progress log or any errors.

    I you are not using the deault Preview PDF viewer that comes with the Mac Operatingsystem and you have the PDF le generated rom a previous compilation open, then any urthercompilations may ail to generate an update PDF until you close the original.

    1.1.3 Windows

    Note: These instructions assume that you are using the built-in LilyPad

    editor. I you are using any o the programs described in Section Easierediting in General Inormation, please consult the documentation orthose programs i you have any problems compiling a le.

    http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    11/198

    Chapter 1: Tutorial 7

    Step 1. Create your .ly le

    Double-click the LilyPond icon on your desktop, an example le will open.

  • 8/4/2019 LILYPOND 1 Learning

    12/198

    Chapter 1: Tutorial 8

    From the menus that appear along the top o the example le, select File > Save as. Donot use the File > Save or the example le as this will not work until you have given it a validLilyPond le name.

    Choose a name or your le, or example test.ly.

  • 8/4/2019 LILYPOND 1 Learning

    13/198

    Chapter 1: Tutorial 9

    Step 2a. Compile (with drag-and-drop)

    Depending on what you preer, to compile your le either:

    Drag-and-drop the le directly onto the LilyPond icon.

  • 8/4/2019 LILYPOND 1 Learning

    14/198

    Chapter 1: Tutorial 10

    Right-click on the le and rom the pop-up context menu choose Open with > LilyPond.

    Step 2b. Compile (with double-clicking)

    Or simply double-click the test.ly.

    Step 3. View output

    During the compilation o the test.ly le, a command window will, very briey open andthen close. Three additional les will have been created during this process.

  • 8/4/2019 LILYPOND 1 Learning

    15/198

    Chapter 1: Tutorial 11

    The PDF le contains the engraved test.ly le.

    Other commands

    To create a new le, begin by selecting File > New rom within any previously created le.

  • 8/4/2019 LILYPOND 1 Learning

    16/198

    Chapter 1: Tutorial 12

    or File > Open to open and edit any les you have saved beore.

    You must save any new edits you make beore you compile it and i the PDF le is notcreated, check the log le that will have been created during the compilation attempt, or anyerrors.

    This log le is overwritten each time you compile your LilyPond le.

    The PS le is used internally by LilyPond to create the PDF le and can be ignored. It alsogets overwritten each time you compile your le.

    I you are viewing your le in a PDF viewer, then you must close the PDF i you wish tomake a new compilation as it may ail to create the new PDF while it is still being viewed.

  • 8/4/2019 LILYPOND 1 Learning

    17/198

    Chapter 1: Tutorial 13

    1.1.4 Command-line

    Note: These instructions assume that you are amiliar with command-

    line programs. I you are using any o the programs described in SectionEasier editing in General Inormation, please consult the documenta-tion or those programs i you have any problems compiling a le.

    Step 1. Create your .ly le

    Create a text le called test.ly and enter:

    \version "2.14.1"

    {

    c' e' g' e'

    }

    Step 2. Compile (with command-line)

    To process test.ly, type the ollowing at the command prompt:

    lilypond test.ly

    You will see something resembling:

    GNU LilyPond 2.14.1

    Processing `test.ly'

    Parsing...

    Interpreting music...

    Preprocessing graphical objects...Solving 1 page-breaking chunks...[1: 1 pages]

    Drawing systems...

    Layout output to `test.ps'...

    Converting to `./test.pdf'...

    Step 3. View output

    You may view or print the resulting test.pdf.

    1.2 How to write input les

    This section introduces some basic LilyPond syntax to help get you started writing input les.

    1.2.1 Simple notation

    LilyPond will add some notation elements automatically. In the next example, we have onlyspecied our pitches, but LilyPond has added a cle, time signature, and rhythms.

    {

    c' e' g' e'

    }

    This behavior may be altered, but in most cases these automatic values are useul.

    http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/http://web.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    18/198

    Chapter 1: Tutorial 14

    Pitches

    Music Glossary: Section pitch in Music Glossary, Section interval in Music Glossary,

    Section scale in Music Glossary, Section middle C in Music Glossary, Section octavein Music Glossary, Section accidental in Music Glossary.

    The easiest way to enter notes is by using \relative mode. In this mode, the octave is chosenautomatically by assuming the ollowing note is always to be placed closest to the previous note,i.e., it is to be placed in the octave which is within three staf spaces o the previous note. Webegin by entering the most elementary piece o music, a scale, in which every note is within justone staf space o the previous note.

    % set the starting point to middle C

    \relative c' {

    c d e f

    g a b c

    }

    The initial note is middle C. Each successive note is placed closest to the previous note in

    other words, the rst c is the closest C to middle C. This is ollowed by the closest D to theprevious note. We can create melodies which have larger intervals, still using only \relativemode:

    \relative c' {

    d f a gc b f d

    }

    It is not necessary or the rst note o the melody to start on the note which species the startingpitch. In the previous example, the rst note the d is the closest D to middle C.

    By adding (or removing) quotes ' or commas , rom the \relative c' command, we can

    change the starting octave:% one octave above middle C

    \relative c'' {

    e c a c

    }

    Relative mode can be conusing initially, but is the easiest way to enter most melodies. Let

    us see how this relative calculation works in practice. Starting rom a B, which is on the middleline in a treble cle, you can reach a C, D and E within 3 staf spaces going up, and an A, Gand F within 3 staf spaces going down. So i the note ollowing a B is a C, D or E it will beassumed to be above the B, and an A, G or F will be assumed to be below.

    http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    19/198

    Chapter 1: Tutorial 15

    \relative c'' {

    b c % c is 1 staff space up, so is the c above

    b d % d is 2 up or 5 down, so is the d above

    b e % e is 3 up or 4 down, so is the e aboveb a % a is 6 up or 1 down, so is the a below

    b g % g is 5 up or 2 down, so is the g below

    b f % f is 4 up or 3 down, so is the f below

    }

    Exactly the same happens even when any o these notes are sharpened or attened. Acci-

    dentals are totally ignored in the calculation o relative position. Precisely the same staf spacecounting is done rom a note at any other position on the staf.

    To add intervals that are larger than three staf spaces, we can raise the octave by adding asingle quote ' (or apostrophe) to the note name. We can lower the octave by adding a comma, to the note name.

    \relative c'' {

    a a, c' f,

    g g'' a,, f'

    }

    To change a note by two (or more!) octaves, we use multiple '' or ,, but be careul that youuse two single quotes '' and not one double quote " !

    Durations (rhythms)

    Music Glossary: Section beam in Music Glossary, Section duration in Music Glossary,Section whole note in Music Glossary, Section hal note in Music Glossary, Section quarter

    note in Music Glossary, Section dotted note in Music Glossary.The duration o a note is specied by a number ater the note name: 1 or a whole note, 2

    or a hal note, 4 or a quarter note and so on. Beams are added automatically.

    I you do not speciy a duration, the previous duration is used or the next note. The durationo the rst note deaults to a quarter note.

    \relative c'' {

    a1

    a2 a4 a8 a

    a 1 6 a a a a 3 2 a a a a 6 4 a a a a a a a a 2

    }

    http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    20/198

    Chapter 1: Tutorial 16

    3

    To create dotted notes, add a dot . to the duration number. The duration o a dotted note

    must be stated explicitly (i.e., with a number).\relative c'' {

    a4 a a4. a8

    a8. a16 a a8. a8 a4.

    }

    Rests

    Music Glossary: Section rest in Music Glossary.A rest is entered just like a note with the name r :

    \relative c'' {

    a4 r r2

    r8 a r4 r4. r8

    }

    Time signatureMusic Glossary: Section time signature in Music Glossary.

    The time signature can be set with the \time command:

    \relative c'' {

    \time 3/4

    a 4 a a

    \time 6/8

    a4. a

    \time 4/4

    a 4 a a a

    }

    86 43 Tempo marks

    Music Glossary: Section tempo indication in Music Glossary, Section metronome in MusicGlossary.

    The tempo indication and metronome mark can be set with the \tempo command:

    \relative c'' {

    \time 3/4\tempo "Andante"

    a 4 a a

    \time 6/8

    http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    21/198

    Chapter 1: Tutorial 17

    \tempo 4. = 96

    a4. a

    \time 4/4

    \tempo "Presto" 4 = 120a 4 a a a

    }

    Presto ( = 120)

    = 96

    86 Andante

    43 Cle

    Music Glossary: Section cle in Music Glossary.

    The cle can be set using the \clef command:\relative c' {

    \clef "treble"

    c1

    \clef "alto"

    c1

    \clef "tenor"

    c1

    \clef "bass"

    c1

    }

    All together

    Here is a small example showing all these elements together:

    \relative c, {

    \clef "bass"

    \time 3/4

    \tempo "Andante" 4 = 120

    c2 e8 c'g'2.

    f 4 e d

    c4 c, r

    }

    Andante ( = 120)

    43

    See alsoNotation Reerence: Section Writing pitches in Notation Reerence, Section Writing

    rhythms in Notation Reerence, Section Writing rests in Notation Reerence, Section Timesignature in Notation Reerence, Section Cle in Notation Reerence.

    http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    22/198

    Chapter 1: Tutorial 18

    1.2.2 Working on input les

    LilyPond input les are similar to source les in many common programming languages. They

    contain a version statement, are case sensitive, and white-space is generally ignored. Expressionsare ormed with curly braces { }, and comments are denoted with % or %{ ... %} .

    I the previous sentences sound like nonsense, dont worry! Well explain what all these termsmean:

    Version statement: Every LilyPond le should contain a version statement. A versionstatement is a line that describes the version o LilyPond or which the le was written, asin the ollowing example:

    \version "2.14.2"

    By convention, the version statement is placed at the top o the LilyPond le.

    The version statement is important or at least two reasons. First, it allows automatic

    updating o the input le as LilyPond syntax changes. Second, it describes the version oLilyPond needed to compile the le.

    I the version statement is omitted rom an input le, LilyPond will print a warning duringthe compilation o the le.

    Case sensitive: it matters whether you enter a letter in lower case (e.g. a, b, s, t) orupper case (e.g. A, B, S, T). Notes are lower case: { c d e } is valid input; { C D E }will produce an error message.

    Whitespace insensitive: it does not matter how many spaces (or tabs or new lines) you add.{ c4 d e } means the same thing as { c4 d e } and:

    { c4 d

    e }

    O course, the previous example is hard to read. A good rule o thumb is to indent codeblocks with two spaces:

    {

    c 4 d e

    }

    However, whitespace is required to separate many syntactical elements rom others. Inother words, whitespace can always be added, but not always eliminated. Since missingwhitespace can give rise to strange errors, it is advisable to always insert whitespace beoreand ater every syntactic element, or example, beore and ater every curly brace.

    Expressions: every piece o LilyPond input needs to have { curly braces } placed around

    the input. These braces tell LilyPond that the input is a single music expression, just likeparentheses () in mathematics. The braces should be surrounded by a space unless theyare at the beginning or end o a line to avoid ambiguities.

    A LilyPond command ollowed by a simple expression in braces (such as\relative c' { ... }) also counts as a single music expression.

    Comments: a comment is a remark or the human reader o the music input; it is ignoredwhile parsing, so it has no efect on the printed output. There are two types o comments.The percent symbol % introduces a line comment; anything ater % on that line is ignored.By convention, a line comment is placed above the code it reers to.

    a 4 a a a

    % this comment refers to the Bsb2 b

    A block comment marks a whole section o music input as a comment. Anything that isenclosed in %{ and %} is ignored. However, block comments do not nest. This means that

  • 8/4/2019 LILYPOND 1 Learning

    23/198

    Chapter 1: Tutorial 19

    you cannot place a block comment inside another block comment. I you try, the rst %} willterminate both block comments. The ollowing ragment shows possible uses or comments:

    % notes for twinkle twinkle follow

    c 4 c g ' g a a g 2

    %{

    This line, and the notes below are ignored,

    since they are in a block comment.

    f 4 f e e d d c 2

    %}

    1.3 Dealing with errors

    Sometimes LilyPond doesnt produce the output you expect. This section provides some linksto help you solve the problems you might encounter.

    1.3.1 General troubleshooting tips

    Troubleshooting LilyPond problems can be challenging or people who are used to a graphicalinterace, because invalid input les can be created. When this happens, a logical approach isthe best way to identiy and solve the problem. Some guidelines to help you learn to do this areprovided in Section Troubleshooting in Application Usage.

    1.3.2 Some common errors

    There are a ew common errors that are dicult to troubleshoot based simply on the errormessages that are displayed. These are described in Section Common errors in ApplicationUsage.

    1.4 How to read the manuals

    This section shows how to read the documentation eciently, and also introduces some useulinteractive eatures available in the online version.

    1.4.1 Omitted material

    LilyPond input must be surrounded by { } marks or a \relative c'' { ... }, as we saw inSection 1.2.2 [Working on input les], page 18. For the rest o this manual, most examples will

    omit this. To replicate the examples, you may copy and paste the displayed input, but you mustadd the \relative c'' { ... } like this:

    \relative c'' {

    ...example goes here...

    }

    Why omit the braces? Most examples in this manual can be inserted into themiddle o a longer piece o music. For these examples, it does not make sense to add\relative c'' { ... } you should not place a \relative inside another \relative! Iwe included \relative c'' { ... } around every example, you would not be able to copy asmall documentation example and paste it inside a longer piece o your own. Most people want

    to add material to an existing piece, so we ormat the manual this way.Also, remember that every LilyPond le should have a \version statement. Because the

    examples in the manuals are snippets, not les, the \version statement is omitted. But youshould make a practice o including them in your les.

    http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    24/198

    Chapter 1: Tutorial 20

    1.4.2 Clickable examples

    Note: This eature is only available in the HTML manuals.

    Many people learn programs by trying and ddling around with the program. This is alsopossible with LilyPond. I you click on a picture in the HTML version o this manual, you willsee the exact LilyPond input that was used to generate that image. Try it on this image:

    Clickhere.

    By cutting and pasting everything in the ly snippet section, you have a starting template

    or experiments. To see exactly the same output (line-width and all), copy everything romStart cut-&-pastable section to the bottom o the le.

    1.4.3 Overview o manuals

    There is a lot o documentation or LilyPond. New users are sometimes conused about whatpart(s) they should read, and occasionally skip over reading vital portions.

    Note: Please do not skip over important parts o the documentation.You will nd it much harder to understand later sections.

    Beore trying to do anything: read the Learning manuals Chapter 1 [Tutorial], page 1, and

    Chapter 2 [Common notation], page 21. I you encounter musical terms which you do notrecognize, please look them up in the Section Glossary in Music Glossary.

    Beore trying to write a complete piece o music: read the Learning manuals Chapter 3[Fundamental concepts], page 41. Ater that, you may want to look in relevant sections othe Section Notation reerence in Notation Reerence.

    Beore trying to change the deault output: read the Learning manuals Chapter 4 [Tweak-ing output], page 87.

    Beore undertaking a large project: read the Usage documents Section Suggestions orwriting les in Application Usage.

    http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://usage.pdf/http://notation.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    25/198

    Chapter 2: Common notation 21

    2 Common notation

    This chapter explains how to create beautiul printed music containing common musical notation,ollowing the material in Chapter 1 [Tutorial], page 1.

    2.1 Single staf notation

    This section introduces common notation that is used or one voice on one staf.

    2.1.1 Bar checks

    Though not strictly necessary, bar checks should be used in the input code to show where barlines are expected to all. They are entered using the bar symbol, |. With bar checks, theprogram can veriy that youve entered durations that make each measure add up to the correctlength. Bar checks also make your input code easier to read, since they help to keep things

    organized.g 1 | e 1 | c 2 . c ' 4 | g 4 c g e | c 4 r r 2 |

    See also

    Notation Reerence: Section Bar and bar number checks in Notation Reerence.

    2.1.2 Accidentals and key signatures

    Note: New users are oten conused by these please read the warningat the bottom o this page, especially i you are not amiliar with musictheory!

    Accidentals

    Music Glossary: Section sharp in Music Glossary, Section at in Music Glossary, Sectiondouble sharp in Music Glossary, Section double at in Music Glossary, Section accidentalin Music Glossary.

    A sharp pitch is made by adding is to the name, and a at pitch by adding es. As youmight expect, a double sharp or double at is made by adding isis or eses. This syntax isderived rom note naming conventions in Nordic and Germanic languages, like German andDutch. To use other names or accidentals, see Section Note names in other languages inNotation Reerence.

    cis4 ees fisis, aeses

    Key signatures

    Music Glossary: Section key signature in Music Glossary, Section major in Music Glossary,Section minor in Music Glossary.

    The key signature is set with the command \key ollowed by a pitch and \major or \minor.

    http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    26/198

    Chapter 2: Common notation 22

    \key d \major

    a1 |

    \key c \minor

    a1 |

    Warning: key signatures and pitches

    Music Glossary: Section accidental in Music Glossary, Section key signature in Music Glos-sary, Section pitch in Music Glossary, Section at in Music Glossary, Section natural inMusic Glossary, Section sharp in Music Glossary, Section transposition in Music Glossary,

    Section Pitch names in Music Glossary.

    To determine whether to print an accidental, LilyPond examines the pitches and the keysignature. The key signature only afects the printed accidentals, not the notes pitch! This isa eature that oten causes conusion to newcomers, so let us explain it in more detail.

    LilyPond makes a clear distinction between musical content and layout. The alteration ( at,natural sign or sharp) o a note is part o the pitch, and is thereore musical content. Whetheran accidental (a printed at, natural or sharp sign) is printed in ront o the correspondingnote is a question o layout. Layout is something that ollows rules, so accidentals are printedautomatically according to those rules. The pitches in your music are works o art, so they willnot be added automatically, and you must enter what you want to hear.

    In this example:\key d \major

    cis4 d e fis

    No note has a printed accidental, but you must still add is and type cis and fis in the inputle.

    The code b does not mean print a black dot just on the middle line o the staf. Rather,

    it means there is a note with pitch B-natural. In the key o A-at major, it does get anaccidental:

    \key aes \major

    aes4 c b c

    I the above seems conusing, consider this: i you were playing a piano, which key would you

    hit? I you would press a black key, then you must add -is or -es to the note name!

    Adding all alterations explicitly might require a little more efort when typing, but theadvantage is that transposing is easier, and accidentals can be printed according to diferentconventions. For some examples o how accidentals can be printed according to diferent rules,see Section Automatic accidentals in Notation Reerence.

    http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    27/198

    Chapter 2: Common notation 23

    See also

    Notation Reerence: Section Note names in other languages in Notation Reerence, Section

    Accidentals in Notation Reerence, Section Automatic accidentals in Notation Reerence,Section Key signature in Notation Reerence.

    2.1.3 Ties and slurs

    Ties

    Music Glossary: Section tie in Music Glossary.

    A tie is created by appending a tilde ~ to the rst note being tied.

    g4~ g c2~ | c4~ c8 a~ a2 |

    Slurs

    Music Glossary: Section slur in Music Glossary.

    A slur is a curve drawn across many notes. The starting note and ending note are markedwith ( and ) respectively.

    d4( c16) cis( d e c cis d) e( d4)

    Phrasing slurs

    Music Glossary: Section slur in Music Glossary, Section phrasing in Music Glossary.

    Slurs to indicate longer phrasing can be entered with \( and \). You can have both slursand phrasing slurs at the same time, but you cannot have simultaneous slurs or simultaneousphrasing slurs.

    g4\( g8( a) b( c) b4\)

    Warnings: slurs vs. ties

    Music Glossary: Section articulation in Music Glossary, Section slur in Music Glossary,Section tie in Music Glossary.

    A slur looks like a tie, but it has a diferent meaning. A tie simply makes the rst note longer,and can only be used on pairs o notes with the same pitch. Slurs indicate the articulation onotes, and can be used on larger groups o notes. Slurs and ties can be nested.

    c4~( c8 d~ d4 e)

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    28/198

    Chapter 2: Common notation 24

    See also

    Notation Reerence: Section Ties in Notation Reerence, Section Slurs in Notation Re-

    erence, Section Phrasing slurs in Notation Reerence.2.1.4 Articulation and dynamics

    Articulations

    Music Glossary: Section articulation in Music Glossary.

    Common articulations can be added to a note using a dash - and a single character:

    c4-^ c-+ c-- c-|

    c4-> c-. c2-_

    Fingerings

    Music Glossary: Section ngering in Music Glossary.

    Similarly, fngering indications can be added to a note using a dash (-) and the digit to beprinted:

    c4-3 e-5 b-2 a-1

    3

    2

    15

    Articulations and ngerings are usually placed automatically, but you can speciy a directionby replacing the dash (-) with ^ (up) or _ (down). You can also use multiple articulations onthe same note. However, in most cases it is best to let LilyPond determine the articulationdirections.

    c4_-^1 d^. f^4_2-> e^-_+

    2

    4

    1

    Dynamics

    Music Glossary: Section dynamics in Music Glossary, Section crescendo in Music Glossary,Section decrescendo in Music Glossary.

    Dynamic signs are made by adding the markings (with a backslash) to the note:

    c4\ff c\mf c\p c\pp

    p pp

    mfff

    Crescendi and decrescendi are started with the commands \< and \>. The next dynamicssign, or example \f, will end the (de)crescendo, or the command \! can be used:

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    29/198

    Chapter 2: Common notation 25

    c4\< c\ff\> c c\!

    ff See also

    Notation Reerence: Section Articulations and ornamentations in Notation Reerence,Section Fingering instructions in Notation Reerence, Section Dynamics in Notation Reer-ence.

    2.1.5 Adding text

    Text may be added to your scores:c2^"espr" a_"legato"

    espr legato

    Extra ormatting may be added with the \markup command:

    c2^\markup { \bold espr }

    a2_\markup {

    \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p

    }

    espr f2nd p

    See also

    Notation Reerence: Section Writing text in Notation Reerence.

    2.1.6 Automatic and manual beams

    Music Glossary: Section beam in Music Glossary.All beams are drawn automatically:

    a8 ais d ees r d c16 b a8

    I you do not like the automatic beams, they may be overridden manually. To correct justan occasional beam mark the rst note to be beamed with [ and the last one with ].

    a8[ ais] d[ ees r d] c16 b a8

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    30/198

    Chapter 2: Common notation 26

    I you want to turn of automatic beaming entirely or or an extended section o music, usethe command \autoBeamOff to turn of automatic beaming and \autoBeamOn to turn it onagain.

    \autoBeamOff

    a8 c b4 d8. c16 b4 |

    \autoBeamOn

    a8 c b4 d8. c16 b4 |

    See also

    Notation Reerence: Section Automatic beams in Notation Reerence, Section Manualbeams in Notation Reerence.

    2.1.7 Advanced rhythmic commands

    Partial measure

    Music Glossary: Section anacrusis in Music Glossary.

    A pickup (or anacrusis) is entered with the keyword \partial. It is ollowed by a duration:\partial 4 is a quarter note pickup and \partial 8 an eighth note.

    \partial 8 f8 |

    c 2 d |

    Tuplets

    Music Glossary: Section note value in Music Glossary, Section triplet in Music Glossary.

    Tuplets are made with the \times keyword. It takes two arguments: a raction and a pieceo music. The duration o the piece o music is multiplied by the raction. Triplets make notesoccupy 2/3 o their notated duration, so a triplet has 2/3 as its raction

    \times 2/3 { f8 g a }\times 2/3 { c8 r c }

    \times 2/3 { f,8 g16[ a g a] }

    \times 2/3 { d4 a8 }

    3

    3

    3

    3

    Grace notes

    Music Glossary: Section grace notes in Music Glossary, Section acciaccatura in MusicGlossary, Section appoggiatura in Music Glossary.

    Grace notes are created with the \grace command, although they can also be created byprexing a music expression with the keyword \appoggiatura or \acciaccatura:

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    31/198

    Chapter 2: Common notation 27

    c2 \grace { a32[ b] } c2 |

    c2 \appoggiatura b16 c2 |

    c2 \acciaccatura b16 c2 |

    See also

    Notation Reerence: Section Grace notes in Notation Reerence, Section Tuplets in No-tation Reerence, Section Upbeats in Notation Reerence.

    2.2 Multiple notes at once

    This section introduces having more than one note at the same time: multiple instruments,multiple staves or a single instrument (i.e. piano), and chords.

    Polyphony in music reers to having more than one voice occurring in a piece o music.Polyphony in LilyPond reers to having more than one voice on the same staf.

    2.2.1 Music expressions explained

    In LilyPond input les, music is represented by music expressions. A single note is a musicexpression:

    a4

    Enclosing a note in braces creates a compound music expression. Here we have created a

    compound music expression with two notes:

    { a 4 g 4 }

    Putting a group o music expressions (e.g. notes) in braces means that they are in sequence

    (i.e. each one ollows the previous one). The result is another music expression:

    { { a 4 g } f 4 g }

    Analogy: mathematical expressionsThis mechanism is similar to mathematical ormulas: a big ormula is created by composingsmall ormulas. Such ormulas are called expressions, and they can contain other expressions,so you can make arbitrarily complex and large expressions. For example,

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    32/198

    Chapter 2: Common notation 28

    1

    1 + 2

    ( 1 + 2 ) * 3

    ((1 + 2) * 3) / (4 * 5)

    This is a sequence o expressions, where each expression is contained in the next (larger) one.The simplest expressions are numbers, and larger ones are made by combining expressions withoperators (like +, * and /) and parentheses. Like mathematical expressions, music expressionscan be nested arbitrarily deep, which is necessary or complex music like polyphonic scores.

    Simultaneous music expressions: multiple staves

    Music Glossary: Section polyphony in Music Glossary.

    This technique is useul or polyphonic music. To enter music with more voices or morestaves, we combine expressions in parallel. To indicate that two voices should play at the sametime, simply enter a simultaneous combination o music expressions. A simultaneous musicexpression is ormed by enclosing expressions inside >. In the ollowing example, threesequences (all containing two separate notes) are combined simultaneously:

    \relative c'' {

    >}

    Note that we have indented each level o the input with a diferent amount o space. LilyPond

    does not care how much (or little) space there is at the beginning o a line, but indenting LilyPondcode like this makes it much easier or humans to read.

    Note: each note is relative to the previous note in the input, not relativeto the c'' in the initial \relative command.

    Simultaneous music expressions: single staf

    To determine the number o staves in a piece, LilyPond looks at the beginning o the rstexpression. I there is a single note, there is one staf; i there is a simultaneous expression, thereis more than one staf. The ollowing example shows a complex expression, but as it begins witha single note it will be set out on a single staf.

    http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    33/198

    Chapter 2: Common notation 29

    \relative c'' {

    c2 |

    > |

    }

    2.2.2 Multiple staves

    LilyPond input les are constructed out o music expressions, as we saw in Section 2.2.1 [Musicexpressions explained], page 27. I the score begins with simultaneous music expressions, Lily-Pond creates multiples staves. However, it is easier to see what happens i we create each staf

    explicitly.

    To print more than one staf, each piece o music that makes up a staf is marked by adding\new Staff beore it. These Staff elements are then combined in parallel with >:

    \relative c'' {

    >

    }

    The command \new introduces a notation context. A notation context is an environmentin which musical events (like notes or \clef commands) are interpreted. For simple pieces,such notation contexts are created automatically. For more complex pieces, it is best to markcontexts explicitly.

    There are several types o contexts. Score, Staff, and Voice handle melodic notation, whileLyrics sets lyric texts and ChordNames prints chord names.

    In terms o syntax, prepending \new to a music expression creates a bigger music expression.In this way it resembles the minus sign in mathematics. The ormula (4 + 5) is an expression,so (4 + 5) is a bigger expression.

    Time signatures entered in one staf afect all other staves by deault. On the other hand, thekey signature o one staf does not afect other staves. This diferent deault behavior is becausescores with transposing instruments are more common than polyrhythmic scores.

    \relative c'' {

    >

    }

  • 8/4/2019 LILYPOND 1 Learning

    34/198

    Chapter 2: Common notation 30

    43

    43

    2.2.3 Staf groups

    Music Glossary: Section brace in Music Glossary, Section staf in Music Glossary, Sectionsystem in Music Glossary.

    Piano music is typeset in two staves connected by a brace. Printing such a staf is similarto the polyphonic example in Section 2.2.2 [Multiple staves], page 29. However, now this entireexpression is inserted inside a PianoStaff:

    \new PianoStaff >

    Here is a small example:

    \relative c'' {

    \new PianoStaff

  • 8/4/2019 LILYPOND 1 Learning

    35/198

    Chapter 2: Common notation 31

    Think o chords as almost equivalent to single notes: almost everything you can attach toa single note can be attached to a chord, and everything must go outside the angle brackets.For example, you can combine markings like beams and ties with chords. They must be placed

    outside the angle brackets.

    r4 ~ 2 |

    8[ ] \>[ ]\! |

    r4 8.\p 16( 4-. ) |

    p

    See alsoNotation Reerence: Section Chorded notes in Notation Reerence.

    2.2.5 Single staf polyphony

    Polyphonic music in lilypond, while not dicult, uses concepts that we havent discussed yet, sowere not going to introduce them here. Instead, the ollowing sections introduce these conceptsand explain them thoroughly.

    See also

    Learning Manual: Section 3.2 [Voices contain music], page 47.

    Notation Reerence: Section Simultaneous notes in Notation Reerence.

    2.3 Songs

    This section introduces vocal music and simple song sheets.

    2.3.1 Setting simple songs

    Music Glossary: Section lyrics in Music Glossary.

    Here is the start o the melody to a nursery rhyme, Girls and boys come out to play:

    \relative c'' {

    \key g \major

    \time 6/8

    d4 b8 c4 a8 | d4 b8 g4}

    86

    The lyrics can be set to these notes, combining both with the \addlyrics keyword. Lyricsare entered by separating each syllable with a space.

  • 8/4/2019 LILYPOND 1 Learning

    36/198

    Chapter 2: Common notation 32

    \addlyrics {

    Girls and boys come | out to play,

    }

    >>

    outGirls

    play,

    86and

    come

    toboys

    Note: It is essential that the nal syllable is separated rom the ter-minating curly bracket by a space or a newline, or it will be assumedto be part o the syllable, giving rise to an obscure error, see SectionApparent error in ../ly/init.ly in Application Usage.

    Note the double angle brackets > around the whole piece to show that the musicand lyrics are to occur at the same time.

    2.3.2 Aligning lyrics to a melody

    Music Glossary: Section melisma in Music Glossary, Section extender line in Music Glos-sary.

    The next line in the nursery rhyme is The moon doth shine as bright as day. Lets extend it:

    >

    to

    The

    out

    Girls

    come

    and

    boys

    play,86

    as

    day;

    shine

    moon bright

    3

    doth

    as

    I you compile the code in the example above, you should see some warnings in the console

    output:song.ly:12:29: warning: barcheck failed at: 5/8

    The | moon doth shine as

    | bright as day; |

    http://usage.pdf/http://usage.pdf/http://usage.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://usage.pdf/http://usage.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    37/198

    Chapter 2: Common notation 33

    song.ly:12:46: warning: barcheck failed at: 3/8

    The | moon doth shine as | bright as day;

    |

    This is a good example o the useulness o bar checks. Now, looking at the music, we seethat the extra lyrics do not align properly with the notes. The word shine should be sung ontwo notes, not one. This is called a melisma, a single syllable sung to more than one note. Thereare several ways to spread a syllable over multiple notes, the simplest being to add a slur acrossthem, or details, see Section 2.1.3 [Ties and slurs], page 23:

    >

    to

    boys

    and

    come

    Girls

    The

    play,

    out

    86

    day;

    bright

    3

    doth

    asshine as

    moon

    The words now line up correctly with the notes, but the automatic beaming or the notes

    above shine as does not look right. We can correct this by inserting manual beaming commandsto override the automatic beaming here, or details, see Section 2.1.6 [Automatic and manualbeams], page 25.

    >

    come

    The

    Girls

    86and

    play,

    outboys

    to

  • 8/4/2019 LILYPOND 1 Learning

    38/198

    Chapter 2: Common notation 34

    as

    doth

    shine

    day;as

    moon

    3

    bright

    As an alternative to using slurs, the melismata may be indicated in just the lyrics by usingan underscore _ or each note that should be included in the melisma:

    >

    out

    The

    86 boys

    and

    Girls

    tocome

    play,

    moon

    bright

    doth

    as

    3as

    day;

    shine

    I a syllable extends over several notes or a single very long note an extender line is usuallydrawn rom the syllable extending under all the notes or that syllable. It is entered as twounderscores __. Here is an example rom the rst three bars o Didos Lament, rom PurcellsDido and neas:

    >

    23

    am

    in

    laid,

    earth,

    When

    I

    laid

    am

    None o the examples so ar have involved words containing more than one syllable. Such

    words are usually split one syllable to a note, with hyphens between syllables. Such hyphens are

  • 8/4/2019 LILYPOND 1 Learning

    39/198

    Chapter 2: Common notation 35

    entered as two dashes, resulting in a centered hyphen between the syllables. Here is an exampleshowing this and everything we have learned so ar about aligning lyrics to notes.

    >

    fac

    del

    cit

    86

    la

    to

    t

    go al

    tumLar

    See also

    Notation Reerence: Section Vocal music in Notation Reerence.

    2.3.3 Lyrics to multiple staves

    The simple approach using \addlyrics can be used or placing lyrics under more than one staf.Here is an example rom Handels Judas Maccabus:

  • 8/4/2019 LILYPOND 1 Learning

    40/198

    Chapter 2: Common notation 36

    \key f \major

    \time 6/8

    \partial 8

    c8 | c8([ bes]) a a([ g]) f | f'4. b, | c4.~ c4}

    \addlyrics {

    Let | flee -- cy flocks the | hills a -- | dorn, __

    }

    \relative c' {

    \key f \major

    \time 6/8

    \partial 8

    r8 | r4. r4 c8 | a'8([ g]) f f([ e]) d | e8([ d]) c bes'4

    }

    \addlyrics {Let | flee -- cy flocks the | hills a -- dorn,

    }

    >>

    a

    flocks

    cy

    dorn,

    cythe

    Let hills

    Let

    dorn,

    a

    86

    86

    flee

    flee

    the

    flocks

    hills

    Scores any more complex than this simple example are better produced by separating outthe score structure rom the notes and lyrics with variables. These are discussed in Section 2.4.1[Organizing pieces with variables], page 36.

    See also

    Notation Reerence: Section Vocal music in Notation Reerence.

    2.4 Final touches

    This is the nal section o the tutorial; it demonstrates how to add the nal touches to simplepieces, and provides an introduction to the rest o the manual.

    2.4.1 Organizing pieces with variables

    When all o the elements discussed earlier are combined to produce larger les, the music ex-pressions get a lot bigger. In polyphonic music with many staves, the input les can becomevery conusing. We can reduce this conusion by using variables.

    With variables (also known as identiers or macros), we can break up complex music expres-sions. A variable is assigned as ollows:

    namedMusic = { ... }

    The contents o the music expression namedMusic can be used later by placing a backslashin ront o the name (\namedMusic, just like a normal LilyPond command).

    violin = \new Staff {

    \relative c'' {

    http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    41/198

    Chapter 2: Common notation 37

    a 4 b c b

    }

    }

    cello = \new Staff {

    \relative c {

    \clef "bass"

    e2 d

    }

    }

    {

    >

    }

    The name o a variable must have alphabetic characters only, no numbers, underscores, ordashes.

    Variables must be dened before the main music expression, but may be used as many timesas required anywhere ater they have been dened. They may even be used in a later denitiono another variable, giving a way o shortening the input i a section o music is repeated manytimes.

    tripletA = \times 2/3 { c,8 e g }

    barA = { \tripletA \tripletA \tripletA \tripletA }

    \relative c'' {

    \barA \barA

    }

    3

    3

    33 3

    3

    3 3 Variables may be used or many other types o objects in the input. For example,

    width = 4.5\cm

    name = "Wendy"

    aFivePaper = \paper { paperheight = 21.0 \cm }

    Depending on its contents, the variable can be used in diferent places. The ollowing example

    uses the above variables:\paper {

    \aFivePaper

    line-width = \width

  • 8/4/2019 LILYPOND 1 Learning

    42/198

    Chapter 2: Common notation 38

    }

    {

    c4^\name}

    2.4.2 Adding titles

    The title, composer, opus number, and similar inormation are entered in the \header block.This exists outside o the main music expression; the \header block is usually placed underneaththe version number.

    \version "2.14.2"

    \header {

    title = "Symphony"

    composer = "Me"

    opus = "Op. 9"

    }

    {

    ... music ...

    }

    When the le is processed, the title and composer are printed above the music. More inor-mation on titling can be ound in Section Creating titles in Notation Reerence.

    2.4.3 Absolute note names

    So ar we have always used \relative to dene pitches. This is the easiest way to enter mostmusic, but another way o dening pitches exists: absolute mode.

    I you omit the \relative, LilyPond treats all pitches as absolute values. A c' will alwaysmean middle C, a b will always mean the note one step below middle C, and a g, will alwaysmean the note on the bottom staf o the bass cle.

    {

    \clef "bass"

    c'4 b g, g, |

    g,4 f, f c' |

    }

    Here is a our-octave scale:

    {

    \clef "bass"

    c,4 d, e, f, |

    g,4 a, b, c |

    d4 e f g |

    a 4 b c ' d ' |

    \clef "treble"e'4 f' g' a' |

    b'4 c'' d'' e'' |

    f''4 g'' a'' b'' |

    http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    43/198

    Chapter 2: Common notation 39

    c'''1 |

    }

    5

    As you can see, writing a melody in the treble cle involves a lot o quote ' marks. Considerthis ragment rom Mozart:

    {\key a \major

    \time 6/8

    cis''8. d''16 cis''8 e''4 e''8 |

    b'8. cis''16 b'8 d''4 d''8 |

    }

    86

    All these quotes makes the input less readable and they are a source o errors. With

    \relative, the previous example is much easier to read and type:\relative c'' {

    \key a \major

    \time 6/8

    cis8. d16 cis8 e4 e8 |

    b8. cis16 b8 d4 d8 |

    }

    86

    I you make a mistake with an octave mark (' or ,) while working in \relative mode, itis very obvious many notes will be in the wrong octave. When working in absolute mode, asingle mistake will not be as visible, and will not be as easy to nd.

    However, absolute mode is useul or music which has large intervals, and is extremely useulor computer-generated LilyPond les.

    2.4.4 Ater the tutorial

    Ater nishing the tutorial, you should probably try writing a piece or two. Start by addingnotes to one o the Appendix A [Templates], page 142. I you need any notation that was notcovered in the tutorial, look at the Notation Reerence, starting with Section Musical notation

    in Notation Reerence. I you want to write or an instrument ensemble that is not covered inthe templates, take a look at Section 3.4 [Extending the templates], page 69.

    Once you have written a ew short pieces, read the rest o the Learning Manual (chapters 3-5).Theres nothing wrong with reading it now, o course! However, the rest o the Learning Manual

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    44/198

    Chapter 2: Common notation 40

    assumes that you are amiliar with LilyPond input. You may wish to skim these chapters rightnow, and come back to them ater you have more experience.

    In this tutorial and in the rest o the Learning Manual, there is a paragraph See also atthe end o each section, which contains cross-reerences to other sections: you should not ollowthese cross-reerences at rst reading; when you have read all o the Learning Manual, you maywant to read some sections again and ollow cross-reerences or urther reading.

    I you have not done so already, please read Section 1.4.3 [Overview o manuals], page 20.There is a lot o inormation about LilyPond, so newcomers oten do not know where they shouldlook or help. I you spend ve minutes reading that section careully, you might save yourselhours o rustration looking in the wrong places!

  • 8/4/2019 LILYPOND 1 Learning

    45/198

    Chapter 3: Fundamental concepts 41

    3 Fundamental concepts

    Youve seen in the Tutorial how to produce beautiully printed music rom a simple text le.This section introduces the concepts and techniques required to produce equally beautiul butmore complex scores.

    3.1 How LilyPond input les work

    The LilyPond input ormat is quite ree-orm, giving experienced users a lot o exibility tostructure their les however they wish. But this exibility can make things conusing or newusers. This section will explain some o this structure, but may gloss over some details in avoro simplicity. For a complete description o the input ormat, see Section File structure inNotation Reerence.

    3.1.1 Introduction to the LilyPond le structureA basic example o a LilyPond input le is

    \version "2.14.2"

    \header { }

    \score {

    ...compound music expression... % all the music goes here!

    \layout { }

    \midi { }

    }

    There are many variations o this basic pattern, but this example serves as a useul startingplace.

    Up to this point none o the examples you have seen have used a \score{} command. Thisis because LilyPond automatically adds the extra commands which are needed when you give itsimple input. LilyPond treats input like this:

    \relative c'' {

    c 4 a d c

    }

    as shorthand or this:

    \book {

    \score {\new Staff {

    \new Voice {

    \relative c'' {

    c 4 a b c

    }

    }

    }

    \layout { }

    }

    }

    In other words, i the input contains a single music expression, LilyPond will interpret thele as though the music expression was wrapped up inside the commands shown above.

    A word o warning! Many o the examples in the LilyPond documentation will omit the \newStaff and \new Voice commands, leaving them to be created implicitly. For simple examples

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    46/198

    Chapter 3: Fundamental concepts 42

    this works well, but or more complex examples, especially when additional commands are used,the implicit creation o contexts can give surprising results, maybe creating extra unwantedstaves. The way to create contexts explicitly is explained in Section 3.3 [Contexts and engravers],

    page 58.

    Note: When entering more than a ew lines o music it is advisable toalways create staves and voices explicitly.

    For now, though, let us return to the rst example and examine the \score command, leavingthe others to deault.

    A \score block must always contain just one music expression, and this must appear imme-diately ater the \score command. Remember that a music expression could be anything roma single note to a huge compound expression like

    {

    \new StaffGroup >

    }

    Since everything is inside { ... }, it counts as one music expression.

    As we saw previously, the \score block can contain other things, such as

    \score {

    { c ' 4 a b c ' }

    \header { }

    \layout { }

    \midi { }}

    Note that these three commands \header, \layout and \midi are special: unlike manyother commands which begin with a backward slash (\) they are not music expressions and arenot part o any music expression. So they may be placed inside a \score block or outside it. Inact, these commands are commonly placed outside the \score block or example, \header isoten placed above the \score command, as the example at the beginning o this section shows.

    Two more commands you have not previously seen are \layout { } and \midi {}. I theseappear as shown they will cause LilyPond to produce a printed output and a MIDI outputrespectively. They are described ully in the Notation Reerence Section Score layout inNotation Reerence, and Section Creating MIDI les in Notation Reerence.

    You may code multiple \score blocks. Each will be treated as a separate score, but theywill be all combined into a single output le. A \book command is not necessary one willbe implicitly created. However, i you would like separate output les rom one .ly le thenthe \book command should be used to separate the diferent sections: each \book block willproduce a separate output le.

    In summary:

    Every \book block creates a separate output le (e.g., a PDF le). I you havent explicitlyadded one, LilyPond wraps your entire input code in a \book block implicitly.

    Every \score block is a separate chunk o music within a \book block.

    Every \layout block afects the \score or \book block in which it appears i.e., a \layout

    block inside a \score block afects only that \score block, but a \layout block outside o a\score block (and thus in a \book block, either explicitly or implicitly) will afect every \scorein that \book.

    For details see Section Multiple scores in a book in Notation Reerence.

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    47/198

    Chapter 3: Fundamental concepts 43

    Another great shorthand is the ability to dene variables, as shown in Section 2.4.1 [Orga-nizing pieces with variables], page 36. All the templates use this:

    melody = \relative c' {

    c 4 a b c

    }

    \score {

    \melody

    }

    When LilyPond looks at this le, it takes the value o melody (everything ater the equalssign) and inserts it whenever it sees \melody. Theres nothing special about the name it couldbe melody, global, keyTime, pianorighthand, or something else. Remember that you can usealmost any name you like as long as it contains just alphabetic characters and is distinct romLilyPond command names. For more details, see Section 3.4.4 [Saving typing with variablesand unctions], page 83. The exact limitations on variable names are detailed in Section Filestructure in Notation Reerence.

    See also

    For a complete denition o the input ormat, see Section File structure in Notation Re-erence.

    3.1.2 Score is a (single) compound musical expression

    We saw the general organization o LilyPond input les in the previous section, Section 3.1.1[Introduction to the LilyPond le structure], page 41. But we seemed to skip over the mostimportant part: how do we gure out what to write ater \score?

    We didnt skip over it at all. The big mystery is simply that there is no mystery. This lineexplains it all:

    A \score block must begin with a compound music expression.

    To understand what is meant by a music expression and a compound music expression, you maynd it useul to review the tutorial, Section 2.2.1 [Music expressions explained], page 27. In thatsection, we saw how to build big music expressions rom small pieces we started rom notes,then chords, etc. Now were going to start rom a big music expression and work our way down.For simplicity, well use just a singer and piano in our example. We dont need a StaffGroupor this ensemble, which simply groups a number o staves together with a bracket at the let,but we do need staves or a singer and a piano, though.

    \score {

    \new PianoStaff = "piano" >

    >>

    \layout { }

    }

    Here we have given names to the staves singer and piano. This is not essential here,but it is a useul habit to cultivate so that you can see at a glance what each stave is or.

    Remember that we use > instead o { ... } to show simultaneous music. Thiscauses the vocal part and piano part to appear one above the other in the score. The >construct would not be necessary or the Singer staf in the example above i it were going tocontain only one sequential music expression, but > rather than braces is necessary i

    http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    48/198

    Chapter 3: Fundamental concepts 44

    the music in the Staf is to contain two or more simultaneous expressions, e.g. two simultaneousVoices, or a Voice with lyrics. Were going to have a voice with lyrics, so angle brackets arerequired. Well add some real music later; or now lets just put in some dummy notes and

    lyrics. I youve orgotten how to add lyrics you may wish to review \addlyrics in Section 2.3.1[Setting simple songs], page 31.

    \score {

  • 8/4/2019 LILYPOND 1 Learning

    49/198

    Chapter 3: Fundamental concepts 45

    \score {

    \new PianoStaff = "piano" >

    >>\layout { }

    }

    And

    said,

    God

    When writing (or reading) a \score section, just take it slowly and careully. Start with theouter level, then work on each smaller level. It also really helps to be strict with indentation make sure that each item on the same level starts on the same horizontal position in your texteditor.

    See also

    Notation Reerence: Section Structure o a score in Notation Reerence.

    3.1.3 Nesting music expressionsIt is not essential to declare all staves at the beginning; they may be introduced temporarily atany point. This is particularly useul or creating ossia sections see Section ossia in MusicGlossary. Here is a simple example showing how to introduce a new staf temporarily or theduration o three notes:

    \new Staff {

    \relative g' {

    r 4 g 8 g c 4 c 8 d |

    e4 r8

    >

    http://notation.pdf/http://notation.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://music-glossary.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    50/198

    Chapter 3: Fundamental concepts 46

    r4 |

    }

    }

    Note that the size o the cle is the same as a cle printed ollowing a cle change slightlysmaller than the cle at the beginning o the line. This is usual or cles printed in the middle oa line.

    The ossia section may be placed above the staf as ollows:

    \new Staff = "main" {

    \relative g' {

    r 4 g 8 g c 4 c 8 d |

    e4 r8

    >

    r4 |}

    }

    This example uses \with, which will be explained more ully later. It is a means o modiyingthe deault behavior o a single Staf. Here it says that the new staf should be placed above thestaf called main instead o the deault position which is below.

    See also

    Ossia are oten written without cle and without time signature and are usually in a smalleront. These require urther commands which have not yet been introduced. See Section 4.3.2[Size o objects], page 102, and Section Ossia staves in Notation Reerence.

    3.1.4 On the un-nestedness o brackets and ties

    You have already met a number o diferent types o bracket and bracket-like constructs in

    writing the input le to LilyPond. These obey diferent rules which can be conusing at rst.Lets rst review the diferent types o brackets and bracket-like constructs.

    Bracket Type Function

    http://notation.pdf/http://notation.pdf/http://notation.pdf/
  • 8/4/2019 LILYPOND 1 Learning

    51/198

    Chapter 3: Fundamental concepts 47

    { .. } Encloses a sequential segment o music< .. > Encloses the notes o a chord> Encloses simultaneous music expressions

    ( .. ) Marks the start and end o a slur\( .. \) Marks the start and end o a phrasing slur[ .. ] Marks the start and end o a manual beam

    To these we should add other constructs which generate lines between or across notes:ties (marked by a tilde, ~), tuplets written as \times x/y {..}, and grace notes written as\grace{..}.

    Outside LilyPond, the conventional use o brackets requires the diferent types to be properlynested, like this, >, with the closing brackets being encountered in exactlythe opposite order to the opening brackets. This is a requirement or the three types o bracketdescribed by the word Encloses in the table above they must nest properly. However, the

    remaining bracket-like constructs, described with the word Marks in the table above togetherwith ties and tuplets, do not have to nest properly with any o the brackets or bracket-likeconstructs. In act, these are not brackets in the sense that they enclose something they aresimply markers to indicate where something starts and ends.

    So, or example, a phrasing slur can start beore a manually inserted beam and end beorethe end o the beam not very musical, perhaps, but possible:

    g8\( a b[ c b\) a] g4

    In general, diferent kinds o brackets, bracket-like constructs, and those implied by tuplets,

    ties and grace notes, may be mixed reely. This example shows a beam extending into a tuplet(line 1), a slur extending into a tuplet (line 2), a beam and a slur extending into a tuplet, a tiecrossing two tuplets, and a phrasing slur extending out o a tuplet (lines 3 and 4).

    r16[ g \times 2/3 { r16 e'8] }

    g,16( a \times 2/3 { b16 d) e }

    g,8[( a \times 2/3 { b8 d) e~] } |

    \times 4/5 { e32\( a, b d e } a4.\)

    3 3

    3

    2 5

    3.2 Voices contain music

    Singers need voices to sing, and so does LilyPond. The actual music or all instruments in ascore is contained in Voices the most undamental o all LilyPonds concepts.

  • 8/4/2019 LILYPOND 1 Learning

    52/198

    Chapter 3: Fundamental concepts 48

    3.2.1 Im hearing Voices

    The lowest, most undamental or innermost layers in a LilyPond score are called Voice contexts

    or just Voic