Lilypond is free, open-source music notation software that can be used to create sheet music in alternative notation systems. One of LilyPond’s strengths is its flexibility.  It is designed so that its output can be modified using the Scheme programming language.  This opens the door to a world of customization without having to alter LilyPond’s source code. This page documents how to use LilyPond with alternative music notation systems with a chromatic staff.


The following files can be used to produce music in a number of alternative music notation systems.  These files demonstrate the use of the specific “lower-level” techniques documented below.

  • — A LilyPond file containing LilyPond and Scheme code that supports alternative music notation systems.
  • — A LilyPond music file demonstrating the use of the file.
  • MNP-music-demo.pdf — LilyPond’s PDF output from the file.

There are basically just a few steps to use an existing traditional LilyPond music file to create a PDF of music in an alternative notation system:

  1. Download the file above and put it in the same directory as your music file.
  2. Include the file at the top of the music file. (See Including LilyPond Files.) The file and the music file must be in the same directory for the \include command to work.
  3. Change “Staff” in the music file to the name of any alternative staff that is defined at the bottom of the file. (Examples are “StaffFiveLineOne” or “StaffKlavarMirckTwo”. See the file for more.)
  4. If the alternative staff is larger than two octaves and is not a compressed staff (i.e. Twinline, TwinNote), then you may need to make the following adjustment for any bass clefs that appear in the music. Enter “\set Staff.middleCPosition = #18” just after any instances of “\clef bass” in the music file. Otherwise the notes may not appear in the expected places on the staff.
  5. Run LilyPond on your music file. Voilà! You now have a PDF of music in an alternative notation system.

Older Demo Files

These are some older demo files that are inferior to those shown above.

Customizing Note Positions

Semitone Spacing

staffLineLayoutFunction is used to customize the default vertical positions of notes on the staff. For a standard pitch-proportional chromatic staff with a semitone between each adjacent note position (line or space), set it to use the ly:pitch-semitones function:

staffLineLayoutFunction = #ly:pitch-semitones

Other Spacing Patterns

For notation systems like Equiton or TwinNote that have a staff based on a whole tone scale with a whole tone between each adjacent note position (line or space), use the following function. (Thanks to Graham Breed for this function.)

staffLineLayoutFunction = #(lambda (p) (floor (/ (+ (ly:pitch-semitones p) 0) 2)))

For staves based on other intervals simply change the number 2 in the function above to the number of semitones in the interval you want. Change the number 0 in the formula to 1 (or 2, etc.) to adjust which notes share a line or space (and which are on different lines or spaces).  See: Snippet: Staves based on a whole tone scale (or other interval)

For Twinline and similar chromatic staves with one note on a line and three in a space, use the following version of the function which uses “banker’s rounding” to get the desired 1-3-1-3-1-3… pattern.

staffLineLayoutFunction = #(lambda (p) (+ 1 (round (+ -1 (/ (ly:pitch-semitones p) 2)))))

(Note: Graham Breed has also shown how to use the ly:set-default-scale scheme function to reposition notes: Dodecaphonic staff snippet)


Customizing Staff Lines

In LilyPond the vertical position of notes and the vertical position of staff lines are independent of each other.  Notes are not placed on a line or space per se, but at a vertical position that may or may not coincide with the vertical position of a line or space.

A staff’s line pattern can be customized using Staff.StaffSymbol and the line-positions property. See Changing the staff line pattern (Staff Symbol Properties). The numbers ( 4 2 0 -2 -4 ) in the line of code below represent the five standard line positions.  A different list of numbers will produce a custom line pattern.

\override Staff.StaffSymbol #'line-positions = #'( 4 2 0 -2 -4 )

It is possible to simulate bold lines by adding extra lines close together with the line-positions property.  Go to Modifying a single staff and scroll down to “Making some staff lines thicker than the others” for more about this trick.

Dashed or dotted lines can be achieved using the Scheme function found in this post to the LilyPond user list.  This function is also included in the file linked at the top of this page.


Customizing Ledger Lines

In LilyPond version 2.15.13 or higher, ledger line positions can be customized, including ledger lines that appear above or below the staff and those that are internal to it. Similar to customizing staff lines, you use Staff.StaffSymbol with the ledger-positions property:

\override Staff.StaffSymbol #'ledger-positions = #'(-12 -10 -8 -6 -4 -2 (0 2) 4 6 8 10 12)

The numbers define positions for a series of ledger lines, this series is repeated in a cycle extending both up and down the pitch axis. The last number in the series is also the first ledger line in the next repetition of the cycle (i.e. the last number refers to the same ledger line as the first number, just in the next iteration of the series).

Internal ledger lines appear by default when custom staff line positions are set with a gap between them of 4 steps or more.

You can group multiple ledger lines together by placing them in parentheses, as shown above: (0 2). When one of the ledger lines in a group appears all of the others will appear as well. This can be used to achieve thicker, bold ledger lines by using the same trick described above for bold staff lines.

Thanks goes to Piers Titus for his work adding this feature to LilyPond. (This supersedes Kevin Dalley’s code for internal ledger lines that was never added to LilyPond.) More details…

An Older Deprecated Method

Before the method above was available, internal ledger lines could be achieved by creating a custom notehead stencil (glyph) that has the ledger line included in it, and then assigning that notehead stencil to the pitches that require a ledger line. This is how it is done in the TwinNote Demo file (linked above). With systems that do not already use custom note heads this would be more difficult since you would have to access to the default oval note head stencil and combine it with a ledger line stencil. You would also need to create different stencils for quarter notes, half notes, and whole notes, and then have a script to determine when to use which based on a note’s duration.


Customizing Noteheads

Noteheads can be colored: Coloring notes depending on their pitch

Notehead styles (shapes) can be customized using a modified version of the code for coloring note heads. See our for the modified code.  This offers more fine-grained control than LilyPond’s shapeNoteStyles property that is used for Shape Note notation. That property only allows you to set custom shapes for each step of the scale (as set by the key signature or the tonic property). It does not let you customize each chromatic scale degree. For example, whatever shape you designate for G will also be the shape for G# and Gb.)

Documentation for notehead styles (shapes):

Custom notehead shapes can be created with ly:make-stencil, see this snippet on Using PostScript to generate special note head shapes. This PostScript stencil method was used to create the triangle note shapes in these TwinNote demo files:

This TwinNote demo also has a different, more streamlined script for customizing noteheads based on pitch.


Customizing Stems

This override prevents LilyPond from extending stems to the middle of the staff. This is particularly helpful with multiple-octave chromatic staves, otherwise you can get stems that extend an octave or more. It is shown in this snippet: Preventing Stem Extension

\override Stem #'no-stem-extend = ##t

The following TwinNote demo LilyPond file (.ly) includes a script for adjusting the stems so that they “attach” to the note head correctly in TwinNote (not too short or too long). It also includes a script that gives half notes a double stem to differentiate them from quarter notes.


Removing Unneeded Symbols

Accidental signs, key signatures, and clefs can be removed as follows. Other unneeded symbols can be hidden: Making symbols invisible

\remove "Accidental_engraver"
\remove "Key_engraver"
\remove "Clef_engraver"

Desired Features List

Most desired features can now be achieved as described above. Any additional desired features can be listed here, should they come to light.