I have a lot of lilypond files for different instruments.

To get a selection for players depending on their playing skills, I'm looking for a an algorithm that analyzes a lilypond file voice by voice and outputs a difficulty factor.

My question is, if there is software available which does that?

I'd prefer command line tools for this jobs. Ideally they work like

> lilypond-voice-analysis --voice==trumpet myscores.ly 

and the output should be someting like

Overall-Difficulty: 8/10
Analysis report:
- tone range: c' ... c''
- speed: 160 bmp
- accidentals: 4#
- fast interval jumps: 
  * bar 12: d' -> f''
- other difficulties:
  * bar 14: trill
  * bar 15: glissando
  * bar 16: high note after long rest: c''

If there's no such software available today, how could it be implemented?

  • Is this question related to the music21 project?
  • Are there PHP/python/... (PHP preferred) libraries which could help here?
  • Which open source project could be extended to make such an analysis?
  • From a musical perspective: Is this idea too tough to solve formally? Are there too much things to consider to analyze music voices with respect to difficulty?
  • 1
    I believe if you are fluent with Python or Perl, it does not take long to write a parser yourself. Because the way you decide to write your music in LilyPond still can vary wildly, the "form of information" is too personal to use a common tool. Do you include a variable? Do you separate files by inclusion? It is you that decide how to format your source code, despite the scope of consideration is limited by LilyPond language. Feb 15, 2017 at 15:08

2 Answers 2


You do stuff like that with a "Scheme engraver". Take a look at files input/regression/scheme-engraver-instance.ly and ly/event-listener.ly for examples.

  • looks like a good point to start. Unfortunately I'm not deeply involved in lilypond internals nor in python. How much effort would be required to externalize these parts as a standalone script that can be extended seperately from lilypond?
    – WeSee
    Feb 15, 2017 at 8:49
  • 1
    @WeSee Your original question leads to extremely difficult algorithms -- essentially a type of machine learning. Don't expect useful results without a lot of effort. It would be really cool if you do produce an accurate tool! Feb 15, 2017 at 14:01
  • 1
    @Carl Witthoft: I think if OP restrict himself to some very organized LilyPond "coding style", the difficulty of parsing can be considerably reduced. Perl is designed for parsing, but any other decent language can do it, and modern languages are easier to maintain. If OP decides to write it, be sure to share your Github to us!! Feb 16, 2017 at 8:10

This would be tremendous lot of work and will not function at all for arbitrary lilypond files, since:

  • Tempo indication (metronome number) is not mandatory, a word like Allegro or Affetuoso does not help much
  • Difficulty is heavily depending on the desired tempo
  • I assume, that your accidentals is intended to reflect the number of accidentals in the key signature. There may be key signature changes, however.
  • There are different possibilities to represent trills (\trill, c-+, written out)
  • All other characteristics depend on the instrument (also not guaranteed to exist in lilypond source, and even if: it could be in any language, abbreviated, ...)

I guess, midi files would be a better starting point (tempo is required, instrument too, assuming General Midi mapping), even if the accidentals are missing there.

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.