midicn 中文

LilyPond and Text-Based Notation

A score kept as plain text rebuilds the whole page from one edit, at the cost of not seeing it while you type.

1 min read0 characters条目Notation and ToolsUpdated 2026-10-31

notationLilyPondplain textengraving

Three notes change in a quartet part. A graphical editor means opening three windows; a text file means editing three lines, compiling once, and letting the page reflow around the new content.

What text buys you

Keep a score as plain text and changes become visible line by line: which pitch moved, which slur was cut, who made the edit. Material can be defined once as a variable and cited in three movements, so one fix propagates everywhere. Templates with different parameters produce dozens of parts in a single pass. The price is concrete: layout exists only after compilation, and one missing brace sends you hunting back from an error line.

Layers inside one file

A workable file separates four layers: version and paper, music variables, the assembly of staves and lyrics, and the output blocks. Variables hold pitch and rhythm; assembly decides which staff receives them and which text sits underneath; output produces page and sound separately. Keep the layers apart and a pitch fix never disturbs spacing.

LayerTypical syntaxWhat changes downstream
Version and paper\version, \paper, global staff sizeType size, margins, staff spacing
Music variablesmusic = \relative c' { … }Every place that cites it
Assembly\new Staff, \new Lyrics \lyricstoStaff count, voice and text ownership
Output\layout, \midiPDF layout and audio

Passing the compiler

Run lilypond on the file and you get a PDF plus a log. The most useful lines are bar checks: place a bar line at every measure and a duration that disagrees with the metre is reported with a line number. Undefined variables, ledger lines far outside the staff and missing fonts surface in the same place. Before a version upgrade, run convert-ly over the syntax, then compare output passage by passage rather than converting everything at once.

Parts and batches

Score and parts can come from one source: tag each passage, keep only the staves a player needs at export. Clefs, transposition and page turns in parts need their own settings; the score layout will not adapt for them. For batch work, pull key, tempo and title out as parameters and leave structure in the template. When something breaks, check the parameter table before the template.

Where it breaks

Layout is algorithmic. Special spacing needs override after override, and a tall stack of overrides is brittle across versions. A large score takes time to compile, and one pitch change rebuilds the whole file. Collaborators who read music but not code cannot edit directly. Microtones, graphic scores and some regional systems need extra packages or hand drawing. Exported MIDI is a by-product: slurs and dynamic marks survive poorly, so do not treat it as a performance reference.

Listen in the library

Ich ruf zu dir, Herr Jesus ChristC13:14Three music tracks still carry the word \new in their names, showing how staves become MIDI tracksDetailsErlkoenigC13:58Erlkönig puts the voice and the two piano staves on separate tracks, named up and down from one staff groupDetailsSymphony5 1C15:16Beethoven's Fifth, first movement, twelve tracks named one through twelve, each wind, horn and string line kept apartDetails

All tracks from midicn-lib — inline badge is the license tier (C1 commercial / C2 non-commercial / C3 study only).

Along the same line

Sources

  • LilyPond 官方 Notation Reference,音乐变量、谱表装配与版面设置章节
  • Mutopia Project 的公开乐谱源文件,LilyPond 源与导出 MIDI 可对照
  • Elaine Gould, Behind Bars, Faber Music,总谱与分谱排版的一般规范