3.5.1 Extracting fragments of music

It is possible to output one or more fragments of a score. To do so, use the clip-regions variable within the \layout or \paper block to define a list of explicit location of the music to be extracted, then execute lilypond with the -dclip-systems option.

\layout {
  clip-regions
  = #(list (cons (make-rhythmic-location 5 1 2)
                 (make-rhythmic-location 7 3 4)))
}

This example extracts a single fragment of the input file starting after a half note duration in fifth measure (5 1 2) and ending after the third quarter note in the seventh measure (7 3 4).

Additional fragments can be extracted by adding more pairs of make-rhythmic-location entries to the clip-regions list.

If system starts and ends are included, they include extents of the System grob, e.g., instrument names.

Grace notes at the end point of the region are not included.

Each music fragment gets written as a separate file. The extracted music is output as if it had been literally ‘cut’ from the original printed score, so if a fragment runs over one or more lines, a separate output file for each line is generated. Assuming that the above example covers two lines in the PDF output of input file foo.ly, the output files for the music fragments would be called foo-from-5.1.2-to-7.3.4-clip.pdf and foo-from-5.1.2-to-7.3.4-clip-1.pdf.

See also

Notation Reference: The \layout block.

Application Usage: Command-line usage.


LilyPond Notation Reference v2.25.17 (development-branch).