This document is also available in PDF.

This file documents GNU LilyPond.

Copyright 1999–2005 by the authors

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections. A copy of the license is included in the section entitled “GNU Free Documentation License”.

GNU LilyPond — The music typesetter

This is the user manual for GNU LilyPond 2.6.x series. (See the bottom of this page for the exact version number).

A further source of information is the website, which can be found at http://www.lilypond.org/. The website contains on-line copies of this and other documentation.

We want to dedicate this program to all the friends that we met through music.

Han-Wen and Jan

Table of Contents

Preface

It must have been during a rehearsal of the EJE (Eindhoven Youth Orchestra), somewhere in 1995 that Jan, one of the cranked violists told Han-Wen, one of the distorted French horn players, about the grand new project he was working on. It was an automated system for printing music (to be precise, it was MPP, a preprocessor for MusiXTeX). As it happened, Han-Wen accidentally wanted to print out some parts from a score, so he started looking at the software, and he quickly got hooked. It was decided that MPP was a dead end. After lots of philosophizing and heated email exchanges, Han-Wen started LilyPond in 1996. This time, Jan got sucked into Han-Wen's new project.

In some ways, developing a computer program is like learning to play an instrument. In the beginning, discovering how it works is fun, and the things you cannot do are challenging. After the initial excitement, you have to practice and practice. Scales and studies can be dull, and if you are not motivated by others—teachers, conductors or audience—it is very tempting to give up. You continue, and gradually playing becomes a part of your life. Some days it comes naturally, and it is wonderful, and on some days it just does not work, but you keep playing, day after day.

Like making music, working on LilyPond can be dull work, and on some days it feels like plodding through a morass of bugs. Nevertheless, it has become a part of our life, and we keep doing it. Probably the most important motivation is that our program actually does something useful for people. When we browse around the net we find many people who use LilyPond, and produce impressive pieces of sheet music. Seeing that feels unreal, but in a very pleasant way.

Our users not only give us good vibes by using our program, many of them also help us by giving suggestions and sending bug reports, so we would like to thank all users that sent us bug reports, gave suggestions or contributed in any other way to LilyPond.

Playing and printing music is more than a nice analogy. Programming together is a lot of fun, and helping people is deeply satisfying, but ultimately, working on LilyPond is a way to express our deep love for music. May it help you create lots of beautiful music!

Han-Wen and Jan

Utrecht/Eindhoven, The Netherlands, July 2002.

Notes for version 2.6

For years, LilyPond has been associated with TeX, for its design, syntax and, last but not least, since it used TeX as an output engine. Starting with 2.6, the latter has changed. By default, LilyPond now produces PostScript directly. This makes it easier to install, quicker to operate and more versatile.

Under the hood, this was made possible by use of the Pango library, which does typesetting of multilingual text. This means that you can easily typeset Chinese, Russian or Minoic lyrics. Another result is the SVG output. You can create SVG pictures of music notation directly from LilyPond.

There are also small improvements. This release has numerous extra features, such as color support, string-number notation, arrowed glissandi. Moreover, it is now possible to commission features. For a small fee, we (the core developers) can implement the features that you sorely need. Examples of sponsored features in 2.6 are solfa notation, stemlets, starting and stopping staves.

Han-Wen and Jan

Utrecht/Eindhoven, The Netherlands, May 2005.

1 Introduction

1.1 Engraving

The art of music typography is called (plate) engraving. The term derives from the traditional process of music printing. Just a few decades ago, sheet music was made by cutting and stamping the music into a zinc or pewter plate in mirror image. The plate would be inked, the depressions caused by the cutting and stamping would hold ink. An image was formed by pressing paper to the plate. The stamping and cutting was completely done by hand. Making a correction was cumbersome, if possible at all, so the engraving had to be perfect in one go. Engraving was a highly specialized skill; a craftsman had to complete around five years of training before earning the title of master engraver, and another five years of experience were necessary to become truly skilled.

Nowadays, all newly printed music is produced with computers. This has obvious advantages; prints are cheaper to make, and editorial work can be delivered by email. Unfortunately, the pervasive use of computers has also decreased the graphical quality of scores. Computer printouts have a bland, mechanical look, which makes them unpleasant to play from.

The images below illustrate the difference between traditional engraving and typical computer output, and the third picture shows how LilyPond mimics the traditional look. The left picture shows a scan of a flat symbol from an edition published in 2000. The center depicts a symbol from a hand-engraved Bärenreiter edition of the same music. The left scan illustrates typical flaws of computer print: the staff lines are thin, the weight of the flat symbol matches the light lines and it has a straight layout with sharp corners. By contrast, the Bärenreiter flat has a bold, almost voluptuous rounded look. Our flat symbol is designed after, among others, this one. It is rounded, and its weight harmonizes with the thickness of our staff lines, which are also much thicker than lines in the computer edition.

png

png

png


Henle (2000) Bärenreiter (1950) LilyPond Feta font (2003)

In spacing, the distribution of space should reflect the durations between notes. However, many modern scores adhere to the durations with mathematical precision, which leads to poor results. In the next example a motive is printed twice. It is printed once using exact mathematical spacing, and once with corrections. Can you spot which fragment is which?

[image of music]

[image of music]

The fragment only uses quarter notes: notes that are played in a constant rhythm. The spacing should reflect that. Unfortunately, the eye deceives us a little; not only does it notice the distance between note heads, it also takes into account the distance between consecutive stems. As a result, the notes of an up-stem/down-stem combination should be put farther apart, and the notes of a down-stem/up-stem combination should be put closer together, all depending on the combined vertical positions of the notes. The first two measures are printed with this correction, the last two measures without. The notes in the last two measures form down-stem/up-stem clumps of notes.

Musicians are usually more absorbed with performing than with studying the looks of a piece of music, so nitpicking about typographical details may seem academical. But it is not. In larger pieces with monotonous rhythms, spacing corrections lead to subtle variations in the layout of every line, giving each one a distinct visual signature. Without this signature all lines would look the same, and they become like a labyrinth. If a musician looks away once or has a lapse in concentration, the lines might lose their place on the page.

Similarly, the strong visual look of bold symbols on heavy staff lines stands out better when the music is far away from the reader, for example, if it is on a music stand. A careful distribution of white space allows music to be set very tightly without cluttering symbols together. The result minimizes the number of page turns, which is a great advantage.

This is a common characteristic of typography. Layout should be pretty, not only for its own sake, but especially because it helps the reader in her task. For performance material like sheet music, this is of double importance: musicians have a limited amount of attention. The less attention they need for reading, the more they can focus on playing the music. In other words, better typography translates to better performances.

These examples demonstrate that music typography is an art that is subtle and complex, and that producing it requires considerable expertise, which musicians usually do not have. LilyPond is our effort to bring the graphical excellence of hand-engraved music to the computer age, and make it available to normal musicians. We have tuned our algorithms, font-designs, and program settings to produce prints that match the quality of the old editions we love to see and love to play from.

1.2 Automated engraving

