From MusicXML to score

This page describes the steps from a MusicXML file to a printed score.

1. Read MusicXML file

 

 

 

In the musicxml project, Zong! contains classes for all supported elements of MusicXML and methods for reading them from a MusicXML file. MusicXMLDocument is the main class, which holds the MusicXML document. The names of the Java classes are usually Mxl... (for MusicXML), followed by the MusicXML element name, like MxlNote for a <note> element.

2. Convert to internal model

 

 

 

 

In the core project, Zong! contains a score model, which is quite similar to that of MusicXML, but with some differences. For example, instead of using MusicXML's backup element, measures in Zong! consist of voices, which contain the actual musical elements like chords or rests. The Score class is the root of the tree of these classes.

The layout project extends the score model by pages and frames, stored in the Layout class. This model allows documents to contain multiple scores. Pages consist of frames, e.g. ScoreFrames for a score and TextFrames for text. For example, the score title in Zong! is not part of a score, but a TextFrame on top of a ScoreFrame. The ScoreDoc class contains the Layout and its Scores.

Using the musicxml-in project, a MusicXMLDocument class can be transformed to a ScoreDoc.

3. Create layout

 

 

 

 

The layout project provides the algorithms for layouting the musical classes from the core project. The musical data is converted to graphical data in this step. The result for the content of a ScoreFrame is a ScoreFrameLayout. It contains the Symbols and their positions, called Stampings in Zong!

4. Render layout

 

 

 

The layout data, which was computed in the last step, is now rendered to the actual device, which may be the screen of a desktop computer or mobile phone, a PDF file or a printed page for example. The renderer is as platform independent as possible, by using device independent StampingRenderer classes for the different types of symbols and the abstract Canvas class as the drawing target. The Canvas class contains methods for drawing staves, musical symbols, texts and more. These classes can be found in the renderer project.

Each specific platform defines its own Canvas implementation. For example, the Viewer and Editor use a JavaFX javafx.scene.canvas.Canvas, the Android Viewer is based on an android.graphics.Canvas and the HTML5/JS viewer uses a com.google.gwt.canvas.client.Canvas (which is a HTML5 canvas). These classes can be found in the platform specific projects.