Skip to content

Export LilyPond to MusicXML

Peter Bjuhr edited this page Jan 5, 2016 · 2 revisions

Project overview

In October 2013 the development of a musicXML-export function internal to Frescobaldi was started. The idea was to use Frescobaldi's representation of the lilypond source code and convert that into the MusicXML structure. Later the internal representation was greatly improved and moved to this standalone repo and along with it the export functionality.

It should be noted from the start that this approach is not optimal and should be seen as a response to the lack of an exporter in LilyPond itself.

The script can roughly be divided into three different parts:

  1. The source code is parsed with the help of Python-ly's internal representation.
  2. The score is represented in an object/list structure suitable for the conversion to XML.
  3. This structure is looped part for part, bar for bar and a XML-tree is built, which is finally written to a file.

Development thoughts and ideas

As a first aim Frescobaldi should be able to handle a workflow were a piece of music is imported to LilyPond source code, the source is manipulated musically and then finally the source is exported (back) to MusicXML. This way LilyPond could be used an integrated part in a score creation process using several different applications were LilyPond needn't be the final destination. Python-ly could even be used as a text-based MusicXML creator. It would be much easier to write a piece of music using the LilyPond syntax than to write the XML-structure directly.

Beyond this preliminary goal the aim is of course to be able to create a correct exported musicXML-file for most LilyPond source inputs.

Export of a LilyPond score to musicXML can either contain the pure musical content or additionally the complete layout information, trying to preserve as much as possible from LilyPond's superior output. The latter is much more complicated, therefore development concentrates on the content, inclusion of layout elements isn't intended at this point.

Current limitations

These are the main limitations at the moment:

  1. Currently the PipeSymbol (|) is needed to get a barline in the MusicXML output although the bar checks are non-obligatory in LilyPond.
  2. Music created with the help of Scheme code rather than with LilyPond's own syntax can not (currently) be exported.

Development progress

Thanks to the better internal representation of the source code in Python-ly, the musicXML exporter is now more stable and can handle a wider variety of different structures. One of the main advantages is that this representation now can handle all variable substitutions even from an include file.

The development is now quickly progressing towards a level where many notational elements can be exported. But it is far from perfect at this stage. See issues with label 'musicxml' for known issues. And don't hesitate to create new issues for bugs and requests.