How do we go about implementing typography? If craftsmen need over ten years to become true masters, how could we simple hackers ever write a program to take over their jobs?

The answer is: we cannot. Typography relies on human judgment of appearance, so people cannot be replaced completely. However, much of the dull work can be automated. If LilyPond solves most of the common situations correctly, this will be a huge improvement over existing software. The remaining cases can be tuned by hand. Over the course of years, the software can be refined to do more and more things automatically, so manual overrides are less and less necessary.

When we started, we wrote the LilyPond program entirely in the C++ programming language; the program's functionality was set in stone by the developers. That proved to be unsatisfactory for a number of reasons:

These problems have been addressed by integrating an interpreter for the Scheme programming language and rewriting parts of LilyPond in Scheme. The current formatting architecture is built around the notion of graphical objects, described by Scheme variables and functions. This architecture encompasses formatting rules, typographical style and individual formatting decisions. The user has direct access to most of these controls.

Scheme variables control layout decisions. For example, many graphical objects have a direction variable that encodes the choice between up and down (or left and right). Here you see two chords, with accents and arpeggios. In the first chord, the graphical objects have all directions down (or left). The second chord has all directions up (right).

[image of music]

The process of formatting a score consists of reading and writing the variables of graphical objects. Some variables have a preset value. For example, the thickness of many lines – a characteristic of typographical style – is a variable with a preset value. You are free to alter this value, giving your score a different typographical impression.

[image of music]

Formatting rules are also preset variables: each object has variables containing procedures. These procedures perform the actual formatting, and by substituting different ones, we can change the appearance of objects. In the following example, the rule which note head objects are used to produce their symbol is changed during the music fragment.

[image of music]

1.3 What symbols to engrave?

The formatting process decides where to place symbols. However, this can only be done once it is decided what symbols should be printed, in other words what notation to use.

Common music notation is a system of recording music that has evolved over the past 1000 years. The form that is now in common use dates from the early renaissance. Although the basic form (i.e., note heads on a 5-line staff) has not changed, the details still evolve to express the innovations of contemporary notation. Hence, it encompasses some 500 years of music. Its applications range from monophonic melodies to monstrous counterpoints for large orchestras.

How can we get a grip on such a many-headed beast, and force it into the confines of a computer program? Our solution is to break up the problem of notation (as opposed to engraving, i.e., typography) into digestible and programmable chunks: every type of symbol is handled by a separate module, a so-called plug-in. Each plug-in is completely modular and independent, so each can be developed and improved separately. Such plug-ins are called engravers, by analogy with craftsmen who translate musical ideas to graphic symbols.

In the following example, we see how we start out with a plug-in for note heads, the Note_heads_engraver.

[image of music]

Then a Staff_symbol_engraver adds the staff

[image of music]

the Clef_engraver defines a reference point for the staff

[image of music]

and the Stem_engraver adds stems.

[image of music]

The Stem_engraver is notified of any note head coming along. Every time one (or more, for a chord) note head is seen, a stem object is created and connected to the note head. By adding engravers for beams, slurs, accents, accidentals, bar lines, time signature, and key signature, we get a complete piece of notation.

[image of music]

This system works well for monophonic music, but what about polyphony? In polyphonic notation, many voices can share a staff.

[image of music]

In this situation, the accidentals and staff are shared, but the stems, slurs, beams, etc., are private to each voice. Hence, engravers should be grouped. The engravers for note heads, stems, slurs, etc., go into a group called `Voice context,' while the engravers for key, accidental, bar, etc., go into a group called `Staff context.' In the case of polyphony, a single Staff context contains more than one Voice context. Similarly, multiple Staff contexts can be put into a single Score context. The Score context is the top level notation context.

See also

Program reference: Contexts.

[image of music]

1.4 Music representation

Ideally, the input format for any high-level formatting system is an abstract description of the content. In this case, that would be the music itself. This poses a formidable problem: how can we define what music really is? Instead of trying to find an answer, we have reversed the question. We write a program capable of producing sheet music, and adjust the format to be as lean as possible. When the format can no longer be trimmed down, by definition we are left with content itself. Our program serves as a formal definition of a music document.

The syntax is also the user-interface for LilyPond, hence it is easy to type

     c'4 d'8

a quarter note C1 (middle C) and an eighth note D1 (D above middle C)

[image of music]

On a microscopic scale, such syntax is easy to use. On a larger scale, syntax also needs structure. How else can you enter complex pieces like symphonies and operas? The structure is formed by the concept of music expressions: by combining small fragments of music into larger ones, more complex music can be expressed. For example

     c4

[image of music]

Chords can be constructed with << and >> enclosing the notes

<<c4 d4 e4>>

[image of music]

This expression is put in sequence by enclosing it in curly braces ... }

{ f4 <<c4 d4 e4>> }

[image of music]

The above is also an expression, and so it may be combined again with another simultaneous expression (a half note) using <<, \\, and >>

<< g2 \\ { f4 <<c4 d4 e4>> } >>

[image of music]

Such recursive structures can be specified neatly and formally in a context-free grammar. The parsing code is also generated from this grammar. In other words, the syntax of LilyPond is clearly and unambiguously defined.

User-interfaces and syntax are what people see and deal with most. They are partly a matter of taste, and also subject of much discussion. Although discussions on taste do have their merit, they are not very productive. In the larger picture of LilyPond, the importance of input syntax is small: inventing neat syntax is easy, while writing decent formatting code is much harder. This is also illustrated by the line-counts for the respective components: parsing and representation take up less than 10% of the source code.

1.5 Example applications

We have written LilyPond as an experiment of how to condense the art of music engraving into a computer program. Thanks to all that hard work, the program can now be used to perform useful tasks. The simplest application is printing notes.

[image of music]

By adding chord names and lyrics we obtain a lead sheet.

[image of music]

Polyphonic notation and piano music can also be printed. The following example combines some more exotic constructs.

[image of music]

The fragments shown above have all been written by hand, but that is not a requirement. Since the formatting engine is mostly automatic, it can serve as an output means for other programs that manipulate music. For example, it can also be used to convert databases of musical fragments to images for use on websites and multimedia presentations.

This manual also shows an application: the input format is text, and can therefore be easily embedded in other text-based formats such as LaTeX, HTML, or in the case of this manual, Texinfo. By means of a special program, the input fragments can be replaced by music images in the resulting PDF or HTML output files. This makes it easy to mix music and text in documents.

1.6 About this manual

The manual is divided into the following chapters:

Once you are an experienced user, you can use the manual as reference: there is an extensive index1, but the document is also available in one big page, which can be searched easily using the search facility of a web browser. If you are not familiar with music notation or music terminology (especially if you are a non-native English speaker), it is advisable to consult the glossary as well. The Music glossary, explains musical terms and includes translations to various languages. It is also available in PDF.

This manual is not complete without a number of other documents. They are not available in print, but should be included with the documentation package for your platform

In all HTML documents that have music fragments embedded, the LilyPond input that was used to produce that image can be viewed by clicking the image.

