I'm writing a program which produces scores in LilyPond. Due to some limitations in this program, the rests are written as if they were seperate notes:

r2 r4. r8 | r2 r4. e''8 | r4 r4 e''2 |

Is there a method native to LilyPond to merge these rests for each measure into code like:

r1 | r2.. e''8 | r2 e''2 |

2 Answers 2


Lilypond "knows" very little about the semantics of music notation. It knows the rhythmic duration of the symbols for notes and rests, and some rules for avoiding collisions between entities, and that's about it. Most other notation software that was originally designed in the 20th century is similar.

It is possible to write notation software which is based on semantics rather than the visual appearance of music notation. In that case, most "rests" don't really exist at all so far as the semantics are concerned. They are just marks made in the score to fill up the gaps between the notes, following a (rather complex) set of rules.

This has interesting (and time-saving!) consequences if you edit the music. The following example has all rests automatically (and correctly) generated:

enter image description here

If for some reason I decide to double the length of the first note, the entire passage is rewritten correctly with only two key strokes required, to select the first note and change its duration. The notes are split up and rebeamed as necessary, as well as rewriting the rests.

enter image description here

Of course you can override the default notation if you want to, but most of the time you shouldn't want to do that!

Whether or not it "shouldn't be too hard", it took a team of professional software developers, who all had more than a decade of experience working on music notation software, several years to produce "version 1.0" of this.

A hard part of the problem is actually figuring out what the "rules" should be, since there are many different conventions. In the software used to make these examples there are 20 or 30 situations with different user-selectable options - this a small sample, just for one time signature (6/8):

enter image description here

This sort of functionality is not likely to appear in Lilypond any time soon.

  • 2
    -1: this answer is of no relevance to the question.
    – Rosie F
    Sep 22, 2019 at 18:50

No, there is not. Lilypond is just like a programming language: it outputs exactly what you instruct it to. Adding slurs doesn't work for rests, and while they'd make real notes longer, they wouldn't output them as merged notes.

Actually, the task you describe is just what I'd expect a program producing Lilypond files would do. It shouldn't be too hard to write an extra step combining rests; you could even try it with regular expressions I guess.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.