Help:LilyPond

Commands
These commands alter the way LilyPond and the Score extension render notation. For commands that just insert musical symbols, see Help:List of musical symbols.

Relative notes
The  command can be used to indicate that pitches should always be relative to the last pitch entered. This is the easiest method of entering pitches. A pitch will be assumed to be the closest note of that pitch to the previous note in the staff. This can be raised an octave by entering an apostrophe after the note (but before the duration or any other modifier); two apostrophes will raise the pitch by two octaves, etc. The opposite, lowering the pitch by an octave, can be done by entering a comma after the note; again, two commas will lower the pitch by two octaves, etc.

Absolute notes
If the  command is not used, pitches will be absolute and each must be set manually. As with relative notes, commas and apostrophes following the pitch name will decrease or increase the octave. All notes are relative to bass c.

So,  will always be bass c,   will always be middle c,   will always be treble c and so forth.

Accidentals
To add an accidental to a note, just add is for sharp or es for flat.

Polyphony
Sometimes there are two sets of notes on the same bar. This can be represented using the following format:

For example:


 * Notes:
 * When transcribing, the different sets of notes can sometime be distinguished by the direction of the stems (up or down).
 * Both sets of notes should have the same overall duration.
 * Lyrics will skip these bars if  is used.  To align lyrics to the notes in these bars, they need to be aligned manually.

Repetition
To repeat the previous chord, without writing the whole thing out again, you can use the letter. There can be single notes in between two uses of the chord.

Only the pitches will be copied. Articulations and other mark-ups will not be repeated but can be applied again as normal (or changed to a different mark-up). Durations will match the previous note as normal, but these can be changed as well.

Multiple staves
Each staff, or stave, is represented by a new block within the score tags. These blocks are grouped by the bookending them with double angle brackets. For example:

Example:


 * Notes
 * If using relative notes, the first note on the second staff will be relative to the last note on the first staff, and so forth.
 * It is recommended that the entire first staff be completed before moving on the start the second staff, before moving on to the third, etc; otherwise the subsequent note positions will keep changing.

Staff group
A staff group (or ensemble staff) connects multiple staves with a bracket and the bar lines continue across all staves. This creates a "system" to group different instruments that should be played simultaneously.

Grand staff
A grand staff (or great stave) groups mutliple staves that should be played on the same instrument. This displays a brace instead of a bracket.

The bass clef shown here in the second staff needs to be added manually. It is common but can be left out if required.

Example:

There is also a Piano Staff object in LilyPond that is mostly identical to the Grand Staff.

Nested staves
Groups of staves can be nested for more complicated arrangements.

Example:

Lyrics
There are several different ways of adding lyrics to a score.

Manual durations
Lyrics can have set durations just like notes. Normally LilyPond assigns lyrics to notes automatically, but this sometimes differ from the original printed lyrics. For example, slurred notes have only one lyric attached to the whole slur and polyphonic sections are skipped entirely for the purposes of lyrics. Manually assigning durations helps to avoid this, as the lyrics are separate from the notes.

To do this, the lyrics block must be created in  instead of using , as follows:

The two (or more) blocks are separate and need to be joined together manually. The  command already contains the code to do so. To connect them manually, the blocks must be bookended with double angle-brackets, like so:

Each lyric (or piece of lyric) needs to be given a duration just like a note, by a number immediately after the lyric itself. There should be no space between the lyric and the duration. If no duration is assigned to a lyric, the last used duration will be used, just as it would with a note. For example:

This can add more lyrics to a bar than there are notes:

Hyphenated lyrics will work with this method but extender will not be generated. The only way to generate extender lines would be to declare an associated voice with the  command.

Associated voice
Lyrics with manual duration will be left-aligned to the position of the appropriate note in the score. Extender lines also cannot be generated as the lyrics are not associated with any note and the the length of the line cannot be determined. To overcome that, the  command can be used to associate, or link, the lyrics with a melody in another block.

The block containing the melody (musical notation) must be created as. The block containing the lyrics must also contain the command. For example:

This will make the lyrics centre-aligned on the note positions and allow the system to generate extender lines.

Additional notes

 * Stanzas can be numbered by the  command at the beginning of the lyrics block. Eg:


 * The appearance of the lyrics can be altered with the  command:

Partial measures
The  command can be used to create partial measures. The command should be followed by a duration, which should be the length before the start of the next measure.

Key signatures
The key signature is a set of sharp or flat symbols on a staff, often near the clef. To identify the key signature of a piece of music, so it can be replicated in LilyPond, the "circle of fifths" diagram can be useful or use the following table.

If there is no set of either sharps or flats, then the key is either C major or A minor and no code needs to be entered (unless dealing with transposing instruments). Each key signature has two relative keys, a major key and a minor key.

The key signature can be entered with the  command followed by the key and either   or   as appropriate. For example, the B minor key signature:

Gregorian chant
If required, it is possible to transcribe Gregorian chant in both traditional 4-line neumatic notation and in more modern variants. The exact syntax for traditional notation is described at the relevant documentation page. The layout of the notes depends on the text. In cases where one word stretches over more than one note, it must be written as  instead of the usual   to display properly, and syllables which are to be sung to more than one note, for example as a result of a ligature (flexa, pes, &c.), require a blank (i.e.  ) to be used for the second and subsequent notes.