The location of the documentation files that are mentioned here can vary from system to system. On occasion, this manual refers to initialization and example files. Throughout this manual, we refer to input files relative to the top-directory of the source archive. For example, input/test/bla.ly may refer to the file lilypond-2.6.0/input/test/bla.ly. On binary packages for the Unix platform, the documentation and examples can typically be found somewhere below /usr/share/doc/lilypond/. Initialization files, for example scm/lily.scm, or ly/engraver-init.ly, are usually found in the directory /usr/share/lilypond/.

Finally, this and all other manuals, are available online both as PDF files and HTML from the web site, which can be found at http://www.lilypond.org/.

2 Tutorial

This tutorial starts with a short introduction to the LilyPond music language. After this first contact we will show you how to produce printed output. Then you will be able to create and print your own sheets of music.

Many people learn programs by trying and fiddling around with the program. This is also possible with LilyPond. If you click on a picture in the HTML version of this manual, you will see the exact LilyPond input that was used to generate that image. Try it on this image

[image of music]

By cutting and pasting the full input into a test file, you have a starting template for experiments. If you like learning in this way, you will probably want to print out or bookmark the Cheat sheet, which is a table listing all commands for quick reference.

2.1 First steps

The first example demonstrates how to enter the most elementary piece of music, a scale. A note can be entered by typing its name, from `a' through `g'. So, if you enter

c d e f g a b

the result looks like this

[image of music]

The duration of a note is specified by a number after the note name. `1' for a whole note, `2' for a half note, `4' for a quarter note and so on

a1 a2 a4 a16 a32

[image of music]

If you do not specify a duration, the duration last entered is used for the next notes. The duration of the first note in input defaults to a quarter

a a8 a a2 a

[image of music]

A rest is entered just like a note, but with the name `r'

r2 r4 r8 r16

[image of music]

Add a dot `.' after the duration to get a dotted note

a2. a4 a8. a16

[image of music]

The (or time signature) can be set with the \time command

\time 3/4
\time 6/8
\time 4/4

[image of music]

The clef can be set using the \clef command

\clef treble
\clef bass
\clef alto
\clef tenor

[image of music]

Remember to enclose the notes and commands in curly braces ... } to convert it to printable output.

[image of music]

For more elaborate information on

Entering pitches and durations
see Pitches, and Durations.
Clefs
see Clef.
Rests
see Rests.
Time signatures and other timing commands
see Time signature.

2.2 Running LilyPond for the first time

In the last section we explained what kind of things you can enter in a LilyPond file. In this section we will explain what commands to run and how to view or print the output. If you have not used LilyPond before, want to test your setup, or want to run an example file yourself, read this section.

MacOS X

If you double click LilyPond.app, it will open with an example file. Save it, for example, to test.ly on your Desktop, and then process it with the menu command `Compile > Typeset File'. The resulting PDF file will be displayed on your screen.

Be warned that the first-ever run will take a minute or two, because all of the system fonts have to be analyzed first.

Windows

On Windows, start up a text-editor2 and enter

{ c'4 e' g' }

Save it on the desktop as test.ly and make sure that it is not called test.ly.TXT. Double clicking test.ly will process the file and show the resulting PDF file.

Unix

Begin by opening a terminal window and starting a text editor. For example, you could open an xterm and execute joe.3 In your text editor, enter the following input and save the file as test.ly

{ c'4 e' g' }

To process test.ly, proceed as follows

lilypond test.ly

You will see something resembling

lilypond test.ly
GNU LilyPond 2.6.0
Processing `test.ly'
Parsing...
Interpreting music... [1]
Preprocessing graphical objects...
Calculating line breaks... [2]
Layout output to `test.ps'...
Converting to `test.pdf'...

The result is the file test.pdf which you can print or view with the standard facilities of your operating system.4

2.3 More about pitches

