Lilypond
Usage
Enclose Lilypond fragment with [lilypond] and [/lilypond] pair.
Official Documentation
On Lilypond official website. But remember to check lilypond’s version, as newer versions are usually not backward compatible with older ones.
Other external documentation
There are many introductory articles for Lilypond, for example:
- Linux Journal: Part 1 and Part 2
- A Spanish tutorial by David Asorey Álvarez
Getting started
As a very simple example, try this fragment:
[lilypond] \relative { \key c \major e4 d c2 | } [/lilypond]
- Fragments are enclosed in curly brackets.
- “\key c \major” is obvious: it means using C major for this staff.
- Each note is followed by its length; ‘4′, ‘2′ means crotchet and minim respectively. Note that the second note has its length omitted, which means reusing previous note length.
- The ending ‘|’ denotes a bar.
- “\relative” is a bit harder to explain: it means using middle C as basis, then dynamically calculate whether each note has higher or lower pitch depending on the distance from previous note. One can refer to documentation of \relative mode for detailed explanation.
Here comes another fragment showing more features:
[lilypond] \relative { \clef bass \key g \major gis4 fis ees4. d8 c2 r \bar "|." } [/lilypond]
(Alternatively, clicking on the image can also view its source.)
- It adopts German accidental notation by default, so “is” suffix means sharp and “es” suffix means flat.
- The key signature of the piece also affects printing of accidental marks. For a passage in G major, a bare “f” note means one with natural sign (f♮), while “fis” is f sharp (f♯). The situation is opposite in C major. In one sentence, enter what you expected to hear, not what you expected to see.
- \clef is quite self-explanatory here; there are many types of clef to choose.
- The ‘8′, ‘4′, ‘1′ means quaver, crotchet and semibreve correspondingly, and the dot after ees4 means dotted note.
- Rest is denoted by ‘r’.
- Note that bar line is not entered; if not, lilypond can calculate its location automatically.
- \bar forces special type of bar lines. Here “|.” denotes end of piece. Visit Lilypond documentation of bar lines for more.
View some more examples in action.
