MusicXML files can be dragged/dropped onto the VHV page to automatically convert them into Humdrum data.

Drag-and-drop MusicXML files

The VHV interface can load MusicXML files by dragging and dropping them from the desktop onto the VHV page. The following figure shows MusicXML data being exported from MuseScore to the desktop, and then dragging the file onto the browser to load the file in VHV.

There are two ways of loading a MusicXML file: regular drag-and-drop will load the MusicXML data directly into the text editor, while holding down the shift key while drag-and-dropping will convert the MusicXML data into Humdrum data, which is then displayed in the text editor:

MusicXML import example
MusicXML file exported from MuseScore, then imported by shift+drag/dropping a file into VHV.

Try downloading the same MusicXML file and loading it into VHV in a similar manner (usually save by right clicking on the link and then choose save link as).

Copy/Paste MusicXML data

MusicXML data can also be copy/pasted into the VHV text editor. In this case VHV behaves like a MusicXML editor, since the data is not converted into the Humdrum format within the text editor.

The freeze command (alt-f) is useful for pausing dynamic notation rendering while editing the MusicXML data. MusicXML data loaded in this manner is converted to Humdrum behind the scenes, but loading the Humdrum data into the text editor is not yet implemented. You can, however, convert to MEI data with the alt-m and display in the text editor.

Conversion of MusicXML data into Humdrum

If MusicXML data is displayed in the text editor, you can use the Edit menu option “Convert to Humdrum” to convert the MusicXML data into Humdrum data, which replaces the MusicXML data in the text editor.

Embedding tandem interpretations

The MusicXML-to-Humdrum converter inside of VHV will convert text expressions that start with an asterisk (*) into tandem interpretations in the Humdrum data. Attach the text expression to the note which should follow immediately after the tandem interpretation. Here is an example of embedding an *Xtuplet interpretation to disable display of tuplet numbers, and later *tuplet to turn them back on:

Adding tuplet interpretations in MuseScore
Adding text expressions to control tuplet number display style in MuseScore.

This MusicXML file dragged-and-dropped into VHV will produce the following Humdrum data that preserves the embedded tandem interpretations controlling tuplet number styling.

Hiding Humdrum markup text

If you do not want to show the Humdrum markup text on PDF output from a music editor, you can make the text invisible in most editors. Here is an example of how to make the text invisible in MuseScore: click on the text and open the inspector panel and then uncheck the Visibility checkbox:

Making text invisible inMuseScore
Making text expressions invisivle in MuseScore.

Here is the resulting PDF output from MuseScore, where the Humdrum markup is not visible:

Making text invisible inMuseScore
Making text expressions invisivle in MuseScore.

In MuseScore, you can also hide the invisible text in the editor by unselecting the menu item View→Show Invisible.

Another example

Here is another example that embeds note-coloring markers in MuseScore:

Adding tuplet interpretations in MuseScore for coloring notes
Adding text expressions to control note colors.

If you drag-and-drop this MusicXML data, the conversion to Humdrum will look and display like this in VHV:

Adding interpretations after notes

When tandem interpretations are attached to notes or rests as text expressions, they will be inserted before the note in the converted Humdrum data. To place interpretations after a note, use two asterisks (**) instead of one. The second asterisk will be removed automatically (since this is reserved for exclusive interpretations). This method of inserting after notes is needed when adding interpretations at the end of a measure, since music editors typically cannot attach text expressions to barlines.

Here is an example of encoding a ligature bracket in MuseScore. The ending note of the ligature occurs at the end of the measure, and since the text expression *Xlig cannot be attached to the barline, it is encoded as **Xlig on the last note of the ligature group:

Adding ligature interpretations in MuseScore
Adding text expressions in MuseScore to display a ligature bracket.

If you drag-and-drop this MusicXML data, the conversion to Humdrum will look and display like this in VHV:

Embedding local comments

Likewise, local comments (starting with !) can be embedded within the MusicXML data to be converted into Humdrum data when you drag-and-drop the file onto VHV.

Adding local comments in MuseScore
Adding embedded local comments in MuseScore.

If you drag-and-drop this MusicXML data, the conversion to Humdrum will look and display like this in VHV:

Notice that any MusicXML text expressions starting with ! will be converted to local comments in the Humdrum data. The comments can also be layout parameters, such as in the above example where !LO:N:vis=1 means that the quarter note has a visual whole-note duration. The !comment is a regular local comment that will not be printed in the score. Text to display in the score can either be a plain text expression that does not start with * or !, and otherwise text can be placed in a TX layout command to add specific parameters to the text rendering in VHV.

Embedding reference records

Reference records can be inserted a text comment starting with three !!! anywhere in the score. To insert reference records at the top of a Humdrum file, add them to the title area in a score editor:

Adding reference records in MuseScore
Adding embedded reference records in MuseScore.

Note that in this example embedding of reference records, the text is made invisible in the MuseScore editor by unchecking the Visible check box in the Inspector panel on the right. This allows embedding Humdrum markup (including tandem interpretation and local comments) in the score editor, but prevent them from being visible in the PDF printout of the notation from MuseScore.

If you drag-and-drop this MusicXML data, the conversion to Humdrum will look and display like this in VHV:

If the MusicXML score contains the composer’s name and title in the standard encoding for a MusicXML file, they will automatically be converted into !!!COM: and !!!OTL: reference records, but if explicit !!!COM: and !!!OTL: entries are added to the file header, they will override the inferred composer’s name and work title.

Also note in this example a demonstration of the header templating system is given:

!!!header-left: @{LYR}\n
!!!header-center: @{OTL}\n<i>@{OMV}</i>
!!!header-right: @{COM}\n@{CDT}

This allows for various reference records to be displayed at the top of the score in the left, right and middle of the header. The \n character sequence represents a line break. There is also a footer templating system, which is useful for printing to PDF from VHV (with the alt-shift-T keyboard shortcut).

Reference record placement

An additional system for embedding reference records in the MusicXML header allows for placement of the records at the start or end of the file. Replace !!! with @ to indicate that a reference record should be placed at the top of the file, while replacing !!! with @@ will cause the reference record to be added at the bottom of the file:

Adding reference records in MuseScore
Alternate system for embedding reference records in MuseScore with above/below controls.

If you drag-and-drop this MusicXML data, the conversion to Humdrum will look and display like this in VHV:

Batch conversion from MusicXML to Humdrum

If you want to convert many MusicXML files into Humdrum at once, you can use the musicxml2hum command-line tool from humlib, which is the same as the MusicXML-to-Humdrum converter built into VHV. To convert multiple MusicXML files in a directory to Humdrum using the bash shell:

for i in *.xml
do
	echo Converting $i
	musicxml2hum $i > $(basename $i .xml).krn
done