A sharp (#) pitch is made by adding `is' to the name, a flat (b) pitch by adding `es'. As you might expect, a double sharp or double flat is made by adding `isis' or `eses'5

cis1 ees fisis aeses

[image of music]

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

\key d \major
g1
\key c \minor
g

[image of music]

Key signatures together with the pitches (including alterations) are used to determine when to print accidentals. This is a feature that often causes confusion to newcomers, so let us explain it in more detail.

LilyPond makes a sharp distinction between musical content and layout. The alteration (flat, natural or sharp) of a note is part of the pitch, and is therefore musical content. Whether an accidental (a flat, natural or sharp sign) is printed in front of the corresponding note is a question of layout. Layout is something that follows rules, so accidentals are printed automatically according to those rules. The pitches in your music are works of art, so they will not be added automatically, and you must enter what you want to hear.

In this example

[image of music]

no note has an explicit accidental, but you still must enter

\key d \major
d cis fis

The code `d' does not mean `print a black dot just below the staff.' Rather, it means: `a note with pitch D-natural.' In the key of A-flat major, it does get an accidental

     \key as \major
     d

[image of music]

Adding all alterations explicitly might require a little more effort when typing, but the advantage is that transposing is easier, and accidentals can be printed according to different conventions. See Automatic accidentals, for some examples how accidentals can be printed according to different rules.

For more information on

Accidentals
see Automatic accidentals.
Key signature
see Key signature.

2.4 Entering ties

A tie is created by appending a tilde `~' to the first note being tied

     g4~ g a2~ a4

[image of music]

For more information on Ties see Ties.

2.5 Automatic and manual beams

All beams are drawn automatically

     a8 ais d es r d

[image of music]

If you do not like where beams are put, they can be entered by hand. Mark the first note to be beamed with `[' and the last one with `]'.

     a8[ ais] d[ es r d]

[image of music]

For more information on beams, see Manual beams.

Here are key signatures, accidentals and ties in action

\relative c'' {
  \time 4/4
  \key g \minor
  \clef treble
  r4 r8 a8 gis4 b
  a8 d4.~ d e,8
  fis4 fis8 fis8 eis4 a8 gis~
  gis2 r2
}

[image of music]

There are some interesting points to note in this example. Bar lines and beams are drawn automatically. Line breaks are calculated automatically; it does not matter where the line breaks are in the source file. Finally, the order in which time, key, and clef changes are entered is not relevant: in the printout, these are ordered according to standard notation conventions.

2.6 Octave entry

To raise a note by an octave, add a high quote ' (apostrophe) to the note name, to lower a note one octave, add a `low quote' , (comma). Middle C is c'

     c'4 c'' c''' \clef bass c c,

[image of music]

An example of the use of quotes is in the following Mozart fragment

     \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

[image of music]

This example shows that music in a high register needs lots of quotes. This makes the input less readable, and it is a source of errors. The solution is to use `relative octave' mode. This is the most convenient way to copy existing music.

In relative mode, a note without octavation quotes (i.e. the ' or , after a note) is chosen so that it is closest to the previous one. For example, `c f' goes up while `c g' goes down.

To use relative mode, add \relative before the piece of music. The first note is taken relative to the middle C (i.e., c')

     \relative {
       c' f c g c
     }

[image of music]

Since most music has small intervals, pieces can be written almost without octavation quotes in relative mode. The previous example is entered as

     \relative {
       \key a \major
       \time 6/8
       cis'8. d16 cis8 e4 e8
       b8. cis16 b8 d4 d8
     }

[image of music]

Larger intervals are made by adding octavation quotes.

     \relative c {
       c'' f, f c' c g' c,
     }

[image of music]

In summary, quotes or commas no longer determine the absolute height of a note in \relative mode. Rather, the height of a note is relative to the previous one, and changing the octave of a single note shifts all following notes an octave up or down.

For more information on relative octaves see Relative octaves, and Octave check.

2.7 Music expressions explained

In input files, music is represent by so-called music expressions. We have already seen some in the previous examples; a single note is a music expression

     a4

[image of music]

Enclosing a group of notes in braces creates a new music expression

     { a4 g4 }

[image of music]

Putting a bunch of music expressions (e.g., notes) in braces, means that they should be played in sequence. The result again is a music expression, which can be grouped with other expressions sequentially. Here, the expression from the previous example is combined with two notes

     { { a4 g } f g }

[image of music]

This technique is useful for non-monophonic music. To enter music with more voices or more staves, we also combine expressions in parallel. Two voices that should play at the same time, are entered as a simultaneous combination of two sequences. A `simultaneous' music expression is formed by enclosing expressions in << and >>. In the following example, three sequences (all containing two separate notes) are combined simultaneously

     <<
       { a4 g }
       { f e }
       { d b }
     >>

[image of music]

This mechanism is similar to mathematical formulas: a big formula is created by composing small formulas. Such formulas are called expressions, and their definition is recursive, so you can make arbitrarily complex and large expressions. For example,

1

1 + 2

(1 + 2) * 3

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

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

Note that this example only has one staff, whereas the previous example had three separate staves. That is because this example begins with a single note. To determine the number of staves, LilyPond looks at the first element. If it is a single note, there is one staff; if there is a simultaneous expression, there is more than one staff.

     {
       c <<c e>>
       << { e f } { c <<b d>> } >>
     }

[image of music]

Music files with deep nesting can be confusing to enter and maintain. One convention that helps against this confusion is indenting. When entering a file with deep nesting of braces and angles, it is customary to use an indent that indicates the nesting level. Formatting music like this eases reading and helps you insert the right number of closing braces at the end of an expression. For example,

<<
  {
    ...
  }
  {
    ...
  }
>>

Some editors have special support for entering LilyPond, and can help indenting source files. See Editor support for more information.

2.8 More staves

To print more than one staff, each piece of music that makes up a staff is marked by adding \new Staff before it. These Staff elements are then combined in parallel with << and >>, as demonstrated here

     <<
       \new Staff { \clef treble c'' }
       \new Staff { \clef bass c }
     >>

[image of music]

The command \new introduces a `notation context.' A notation context is an environment in 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 mark contexts explicitly. This ensures that each fragment gets its own stave.

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

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

We can now typeset a melody with two staves

     \relative <<
       \new Staff {
         \time 3/4
         \clef treble
     
         e'2 d4 c2 b4 a8[ a]
         b[ b] g[ g] a2.
       }
       \new Staff {
          \clef bass
          c,,2 e4 g2.
          f4 e d c2.
       }
     >>

[image of music]

For more information on contexts see the description in Interpretation contexts.

2.9 Adding articulation marks to notes

Common accents can be added to a note using a dash (`-') and a single character

     c-.  c-- c-> c-^ c-+ c-_

[image of music]

Similarly, fingering indications can be added to a note using a dash (`-') and the digit to be printed

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

[image of music]

Articulations and fingerings are usually placed automatically, but you can specify a direction using `^' (up) or `_' (down). You can also use multiple articulations on the same note. In most cases, however, it is best to let LilyPond determine the articulation directions.

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

[image of music]

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

     c\ff c\mf

[image of music]

Crescendi and decrescendi are started with the commands \< and \>. An ending dynamic, for example \f, will finish the (de)crescendo, or the command \! can be used

     c2\< c2\ff\> c2 c2\!

[image of music]

A slur is a curve drawn across many notes, and indicates legato articulation. The starting note and ending note are marked with `(' and `)', respectively

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

[image of music]

A slur looks like a tie, but it has a different meaning. A tie simply makes the first note sound longer, and can only be used on pairs of notes with the same pitch. Slurs indicate the articulations of notes, and can be used on larger groups of notes. Slurs and ties can be nested

[image of music]

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

     a8(\( ais b c) cis2 b'2 a4 cis, c\)

[image of music]

For more information on

Fingering
see Fingering instructions.
Articulations
see Articulations.
Slurs
see Slurs.
Phrasing slurs
see Phrasing slurs.
Dynamics
see Dynamics.

2.10 Combining notes into chords

Chords can be made by surrounding pitches with angle brackets. Angle brackets are the symbols `<' and `>'.

     r4 <c e g>4 <c f a>8

[image of music]

You can combine markings like beams and ties with chords. They must be placed outside the angled brackets

     r4 <c e g>8[ <c f a>]~ <c f a>

[image of music]

r4 <c e g>8\>( <c e g> <c e g> <c f a>\!)

[image of music]

2.11 Advanced rhythmic commands

A pickup is entered with the keyword \partial. It is followed by a duration: \partial 4 is a quarter note upstep and \partial 8 an eighth note

     \partial 8
     f8 c2 d e

[image of music]

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

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

[image of music]

Grace notes are also made by prefixing a music expression with the keyword \appoggiatura or \acciaccatura

     c4 \appoggiatura b16 c4
     c4 \acciaccatura b16 c4

[image of music]

For more information on

Grace notes
see Grace notes,
Tuplets
see Tuplets,
Pickups
see Partial measures.

2.12 Commenting input files

A comment is a remark for the human reader of the music input; it is ignored while parsing, so it has no effect on the printed output. There are two types of comments. The percent symbol `%' introduces a line comment; after % the rest of the line is ignored. A block comment marks a whole section of music input. Anything that is enclosed in %{ and %} is ignored. The following fragment shows possible uses for comments

% notes for twinkle twinkle follow
  c4 c g' g a a g2

%{
    This line, and the notes below
    are ignored, since they are in a
    block comment.

    g g f f e e d d c2
%}

There is a special statement that is a kind of comment. The \version statement marks for which version of LilyPond the file was written. To mark a file for version 2.6.0, use

\version "2.6.0"

These annotations make future upgrades of LilyPond go more smoothly. Changes in the syntax are handled with a special program, convert-ly (see Updating files with convert-ly), and it uses \version to determine what rules to apply.

2.13 Printing lyrics

Lyrics are entered by separating each syllable with a space

I want to break free

Consider the melody

     \relative {
       r4 c \times 2/3 { f g g }
       \times 2/3 { g4( a2) }
     }

[image of music]

The lyrics can be set to these notes, combining both with the \addlyrics keyword

     <<
       \relative {
         r4 c \times 2/3 { f g g }
         \times 2/3 { g4( a2) }
       }
       \addlyrics { I want to break free }
     >>

[image of music]

This melody ends on a melisma, a single syllable (`free') sung to more than one note. This is indicated with an extender line. It is entered as two underscores, i.e.,

{ I want to break free __ }

[image of music]

Similarly, hyphens between words can be entered as two dashes, resulting in a centered hyphen between two syllables

Twin -- kle twin -- kle

[image of music]

More options, like putting multiple lines of lyrics below a melody are discussed in Vocal music.

2.14 A lead sheet

In popular music, it is common to denote accompaniment with chord names. Such chords can be entered like notes,

     \chordmode { c2 f4. g8 }

[image of music]

Now each pitch is read as the root of a chord instead of a note. This mode is switched on with \chordmode

Other chords can be created by adding modifiers after a colon. The following example shows a few common modifiers

     \chordmode { c2 f4:m g4:maj7 gis1:dim7 }

[image of music]

For lead sheets, chords are not printed on staves, but as names on a line for themselves. This is achieved by using \chords instead of \chordmode. This uses the same syntax as \chordmode, but renders the notes in a ChordNames context, with the following result.

     \chords { c2 f4.:m g4.:maj7 gis8:dim7 }

[image of music]

When put together, chord names, lyrics and a melody form a lead sheet, for example,

<<
  \chords { chords }
  the melody
  \addlyrics { the text }
>>
}

[image of music]

A complete list of modifiers and other options for layout can be found in Chords.

2.15 Adding titles

Bibliographic information is entered in a separate block, the \header block. The name of the piece, its composer, etc., are entered as an assignment, within \header { ... }. The \header block is usually put at the top of the file. For example,

\header {
  title = "Miniature"
  composer = "Igor Stravinsky"
}

{ ... }

When the file is processed, the title and composer are printed above the music. More information on titling can be found in Creating titles.

2.16 Single staff polyphony

When different melodic lines are combined on a single staff they are printed as polyphonic voices; each voice has its own stems, slurs and beams, and the top voice has the stems up, while the bottom voice has them down.

Entering such parts is done by entering each voice as a sequence (with {...}), and combining these simultaneously, separating the voices with \\

     << { a4 g2 f4~ f4 } \\
        { r4 g4 f2 f4 } >>

[image of music]

For polyphonic music typesetting, spacer rests can also be convenient; these are rests that do not print. They are useful for filling up voices that temporarily do not play. Here is the same example with a spacer rest (s) instead of a normal rest (r),

     << { a4 g2 f4~ f4 } \\
        { s4 g4 f2 f4 } >>

[image of music]

Again, these expressions can be nested arbitrarily

     <<
       \new Staff <<
         { a4 g2 f4~ f4 } \\
         { s4 g4 f2 f4 }
       >>
       \new Staff <<
         \clef bass
         { <c, g>1 ~ <c g>4 } \\
         { e,4 d e2 ~ e4}
       >>
     >>

[image of music]

More features of polyphonic typesetting are described in this manual in section Polyphony.

2.17 Piano staves

Piano music is typeset in two staves connected by a brace. Printing such a staff is similar to the polyphonic example in More staves,

<< \new Staff { ... }
   \new Staff { ... } >>

but now this entire expression must be interpreted as a PianoStaff

\new PianoStaff << \new Staff ... >>

Here is a small example

     \new PianoStaff <<
       \new Staff { \time 2/4 c4 c g' g }
       \new Staff { \clef bass c,, c' e c }
     >>

[image of music]

More information on formatting piano music is given in Piano music.

2.18 Organizing larger pieces

When all of the elements discussed earlier are combined to produce larger files, the \score blocks get a lot bigger, because the music expressions are longer, and, in the case of polyphonic pieces, more deeply nested. Such large expressions can become unwieldy.

By using variables, also known as identifiers, it is possible to break up complex music expressions. An identifier is assigned as follows

namedMusic = { ... }

The contents of the music expression namedMusic, can be used later by preceding the name with a backslash, i.e., \namedMusic. In the next example, a two-note motive is repeated two times by using variable substitution

     seufzer = {
       e'4( dis'4)
     }
     { \seufzer \seufzer }

[image of music]

The name of an identifier should have alphabetic characters only; no numbers, underscores or dashes. The assignment should be outside of running music.

It is possible to use variables for many other types of objects in the input. For example,

width = 4.5\cm
name = "Wendy"
aFivePaper = \paper { paperheight = 21.0 \cm }

Depending on its contents, the identifier can be used in different places. The following example uses the above variables

\paper {
  \aFivePaper
  linewidth = \width
}
{ c4^\name }

More information on the possible uses of identifiers is given in the technical manual, in Input variables and Scheme.

2.19 An orchestral part

In orchestral music, all notes are printed twice. Once in a part for the musicians, and once in a full score for the conductor. Identifiers can be used to avoid double work. The music is entered once, and stored in a variable. The contents of that variable is then used to generate both the part and the full score.

It is convenient to define the notes in a special file. For example, suppose that the file horn-music.ly contains the following part of a horn/bassoon duo

hornNotes = \relative c {
  \time 2/4
  r4 f8 a cis4 f e d
}

Then, an individual part is made by putting the following in a file

\include "horn-music.ly"
\header {
  instrument = "Horn in F"
}

{
 \transpose f c' \hornNotes
}

The line

\include "horn-music.ly"

substitutes the contents of horn-music.ly at this position in the file, so hornNotes is defined afterwards. The command \transpose f c' indicates that the argument, being \hornNotes, should be transposed by a fifth downwards. Sounding `f' is denoted by notated c', which corresponds with the tuning of a normal French Horn in F. The transposition can be seen in the following output

[image of music]

In ensemble pieces, one of the voices often does not play for many measures. This is denoted by a special rest, the multi-measure rest. It is entered with a capital `R' followed by a duration (1 for a whole note, 2 for a half note, etc.). By multiplying the duration, longer rests can be constructed. For example, this rest takes 3 measures in 2/4 time

R2*3

When printing the part, multi-rests must be condensed. This is done by setting a run-time variable

\set Score.skipBars = ##t

This command sets the property skipBars in the Score context to true (##t). Prepending the rest and this option to the music above, leads to the following result

[image of music]

The score is made by combining all of the music together. Assuming that the other voice is in bassoonNotes in the file bassoon-music.ly, a score is made with

\include "bassoon-music.ly"
\include "horn-music.ly"

<<
  \new Staff \hornNotes
  \new Staff \bassoonNotes
>>

leading to

[image of music]

More in-depth information on preparing parts and scores can be found in the notation manual; see Orchestral music.

Setting run-time variables (`properties') is discussed in Changing context properties on the fly.

3 Example templates

This section of the manual contains templates with the LilyPond score already set up for you. Just add notes, run LilyPond, and enjoy beautiful printed scores!

3.1 Single staff

3.1.1 Notes only

The first example gives you a staff with notes, suitable for a solo instrument or a melodic fragment. Cut and paste this into a file, add notes, and you're finished!

     \version "2.6.0"
     melody = \relative c' {
        \clef treble
        \key c \major
        \time 4/4
     
        a4 b c d
     }
     
     \score {
        \new Staff \melody
        \layout { }
        \midi { \tempo 4=60 }
     }

[image of music]

3.1.2 Notes and lyrics

The next example demonstrates a simple melody with lyrics. Cut and paste, add notes, then words for the lyrics. This example turns off automatic beaming, which is common for vocal parts. If you want to use automatic beaming, you'll have to change or comment out the relevant line.

     \version "2.6.0"
     melody = \relative c' {
        \clef treble
        \key c \major
        \time 4/4
     
        a4 b c d
     }
     
     text = \lyricmode {
        Aaa Bee Cee Dee
     }
     
     \score{
        <<
           \context Voice = one {
              \autoBeamOff
              \melody
           }
           \lyricsto "one" \new Lyrics \text
        >>
        \layout { }
        \midi { \tempo 4=60 }
     }

[image of music]

3.1.3 Notes and chords

Want to prepare a lead sheet with a melody and chords? Look no further!

     \version "2.6.0"
     melody = \relative c' {
        \clef treble
        \key c \major
        \time 4/4
     
        f4 e8[ c] d4 g |
        a2 ~ a2 |
     }
     
     harmonies = \chordmode {
        c4:m f:min7 g:maj c:aug d2:dim b:sus
     }
     
     \score {
        <<
           \context ChordNames {
              \set chordChanges = ##t
              \harmonies
           }
        \context Staff = one \melody
        >>
     
        \layout{ }
        \midi { \tempo 4=60}
     }

[image of music]

3.1.4 Notes, lyrics, and chords.

This template allows you to prepare a song with melody, words, and chords.

     \version "2.6.0"
     melody = \relative c' {
        \clef treble
        \key c \major
        \time 4/4
     
        a b c d
     }
     
     text = \lyricmode {
        Aaa Bee Cee Dee
     }
     
     harmonies = \chordmode {
        a2 c2
     }
     
     \score {
        <<
           \context ChordNames {
              \set chordChanges = ##t
              \harmonies
           }
        \context Voice = one {
           \autoBeamOff
           \melody
        }
        \lyricsto "one" \new Lyrics \text
        >>
        \layout { }
        \midi { \tempo 4=60 }
     }

