How to create figures for music scores
Standard Ebooks handles instances of music notation in books by recreating them in a modern score editor and embedding them as SVG files much as any other illustration. To explain the process, let us consider the example of Man and Superman, which has three instances of music notation.
-
Finding sources
In the original Project Gutenberg transcription, the music is simply referenced as (a staff of music is supplied here). You therefore have to go find the relevant music in the scans of the source.
This image is not clear enough that it is possible to simply follow the illustration tracing procedure, and even if it were could, the goal is not to duplicate the source as exactly as possible but instead to produce a clean, modern, legible version of it.
-
Recreating with a scorewriter
A number of modern scorewriters exist, including several free options. While any of these that can output MusicXML and SVG files can be made to work, MuseScore, a powerful, open source option, is the SE default. Tutorials for its use are available directly from MuseScore.
The score should be recreated as closely as possible while still being readable, but at this stage it does not need to be perfect as it can be further edited by an SVG editor. At this point, the priority is for it to be human-readable, not for the scorewriter to produce the best possible playback.
MuseScore cannot fully replicate the original, so final changes will be made in a vector editing program. Once you are ready to progress to the next step, export the music into two formats: MusicXML and SVG.
MusicXML files should be named
illustration-n.xml
and saved in./images/
. Ensure that they have a .xml filename. SVG files should be saved asillustration-n.svg
in./src/epub/images/
. -
Edit in a vector graphics editor
There are a number of vector graphics editors available and you are free to use whichever you are most familiar with to make visual changes to the score. Regardless of what you use to make visual edits, Inkscape and specific plugins available for it are recommended to clean up the SVG code.
At this stage, final visual changes are made. The final rests and bars at the end are cropped out, clef lines behind the instrument text have been removed, and elements have been slightly rearranged to reduce the amount of space the key and time signatures take up. The SVG is made black against a transparent background, and cropped so there is no blank space around the edges of the illustration.
-
Prepare the SVG file
As initially prepared by Inkscape or your vector graphics editor of choice, the SVG is unlikely to be in good shape. Any transformations need to be applied, all colour needs to be removed to allow for readers with an inverted color scheme, and the header needs to be corrected. For the complete SE guidance on SVG files, see section 10.2 of the manual.
Applying transformations
As generated by MuseScore, SVG files are likely to include transform elements throughout, which need to be removed. There are several ways to do this, but the the following two are recommended.
- Install the extension Inkscape Apply Transforms and use this.
- Use the command line tool SVGO (SVG Optimizer). An online version of the tool also exists, and can be a good starting point. The default settings are generally good except for the following: markup should be prettified, XML instructions should not be removed, viewBox should be preferred to width and height and not removed, paths should not be rounded or rewritten, and "title" and "description" should not be removed.
Correcting the header
The header of the SVG should include minimal basic information, and a title. In the case of named pieces of music, the title will be that name. In all other cases, it should be the short description that will be used as alt text in the final book.
-
Insert the music as a figure and add a List of Illustrations
Once the music is ready, it is inserted like any other image. For full guidance, see section 7.8 of the manual.
As this is an illustration, a List of Illustrations is needed. For full guidance, see section 7.9 of the manual.