Skip to content

LilyPond Syntax

You can use any valid LilyPond syntax with astro-lilypond. This page covers the most common patterns.

Note names run from a to g. Inside \relative, each pitch is chosen to be as close as possible to the previous note — within a fourth above or below. Use ' to raise by one octave and , to lower.

\relative c' {
c4 d e f | g a b c |
c' b a g | f e d c |
}

Notes inherit the previous note’s duration by default. A new duration can be set by appending a number to the note:

Syntax Duration Name
1 Whole Semibreve
2 Half Minim
4 Quarter Crotchet
8 Eighth Quaver
16 Sixteenth Semiquaver
32 Thirty-second Demisemiquaver
\relative c' {
c4 c8 c c16 c c c c32 c c c c c c c
}

Append dots to extend by half the note’s value. Double-dotting adds three-quarters:

Syntax Duration
c4. Dotted quarter
c4.. Double-dotted quarter
\relative c' {
c4. c8 c4 r |
c2. c4 |
c4.. c16 c2 |
}

r is an ordinary rest, R is a full-measure rest displayed centred in the bar, and s reserves time without printing anything.

\relative c' {
c4 r4 c4 r4 |
r2 c2 |
R1 |
}

Accidentals are written as is and es suffixes appended to the note name.

Syntax Meaning Example
is Sharp cis = C♯
es Flat bes = B♭
isis Double sharp cisis = C𝄪
eses Double flat ceses = C𝄫
\relative c' {
c4 cis d dis | e f fis g |
g4 ges f fes | e es d des |
}

Set the key with \key and the time signature with \time. Both take effect from where they appear.

\relative c' {
\key g \major
\time 3/4
g4 a b | c b a | g2. |
}

LilyPond inserts single barlines automatically. Use \bar to override:

Syntax Description
\bar "||" Double barline
\bar "|." Final barline
\bar ".|:" Start repeat
\bar ":|." End repeat
\relative c' {
c1 \bar "||"
c1 \bar ".|:"
c1 \bar ":|."
c1 \bar "|."
}

Write a chord by wrapping notes in angle brackets. All notes in the brackets share the same duration.

\relative c' {
<c e g>4 <d f a> <e g b> <c e g> |
<f a c>2 <g b d> |
}

Attach articulations after the note with a dash and a symbol:

Syntax Shorthand Name
\staccato -. Staccato
\tenuto -- Tenuto
\accent -> Accent
\marcato -^ Marcato
\staccatissimo -! Staccatissimo
\portato -_ Portato
\relative c'' {
c4-. c-- c-> c-^ |
c4-! c-_ c2 |
}
Syntax Name
\ppp Pianississimo
\pp Pianissimo
\p Piano
\mp Mezzo-piano
\mf Mezzo-forte
\f Forte
\ff Fortissimo
\fff Fortississimo
\sfz Sforzando

Use \< to begin a crescendo hairpin and \> for a diminuendo; close either with \!.

\relative c'' {
c4\pp c c c |
c4\< c c c\! |
c4\ff c\> c c\! |
c4\mp c\mf c c |
}

A slur spans from ( to ). A tie connects two notes of the same pitch with ~.

\relative c'' {
c4( d e f) |
g2~ g4 f |
e4( f~ f2) |
}

\grace places a small unmetered note before the main note. Use braces for multiple grace notes.

\relative c'' {
\grace e8 d4 c2. |
\grace { d16 e } f4 e2. |
}

\tuplet groups notes into a ratio. The most common case is triplets (\tuplet 3/2), where three notes occupy the space of two.

3 3 3
\relative c'' {
\tuplet 3/2 { c4 d e } f2 |
\tuplet 3/2 { g8 f e } \tuplet 3/2 { d c b } c2 |
}

Use << and >> to stack voices on the same staff. \voiceOne and \voiceTwo set stem directions automatically. Separate voices with \\.

\new Staff <<
\new Voice {
\voiceOne
\relative c'' { c4 b a g }
}
\new Voice {
\voiceTwo
\relative c' { e4 d c b }
}
>>