[image of music]

3.2 Piano templates

3.2.1 Solo piano

Here is a simple piano staff.

     \version "2.6.0"
     upper = \relative c'' {
        \clef treble
        \key c \major
        \time 4/4
     
        a b c d
     }
     
     lower = \relative c {
        \clef bass
        \key c \major
        \time 4/4
     
        a2 c
     }
     
     \score {
        \context PianoStaff <<
           \set PianoStaff.instrument = "Piano  "
           \context Staff = upper \upper
           \context Staff = lower \lower
        >>
        \layout { }
        \midi { \tempo 4=60 }
     }

[image of music]

3.2.2 Piano and melody with lyrics

Here is a typical song format: one staff with the melody and lyrics, with piano accompaniment underneath.

     \version "2.6.0"
     melody = \relative c'' {
        \clef treble
        \key c \major
        \time 4/4
     
        a b c d
     }
     
     text = \lyricmode {
        Aaa Bee Cee Dee
     }
     
     upper = \relative c'' {
        \clef treble
        \key c \major
        \time 4/4
     
        a b c d
     }
     
     lower = \relative c {
        \clef bass
        \key c \major
        \time 4/4
     
        a2 c
     }
     
     \score {
        <<
           \context Voice = mel {
               \autoBeamOff
               \melody
           }
           \lyricsto mel \new Lyrics \text
     
           \context PianoStaff <<
              \context Staff = upper \upper
              \context Staff = lower \lower
           >>
        >>
        \layout {
           \context { \RemoveEmptyStaffContext }
        }
        \midi { \tempo 4=60 }
     }

