LilyPond
LilyPond music engraving — pitch syntax, articulation, score structure, compilation to PDF, and multi-voice parts.
LilyPond Basics
What is LilyPond?
LilyPond: text-based music engraving system
Input: .ly text file (like LaTeX for music)
Output: PDF, PNG, SVG
Quality: publication-grade scores
Philosophy: input describes WHAT, LilyPond decides HOW to engrave
Install: pacman -S lilypond
Compile: lilypond file.ly → file.pdf
Note input
% Pitch names: c d e f g a b
% Duration: 1=whole 2=half 4=quarter 8=eighth 16=sixteenth
% Sharp: is (cis = C#), Flat: es (ees = Eb)
\relative c' {
c4 d e f | % quarter notes: C D E F
g2 g | % half notes: G G
a8 a a a a2 | % eighth notes then half
g1 | % whole note G
}
Octave notation
% Relative mode: ' goes up, , goes down from previous note
\relative c' {
c d e f g a b % ascending scale
c' c, c % c' = up octave, c, = down octave
}
% Absolute mode: c = C3, c' = C4, c'' = C5
{ c' d' e' f' g' a' b' c'' }
Document Structure
Minimal score
\version "2.24.0"
\header {
title = "My Piece"
composer = "Evan Rosado"
}
\score {
\relative c' {
\key c \major
\time 4/4
\tempo 4 = 120
c4 e g c | g2 e | c1 \bar "|."
}
\layout { }
\midi { }
}
Key and time signatures
\key c \major % C major
\key a \minor % A minor
\key g \major % G major (1 sharp)
\key bes \major % Bb major (2 flats)
\time 4/4 % common time
\time 3/4 % waltz
\time 6/8 % compound duple
\time 7/8 % odd meter
Notation Features
Dynamics and articulation
c4\p d\< e f | % piano, crescendo
g4\f a\> g f | % forte, decrescendo
e4\mf r r2 | % mezzo-forte, rests
c4-. d-. e-. f-. % staccato
c4-- d-- e-- f-- % tenuto
c4-> d-> e-> f-> % accent
c4( d e f) % slur (legato)
c4~ c % tie (same pitch)
Chords and polyphony
% Chords: angle brackets
<c e g>4 <d f a> <e g b> <f a c'>
% Multiple voices on one staff
\new Staff {
<< { c'4 d' e' f' } \\ { a2 g } >>
}
% Piano grand staff
\new PianoStaff <<
\new Staff { \relative c'' { c4 d e f } }
\new Staff { \clef bass \relative c { c2 g } }
>>
Compilation and Workflow
Build commands
# Basic compilation
lilypond piece.ly # → piece.pdf
# PNG output (for embedding)
lilypond --png piece.ly # → piece.png
# Specific output format
lilypond -dbackend=svg piece.ly # → piece.svg
# Preview mode (faster, draft quality)
lilypond -dpreview piece.ly
# Set paper size
lilypond -dpaper-size='"letter"' piece.ly