ArticleslgStudy

computer science

LilyPond

LilyPond is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand LilyPond rather than just read about it. In short: LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules, reflecting the era when scores were engraved by hand.

LilyPond — main illustration
LilyPond — illustration

Key takeaways

  • LilyPond belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect LilyPond to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of LilyPond from memory before moving on to harder problems.

Reference excerpt

LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules, reflecting the era when scores were engraved by hand. LilyPond is cross-platform, and is available for several common operating systems; released under the terms of the GNU General Public License, LilyPond is free software and part of the GNU Project.

History The LilyPond project was started in 1996 by Han-Wen Nienhuys and Jan Nieuwenhuizen, after they decided to abandon work on MPP (MusiXTeX PreProcessor), a project they began collaborating on in 1995. Its name was inspired both by the Rosegarden project and an acquaintance of Nienhuys and Nieuwenhuizen named Suzanne, a name that means lily in Hebrew (שׁוֹשַׁנָּה).

Version 1.0 LilyPond 1.0 was released on July 31, 1998, highlighting the development of a custom music font, Feta, and the complete separation of LilyPond from MusiXTeX.

Version 2.0 LilyPond 2.0 was released on September 24, 2003, announcing a simplified syntax model and a much more complete set of facilities for notating various styles of music.

Design

LilyPond is mostly written in C++ and uses Scheme (interpreted by GNU Guile) as its extension language, allowing for user customization. It has a relatively large codebase; as of March 10, 2017, the source includes over 600,000 lines of C++, 140,000 lines of Scheme, and 120,000 lines of Python code. It uses a simple text notation for music input, which LilyPond interprets and processes in a series of stages. In the final stage, music notation is output to PDF (via PostScript) or other graphical formats, such as SVG or PNG. LilyPond can also generate MIDI files that correspond to the music notation output. LilyPond is a text-based application, so it does not contain its own graphical user interface to assist with score creation. (However, a text-editor based "LilyPad" GUI for Windows and MacOS is included by default on these systems.) It does, however, have a flexible input language that strives to be simple, easing the learning curve for new users. LilyPond adheres to the WYSIWYM paradigm; the workflow for typesetting music notation with LilyPond is similar to that of preparing documents with LaTeX. LilyPond supports experimental musical notation. Its guitar facilities support alternative tunings, such as major-thirds tuning.

Software features

LilyPond's primary goal is to produce output comparable to professionally engraved scores instead of output that looks mechanical and computer-generated. An essay from the LilyPond website, written by LilyPond developers, explains some typographical issues addressed by LilyPond:

Optical font scaling: depending on the staff size, the design of the music font is slightly altered; this is a feature that Donald Knuth's Computer Modern font is known for. As a result, note heads become more rounded, and staff lines become thicker. Optical spacing: stem directions are taken into account when spacing subsequent notes. Special ledger line handling: ledger lines are shortened when accidentals are nearby, thus enhancing readability. Proportional spacing: notes can be positioned in such a way that exactly reflects their duration. For example, with this setting, the space between consecutive quarter notes is four times greater than between consecutive sixteenth notes.

Overview of input syntax The native input language for LilyPond is comprehensive, and consists of many commands needed for expressing any sort of articulation, dynamic, meter, etc. It is similar to that of TeX. The ability to embed Scheme code within a LilyPond source file permits arbitrary extensions to the input language and assists with algorithmic composition. Some general syntactic features are listed below.

Single-line comments begin with a percent sign %. Notes are represented in pitch-duration format: pitch is specified with Helmholtz pitch notation, and duration is specified with a numeral based system. The semantics of the pitch-duration format change depending on the active input mode; this is explained in depth in the LilyPond manual. For example, in absolute mode, a'4 is an A, one octave up from the base A (A3 in scientific pitch notation), of quarter note length. Commands usually begin with a backslash (such as \time, or \slurUp). The function of the command in question determines where the command is placed; for example, if the command is used to indicate a fixed dynamic on a specific note, it is placed after the note. Some common commands are represented symbolically to ease typing. One example is with slurs, where ( and ) indicate the beginning and ending of a slur, respectively. Another example is with manual beaming, where [ and ] indicate the extent of the beam. LilyPond's interface with Pango requires the input character encoding to be UTF-8. One benefit of this is that more than one language can be included in the same source file.

Example of LilyPond input file

Corresponding output

More complex output LilyPond can also create extensively customised output. An example is the short extract of a Karlheinz Stockhausen piano piece below.

Collaboration with other projects

Several graphical scorewriters—such as Rosegarden, NoteEdit, Canorus, Denemo, and TuxGuitar—can export files directly to LilyPond format. Other graphical applications serve as front ends to LilyPond, including Frescobaldi (written in Python, maintained by Wilbert Berendsen) and the LilyPondTool plugin for jEdit. Denemo integrates the PDF output of LilyPond in its display, allowing some editing operations on the final typeset score. The Mutopia Project, which distributes free content sheet music, uses LilyPond to typeset its music, as does Musipedia, a collaborative music encyclopedia. Emacs' org-mode contains support for embedding LilyPond scores into documents. OOoLilyPond, a LibreOffice extension, provides support for calling LilyPond to embed scores into documents.

Integration into MediaWiki LilyPond is available in MediaWiki via the Score extension code. This, for example, transforms the notation

into

The above is an excerpt from Ludwig van Beethoven's 9th Symphony, commonly known as "Ode to Joy". More complex scores, including lyrics, are also possible within MediaWiki wikis. See Pastime with Good Company or Il Canto degli Italiani for an example of this.

… excerpt ends here. Continue reading the full article.

Illustrations

LilyPond illustration
LilyPond illustration
LilyPond: Screenshot of LilyPond running on Linux
Screenshot of LilyPond running on Linux
LilyPond: Beethoven's Symphony No. 5 music sheet printed from a digitally engraved PDF file produced by LilyPond; released by the Mutopia Project
Beethoven's Symphony No. 5 music sheet printed from a digitally engraved PDF file produced by LilyPond; released by the Mutopia Project
LilyPond illustration

Worked examples

Example 1 — a first encounter with LilyPond

Start with the simplest possible case. Write down what LilyPond claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to LilyPond before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about LilyPond ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of LilyPond

In research
LilyPond appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses LilyPond in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
LilyPond is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1996 software, Cross-platform software, Free music software, so understanding it makes those chapters shorter.
In everyday life
Look for LilyPond outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “LilyPond” →

How to study LilyPond in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what LilyPond means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain LilyPond out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is LilyPond in simple terms?

LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules, reflecting the era when scores were engraved by hand.

Why does LilyPond matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study LilyPond?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on LilyPond.

Tags

  • 1996 software
  • Cross-platform software
  • Free music software
  • Free software programmed in C++
  • Free typesetting software
  • GNU Project software
  • LilyPond
  • Music notation file formats
  • Scorewriters
  • Scorewriters for Linux
  • Software using the GNU General Public License

Keep exploring