[image of music]

3.2.3 Piano centered lyrics

Instead of having a full staff for the melody and lyrics, you can place the lyrics between the piano staff (and omit the separate melody staff).

     \version "2.6.0"
     upper = \relative c'' {
        \clef treble
        \key c \major
        \time 4/4
     
        a b c d
     }
     
     lower = \relative c {
        \clef bass
        \key c \major
        \time 4/4
     
        a2 c
     }
     
     text = \lyricmode {
        Aaa Bee Cee Dee
     }
     
     \score {
       \context GrandStaff <<
         \context Staff = upper {
             \context Voice = singer \upper }
         \lyricsto "singer" \new Lyrics \text
         \context Staff = lower <<
           \clef bass
           \lower
         >>
       >>
       \layout {
         \context { \GrandStaff \accepts "Lyrics" }
         \context { \Lyrics \consists "Bar_engraver" }
       }
       \midi { \tempo 4=60 }
     }

[image of music]

3.2.4 Piano centered dynamics

Many piano scores have the dynamics centered between the two staffs. This requires a bit of tweaking to implement, but since the template is right here, you don't have to do the tweaking yourself.

     \version "2.6.0"
     upper = \relative c'' {
       \clef treble
       \key c \major
       \time 4/4
     
       a b c d
     }
     
     lower = \relative c {
       \clef bass
       \key c \major
       \time 4/4
     
       a2 c
     }
     
     dynamics = {
       s2\fff\> s4
       s\!\pp
     }
     
     pedal = {
       s2\sustainDown s2\sustainUp
     }
     
     \score {
       \context PianoStaff <<
         \context Staff=upper \upper
         \context Dynamics=dynamics \dynamics
         \context Staff=lower <<
           \clef bass
           \lower
         >>
         \context Dynamics=pedal \pedal
       >>
       \layout {
         \context {
           \type "Engraver_group_engraver"
           \name Dynamics
           \alias Voice % So that \cresc works, for example.
           \consists "Output_property_engraver"
     
           minimumVerticalExtent = #'(-1 . 1)
           pedalSustainStrings = #'("Ped." "*Ped." "*")
           pedalUnaCordaStrings = #'("una corda" "" "tre corde")
     
           \consists "Piano_pedal_engraver"
           \consists "Script_engraver"
           \consists "Dynamic_engraver"
           \consists "Text_engraver"
     
           \override TextScript #'font-size = #2
           \override TextScript #'font-shape = #'italic
           \override DynamicText #'extra-offset = #'(0 . 2.5)
           \override Hairpin #'extra-offset = #'(0 . 2.5)
     
           \consists "Skip_event_swallow_translator"
     
           \consists "Axis_group_engraver"
         }
         \context {
           \PianoStaff
           \accepts Dynamics
           \override VerticalAlignment #'forced-distance = #7
         }
       }
     }
     \score {
       \context PianoStaff <<
         \context Staff=upper << \upper \dynamics >>
         \context Staff=lower << \lower \dynamics >>
         \context Dynamics=pedal \pedal
       >>
       \midi {
         \context {
           \type "Performer_group_performer"
           \name Dynamics
           \consists "Piano_pedal_performer"
         }
         \context {
           \PianoStaff
           \accepts Dynamics
         }
       }
     }

