3.7.3 Saving music events to a file

Music events can be saved to a file on a per-staff basis by including a file in your main score.

\include "event-listener.ly"

This creates file(s) called ‘FILENAME-STAFFNAME.notes’ or ‘FILENAME-unnamed-staff.notes’ for each staff. Note that if you have multiple unnamed staves, the events for all staves are mixed together in the same file. The output looks like this:

0.000   note     57       4   p-c 2 12
0.000   dynamic  f
0.250   note     62       4   p-c 7 12
0.500   note     66       8   p-c 9 12
0.625   note     69       8   p-c 14 12
0.750   rest     4
0.750   breathe

The syntax is a tab-delimited line, with two fixed fields on each line followed by optional parameters.

time  type  …params…

This information can easily be read into other programs such as python scripts, and can be very useful for researchers wishing to perform musical analysis or playback experiments with LilyPond.

Known issues and warnings

Not all lilypond music events are supported by ‘event-listener.ly’. It is intended to be a well-crafted “proof of concept”. If some events that you want to see are not included, copy ‘event-listener.ly’ into your lilypond directory and modify the file so that it outputs the information you want.

LilyPond — Notation Reference v2.24.4 (stable-branch).