Skip to content

musicXML export in Frescobaldi

Peter Bjuhr edited this page Feb 2, 2015 · 39 revisions

Project overview

In October 2013 the development of a musicXML-export function internal to Frescobaldi was started. The initial idea came from this repo, and was to use Frescobaldi's representation of the lilypond source code and convert that into a XML-structure. The hope is that this project can constitute a catalyst for the overall ly2xml-project and that some parts of it may be contributive to the development of a LilyPond function.

The script can roughly be divided into three different parts:

  1. The source code is parsed with the help of Frescobaldi'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 (through Frescobaldi) could be used an integrated part in a score creation process using several different applications were LilyPond needn't be the final destination. Frescobaldi 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, with the limitations listed below.

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

  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 an even better internal representation of the source code in Frescobaldi, 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. See the results of the performed tests below for more details of the progress. And feel free to make requests for features that is still missing.

Performed tests

Tests carried out to try out the ability of the export function.

Test scores

Scores designed to give an intermediate overview of the current status of the export function:

Export Demo (simple)

textfiles: original ly-file | exported XML-file | re-imported ly-file (musicxml2ly)

images: original | re-imported (musicxml2ly) | re-imported (MuseScore)

Sarabande (Bach)

textfiles: original ly-file | exported XML-file | re-imported ly-file (musicxml2ly)

images: original | re-imported (musicxml2ly) | re-imported (MuseScore)

Slightly restructured source file

textfiles: original ly-file | exported XML-file | re-imported ly-file (musicxml2ly)

images: original | re-imported (musicxml2ly) | re-imported (MuseScore)

LilyPond Demo

textfiles: original ly-file | exported XML-file | re-imported ly-file (musicxml2ly)

images: original | re-imported (musicxml2ly) | re-imported (MuseScore)

Export Demo (advanced)

textfiles: original ly-file | exported XML-file | re-imported ly-file (musicxml2ly)

images: original | re-imported (musicxml2ly) | re-imported (MuseScore)

MusicXML test suite

The XML-files in LilyPond's unofficial MusicXML test suite are imported with musicxml2ly and then exported back to musicXML to test the functionality of the script. You can follow the progress of these tests below. (Files marked with '?!' are only relevant for import tests.

Basics: Pitches, Rests, Rhythm

  • 01a-Pitches-Pitches.xml
  • 01b-Pitches-Intervals.xml
  • 01c-Pitches-NoVoiceElement.xml ?!
  • 01d-Pitches-Microtones.xml
  • 01e-Pitches-ParenthesizedAccidentals.xml cautionary, parentheses implemented
  • 01f-Pitches-ParenthesizedMicrotoneAccidentals.xml
  • 02a-Rests-Durations.xml
  • 02b-Rests-PitchedRests.xml
  • 02c-Rests-MultiMeasureRests.xml
  • 02d-Rests-Multimeasure-TimeSignatures.xml
  • 02e-Rests-NoType.xml ?! \partial not yet supported
  • 03a-Rhythm-Durations.xml
  • 03b-Rhythm-Backup.xml
  • 03c-Rhythm-DivisionChange.xml ?!
  • 03d-Rhythm-DottedDurations-Factors.xml

Staff attributes: Time signatures, Clefs, Key signatures

  • 11a-TimeSignatures.xml
  • 11b-TimeSignatures-NoTime.xml ?!
  • 11c-TimeSignatures-CompoundSimple.xml
  • 11d-TimeSignatures-CompoundMultiple.xml
  • 11e-TimeSignatures-CompoundMixed.xml
  • 11f-TimeSignatures-SymbolMeaning.xml
  • 11g-TimeSignatures-SingleNumber.xml
  • 11h-TimeSignatures-SenzaMisura.xml
  • 12a-Clefs.xml
  • 12b-Clefs-NoKeyOrClef.xml ?!
  • 13a-KeySignatures.xml
  • 13b-KeySignatures-ChurchModes.xml
  • 13c-KeySignatures-NonTraditional.xml
  • 13d-KeySignatures-Microtones.xml
  • 14a-StaffDetails-LineChanges.xml

###Note settings: Chorded notes, note heads, tuplets, grace notes

  • 21a-Chord-Basic.xml
  • 21b-Chords-TwoNotes.xml
  • 21c-Chords-ThreeNotesDuration.xml
  • 21d-Chords-SchubertStabatMater.xml
  • 21e-Chords-PickupMeasures.xml
  • 21f-Chord-ElementInBetween.xml
  • 22a-Noteheads.xml
  • 22b-Staff-Notestyles.xml
  • 22c-Noteheads-Chords.xml
  • 22d-Parenthesized-Noteheads.xml
  • 23a-Tuplets.xml
  • 23b-Tuplets-Styles.xml
  • 23c-Tuplet-Display-NonStandard.xml
  • 23d-Tuplets-Nested.xml
  • 23e-Tuplets-Tremolo.xml
  • 23f-Tuplets-DurationButNoBracket.xml
  • 24a-GraceNotes.xml
  • 24b-ChordAsGraceNote.xml
  • 24c-GraceNote-MeasureEnd.xml
  • 24d-AfterGrace.xml
  • 24e-GraceNote-StaffChange.xml
  • 24f-GraceNote-Slur.xml

Notations and articulations: Dynamics (staff-attached), Notations (note-attached), Spanners

  • 31a-Directions.xml
  • 31c-MetronomeMarks.xml
  • 32a-Notations.xml
  • 32b-Articulations-Texts.xml
  • 32c-MuvltipleNotationChildren.xml ?!
  • 32d-Arpeggio.xml
  • 33a-Spanners.xml
  • 33b-Spanners-Tie.xml
  • 33c-Spanners-Slurs.xml
  • 33d-Spanners-OctaveShifts.xml
  • 33e-Spanners-OctaveShifts-InvalidSize.xml
  • 33f-Trill-EndingOnGraceNote.xml
  • 33g-Slur-ChordedNotes.xml
  • 33h-Spanners-Glissando.xml
  • 33i-Ties-NotEnded.xml

Other tests

Known issues