[image of music]

3.3 String quartet

3.3.1 String quartet

This template demonstrates a string quartet. It also uses a \global section for time and key signatures.

     \version "2.6.0"
     
     global= {
       \time 4/4
       \key c \major
     }
     
     violinOne = \new Voice { \relative c''{
       \set Staff.instrument = "Violin 1 "
     
       c2 d e1
     
     \bar "|." }}
     violinTwo = \new Voice { \relative c''{
       \set Staff.instrument = "Violin 2 "
     
       g2 f e1
     
     \bar "|." }}
     viola = \new Voice { \relative c' {
       \set Staff.instrument = "Viola "
       \clef alto
     
       e2 d c1
     
     \bar "|." }}
     cello = \new Voice { \relative c' {
       \set Staff.instrument = "Cello     "
       \clef bass
     
       c2 b a1
     
     \bar "|."}}
     
     \score {
        \new StaffGroup <<
           \new Staff << \global \violinOne >>
           \new Staff << \global \violinTwo >>
           \new Staff << \global \viola >>
           \new Staff << \global \cello >>
        >>
        \layout { }
        \midi { \tempo 4=60}
     }

[image of music]

3.3.2 String quartet parts

The previous example produces a nice string quartet, but what if you needed to print parts? This template demonstrates how to use the \tag feature to easily split a piece into individual parts.

You need to split this template into separate files; the filenames are contained in comments at the beginning of each file. piece.ly contains all the music definitions. The other files – score.ly, vn1.ly, vn2.ly, vla.ly, and vlc.ly – produce the appropiate part.

%%%%% piece.ly
\version "2.6.0"

global= {
  \time 4/4
  \key c \major
}

Violinone = \new Voice { \relative c''{
  \set Staff.instrument = "Violin 1 "

  c2 d e1

\bar "|." }}   %*********************************
Violintwo = \new Voice { \relative c''{
  \set Staff.instrument = "Violin 2 "

  g2 f e1

\bar "|." }}   %*********************************
Viola = \new Voice { \relative c' {
  \set Staff.instrument = "Viola "
  \clef alto

  e2 d c1

\bar "|." }}   %*********************************
Cello = \new Voice { \relative c' {
  \set Staff.instrument = "Cello     "
  \clef bass

  c2 b a1

\bar "|."}}   %**********************************

music = {
  <<
    \tag #'(score vn1) \new Staff { << \global \Violinone >> }
    \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
    \tag #'(score vla) \new Staff { << \global \Viola>> }
    \tag #'(score vlc) \new Staff { << \global \Cello>> }
  >>
}



%%%%% score.ly
\version "2.6.0"
\include "piece.ly"
#(set-global-staff-size 14)
\score {
  \new StaffGroup \keepWithTag #'score \music
  \layout { }
  \midi { \tempo 4 = 60 }
}


%%%%% vn1.ly
\version "2.6.0"
\include "piece.ly"
\score { 
  \keepWithTag #'vn1 \music
  \layout { }
}


%%%%% vn2.ly
\version "2.6.0"
\include "piece.ly"
\score { 
  \keepWithTag #'vn2 \music
  \layout { }
}


%%%%% vla.ly
\version "2.6.0"
\include "piece.ly"
\score { 
  \keepWithTag #'vla \music
  \layout { }
}


%%%%% vlc.ly
\version "2.6.0"
\include "piece.ly"
\score { 
  \keepWithTag #'vlc \music
  \layout { }
}

3.4 Vocal ensembles

3.4.1 SATB vocal score

Here is a standard four-part SATB vocal score. With larger ensembles, it's often useful to include a section which is included in all parts. For example, the time signature and key signatures are almost always the same for all parts.

     \version "2.6.0"
     global = {
        \key c \major
        \time 4/4
     }
     
     sopMusic = \relative c'' {
        c4 c c8[( b)] c4
     }
     sopWords = \lyricmode {
        hi hi hi hi
     }
     
     altoMusic = \relative c' {
        e4 f d e
     }
     altoWords =\lyricmode {
        ha ha ha ha
     }
     
     tenorMusic = \relative c' {
        g4 a f g
     }
     tenorWords = \lyricmode {
        hu hu hu hu
     }
     
     bassMusic = \relative c {
        c4 c g c
     }
     bassWords = \lyricmode {
        ho ho ho ho
     }
     
     \score {
        \context ChoirStaff <<
           \context Lyrics = sopranos { s1 }
           \context Staff = women <<
              \context Voice =
                sopranos { \voiceOne << \global \sopMusic >> }
              \context Voice =
                altos { \voiceTwo << \global \altoMusic >> }
           >>
           \context Lyrics = altos { s1 }
           \context Lyrics = tenors { s1 }
           \context Staff = men <<
              \clef bass
              \context Voice =
                tenors { \voiceOne <<\global \tenorMusic >> }
              \context Voice =
                basses { \voiceTwo <<\global \bassMusic >> }
           >>
           \context Lyrics = basses { s1 }
           \context Lyrics = sopranos \lyricsto sopranos \sopWords
           \context Lyrics = altos \lyricsto altos \altoWords
           \context Lyrics = tenors \lyricsto tenors \tenorWords
           \context Lyrics = basses \lyricsto basses \bassWords
        >>
     
        \layout {
           \context {
              % a little smaller so lyrics
              % can be closer to the staff
              \Staff minimumVerticalExtent = #'(-3 . 3)
           }
        }
     }

[image of music]

3.4.2 SATB vocal score and automatic piano reduction

This template adds an automatic piano reduction to the SATB vocal score. This demonstrates one of the strengths of LilyPond – you can use a music definition more than once. If you make any changes to the vocal notes (say, tenorMusic), then the changes will also apply to the piano reduction.

     \version "2.6.0"
     global = {
        \key c \major
        \time 4/4
     }
     
     sopMusic = \relative c'' {
        c4 c c8[( b)] c4
     }
     sopWords = \lyricmode {
        hi hi hi hi
     }
     
     altoMusic = \relative c' {
        e4 f d e
     }
     altoWords =\lyricmode {
        ha ha ha ha
     }
     
     tenorMusic = \relative c' {
        g4 a f g
     }
     tenorWords = \lyricmode {
        hu hu hu hu
     }
     bassMusic = \relative c {
        c4 c g c
     }
     bassWords = \lyricmode {
        ho ho ho ho
     }
     
     \layout {
       \context {
              % a little smaller so lyrics
              % can be closer to the staff
              \Staff
               minimumVerticalExtent = #'(-3 . 3)
       }
     }
     
     <<
       \context ChoirStaff
       <<
         \context Lyrics = sopranos { s1 }
         \context Staff = women <<
           \context Voice =
             sopranos { \voiceOne << \global \sopMusic >> }
           \context Voice =
             altos { \voiceTwo << \global \altoMusic >> }
         >>
         \context Lyrics = altos { s1 }
         \context Lyrics = tenors { s1 }
         \context Staff = men <<
           \clef bass
           \context Voice =
             tenors { \voiceOne <<\global \tenorMusic >> }
           \context Voice =
             basses { \voiceTwo <<\global \bassMusic >> }
         >>
         \context Lyrics = basses { s1 }
         \context Lyrics = sopranos \lyricsto sopranos \sopWords
         \context Lyrics = altos \lyricsto altos \altoWords
         \context Lyrics = tenors \lyricsto tenors \tenorWords
         \context Lyrics = basses \lyricsto basses \bassWords
       >>
       \new PianoStaff
       <<
         \new Staff <<
           \set Staff.printPartCombineTexts = ##f
           \partcombine
           << \global \sopMusic >>
           << \global \altoMusic >>
         >>
         \new Staff <<
           \clef bass
           \set Staff.printPartCombineTexts = ##f
           \partcombine
           << \global \tenorMusic >>
           << \global \bassMusic >>
         >>
       >>
     >>

[image of music]

3.5 Ancient notation templates

3.5.1 Transcription of mensural music

When transcribing mensural music, an incipit at the beginning of the piece is useful to indicate the original key and tempo. While today musicians are used to bar lines in order to faster recognize rhythmic patterns, bar lines where not yet invented during the period of mensural music; in fact, the meter often changed after every few notes. As a compromise, bar lines are often printed between the staves rather than on the staves.

\version "2.6.0"

global = {
  \set Score.skipBars = ##t

  % incipit
  \once \override Score.SystemStartBracket #'transparent = ##t
  \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
  \key f \major
  \time 2/2
  \once \override Staff.TimeSignature #'style = #'neomensural
  \override Voice.NoteHead #'style = #'neomensural
  \override Voice.Rest #'style = #'neomensural
  \set Staff.printKeyCancellation = ##f
  \cadenzaOn % turn off bar lines
  \skip 1*10
  \once \override Staff.BarLine #'transparent = ##f
  \bar "||"
  \skip 1*1 % need this extra \skip such that clef change comes
            % after bar line
  \bar ""

  % main
  \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
  \cadenzaOff % turn bar lines on again
  \once \override Staff.Clef #'full-size-change = ##t
  \set Staff.forceClef = ##t
  \key g \major
  \time 4/4
  \override Voice.NoteHead #'style = #'default
  \override Voice.Rest #'style = #'default

  % FIXME: setting printKeyCancellation back to #t must not
  % occur in the first bar after the incipit.  Dto. for forceClef.
  % Therefore, we need an extra \skip.
  \skip 1*1
  \set Staff.printKeyCancellation = ##t
  \set Staff.forceClef = ##f

  \skip 1*7 % the actual music

  % let finis bar go through all staves
  \override Staff.BarLine #'transparent = ##f

  % finis bar
  \bar "|."
}

discantusNotes = {
  \transpose c' c'' {
    \set Staff.instrument = "Discantus  "

    % incipit
    \clef "neomensural-c1"
    c'1. s2   % two bars
    \skip 1*8 % eight bars
    \skip 1*1 % one bar

    % main
    \clef "treble"
    d'2. d'4 |
    b e' d'2 |
    c'4 e'4.( d'8 c' b |
    a4) b a2 |
    b4.( c'8 d'4) c'4 |
    \once \override NoteHead #'transparent = ##t c'1 |
    b\breve |
  }
}

discantusLyrics = \lyricmode {
  % incipit
  IV-

  % main
  Ju -- bi -- |
  la -- te De -- |
  o, om --
  nis ter -- |
  ra, __ om- |
  "..." |
  -us. |
}

altusNotes = {
  \transpose c' c'' {
    \set Staff.instrument = "Altus  "

    % incipit
    \clef "neomensural-c3"
    r1        % one bar
    f1. s2    % two bars
    \skip 1*7 % seven bars
    \skip 1*1 % one bar

    % main
    \clef "treble"
    r2 g2. e4 fis g | % two bars
    a2 g4 e |
    fis g4.( fis16 e fis4) |
    g1 |
    \once \override NoteHead #'transparent = ##t g1 |
    g\breve |
  }
}

altusLyrics = \lyricmode {
  % incipit
  IV-

  % main
  Ju -- bi -- la -- te | % two bars
  De -- o, om -- |
  nis ter -- ra, |
  "..." |
  -us. |
}

tenorNotes = {
  \transpose c' c' {
    \set Staff.instrument = "Tenor  "

    % incipit
    \clef "neomensural-c4"
    r\longa   % four bars
    r\breve   % two bars
    r1        % one bar
    c'1. s2   % two bars
    \skip 1*1 % one bar
    \skip 1*1 % one bar

    % main
    \clef "treble_8"
    R1 |
    R1 |
    R1 |
    r2 d'2. d'4 b e' | % two bars
    \once \override NoteHead #'transparent = ##t e'1 |
    d'\breve |
  }
}

tenorLyrics = \lyricmode {
  % incipit
  IV-

  % main
  Ju -- bi -- la -- te | % two bars
  "..." |
  -us. |
}

bassusNotes = {
  \transpose c' c' {
    \set Staff.instrument = "Bassus  "

    % incipit
    \clef "bass"
    r\maxima  % eight bars
    f1. s2    % two bars
    \skip 1*1 % one bar

    % main
    \clef "bass"
    R1 |
    R1 |
    R1 |
    R1 |
    g2. e4 |
    \once \override NoteHead #'transparent = ##t e1 |
    g\breve |
  }
}

bassusLyrics = \lyricmode {
  % incipit
  IV-

  % main
  Ju -- bi- |
  "..." |
  -us. |
}

\score {
  \context StaffGroup = choirStaff <<
    \context Voice =
      discantusNotes << \global \discantusNotes >>
    \context Lyrics =
      discantusLyrics \lyricsto discantusNotes { \discantusLyrics }
    \context Voice =
      altusNotes << \global \altusNotes >>
    \context Lyrics =
      altusLyrics \lyricsto altusNotes { \altusLyrics }
    \context Voice =
      tenorNotes << \global \tenorNotes >>
    \context Lyrics =
      tenorLyrics \lyricsto tenorNotes { \tenorLyrics }
    \context Voice =
      bassusNotes << \global \bassusNotes >>
    \context Lyrics =
      bassusLyrics \lyricsto bassusNotes { \bassusLyrics }
  >>
  \layout {
    \context {
      \Score
      \override BarLine #'transparent = ##t
      \remove "System_start_delimiter_engraver"
    }
    \context {
      \Voice
      \override Slur #'transparent = ##t
    }
  }
}

[image of music]

3.6 Jazz combo

This is a much more complicated template, for a jazz ensemble. Note that all instruments are notated in \key c \major. This refers to the key in concert pitch; LilyPond will automatically transpose the key if the music is within a \transpose section.