Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MusicXML plugin

This plugin lets OxiGuitar swap scores with other notation programs. With it, OxiGuitar opens what MuseScore, Finale, Sibelius, Dorico or Guitar Pro export as MusicXML, and saves scores those programs can open.

It reads and writes .musicxml and .xml files, and compressed .mxl files. It only handles files. It makes no sound.

What MusicXML is

Every notation program saves in its own format, and none of them reads all the others. MusicXML is the common language they agreed on for moving a score from one to another. It was created by Michael Good at Recordare around 2004, is now looked after by the W3C’s Music Notation Community Group, and almost every notation program can import and export it.

As the name says, it is XML: a text format of nested tags, readable (just about) by people and easy for programs to check. A note looks something like this:

<note>
  <pitch><step>E</step><octave>4</octave></pitch>
  <duration>2</duration>
  <type>quarter</type>
  <notations><technical><string>1</string><fret>0</fret></technical></notations>
</note>

Because it spells everything out, a MusicXML file is big; a .mxl file is the same thing packed in a ZIP archive, a fraction of the size.

What survives the trip

MusicXML is a general-purpose format. It is excellent at standard notation: pitches, rhythms, voices, key and time signatures, dynamics, lyrics, repeats. Guitar-specific details are another matter: string and fret numbers, bends and slides are in the standard, but programs write them in different ways, and some things (a whammy bar, for instance) have no place at all. So:

  • Guitar and bass parts with tablature open as tablature. When a file has only the notes, OxiGuitar works out a fingering as it opens.
  • When saving, each guitar is written as a notation staff and a tablature staff, so the frets survive in programs that read tablature.
  • Before saving, OxiGuitar tells you if anything in your score can’t be written to MusicXML.

To keep everything, save in a Guitar Pro format; use MusicXML to share with notation programs.

How to use it

Check it is installed

Tools → Plugins… lists every plugin OxiGuitar found, with its version, and lets you switch any of them off:

Open and save

  • Open: File → Open… and pick a .musicxml, .xml or .mxl file, or double-click one if your system links the file type to OxiGuitar. OxiGuitar looks inside the file to decide which plugin reads it; the extension doesn’t matter.
  • Save: File → Save As… and pick MusicXML as the format. If the format can’t hold everything in your score, OxiGuitar says what would be lost before it saves, and you can keep the rest in the .oxg file beside it.
  • The import log: anything the MusicXML plugin couldn’t bring across is listed in the footer at the bottom of the window when the file opens.

What you can do with it

  • Bring a score from another notation program into OxiGuitar. Guitar and bass parts open as tablature. When the file has only notes, OxiGuitar works out a fingering as it opens.
  • Send a score back out. Each guitar is written as a notation staff and a tablature staff, so the frets survive in programs that read tablature.
  • Open the drums of a score as drums.
  • Move a score through MusicXML as a neutral stop between OxiGuitar and a program with no direct support.

Other pitched parts, such as a melody or a piano, are fingered too but show notation only until you turn their tablature on in the Track tab. When MusicXML can’t hold something, such as a whammy bar, OxiGuitar tells you before it saves.

Architecture and strategy

The plugin is one file with a reader and a writer on top of the musicxml Rust library. We wrote the parts around it: compressed archives, text encodings, and the decision about which parts are guitars, basses, drums or something else.

The strategy is to use the library as published and handle its gaps in our own code, instead of forking it. The file type is decided from the first element of the XML, never from the extension. The repository has a test file of our own, tests for damaged files and edge cases, and fuzzing for the reader and the writer.

docs/design.md in the repository says what is read and written, what is left out, and why.

Current limitations

  • Left out when reading, and named in the import log: cue notes, keys that aren’t on the circle of fifths, two-note tremolos, trills, articulations other than accents and staccato, and voices past the fourth.
  • No layout. System and page breaks, positions and spacing aren’t read or written: OxiGuitar lays out the score its own way.
  • One score per .mxl. Archives holding several scores aren’t supported yet.
  • No microtones.
  • Some guitar marks Guitar Pro writes as text, such as palm mute and let ring as words, or vibrato as a wavy line, aren’t read as marks yet.

Left out on purpose

  • A parser of our own. The musicxml Rust library reads and writes the format; we use it as published and handle its gaps (ZIP oddities, text encodings, older DOCTYPEs) in our code, not in a fork.
  • Guessing from the extension. The file type comes from the XML’s first element. A .xml file that isn’t MusicXML is left to other plugins.
  • Writing everything into MusicXML. Things MusicXML can’t hold are named before saving, rather than squeezed into text that other programs would misread.

Where you can help

  • Text marks to real marks: palm mute, let ring and vibrato as Guitar Pro writes them (src/, docs/design.md).
  • Layout: system and page breaks both ways.
  • Files from Finale, Sibelius and Dorico to test with, especially with tablature. Never attach files you aren’t allowed to share.

Every change needs its tests and a row on the Features page; the Testing page says how to run them.

Requirements and assumptions

Requirements

  • OxiGuitar 0.25 or later (the plugin asks for interface 3.0). See the OxiGuitar manual.
  • Windows, macOS or Linux.
  • To hear a score you also need a plugin that plays scores and an audio output plugin.

Assumptions

  • The file is MusicXML, plain or compressed.
  • A part marked as guitar or bass in the file is one. A part with no such mark is treated as an ordinary pitched part.
  • When a file has no tablature, a computed fingering is acceptable. It may differ from what you would choose.

Installing

You need OxiGuitar first: its manual says how to get it. This page is about the MusicXML plugin.

From a release

Each release on the releases page has a zip for each system (Linux, Windows and macOS; Linux and Windows for x86_64 and ARM64), a .deb, an .rpm and a Flatpak for Linux, a setup program for Windows that installs for you alone (no administrator password), a .pkg for macOS that does the same, and a SHA256SUMS file to check the downloads against. Take the file that matches your system.

Copying the file yourself

A plugin is a single file ending in .oxp. Unzip the release for your system and put musicxml.oxp in your plugins folder:

SystemYour plugins folder
Linux~/.local/share/oxiguitar/plugins/
macOS~/Library/Application Support/OxiGuitar/plugins/
Windows%APPDATA%\OxiGuitar\plugins\

Start OxiGuitar again. Tools → Plugins… lists what it found. The same menu switches a plugin off, and deleting the file removes it.

On macOS, a plugin file you downloaded yourself may be refused as coming from an unverified developer. Clear the download mark and start OxiGuitar again:

xattr -d com.apple.quarantine ~/Library/Application\ Support/OxiGuitar/plugins/*.oxp

A plugin installed with the .pkg is not marked this way.

Linux package managers

The package is called oxiguitar-musicxml. It lives in a signed package repository on GitHub Pages that you add once.

Debian, Ubuntu and relatives:

sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.gpg -o /etc/apt/keyrings/oxiguitar.gpg
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.sources -o /etc/apt/sources.list.d/oxiguitar.sources
sudo apt update
sudo apt install oxiguitar-musicxml

Fedora and relatives:

sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.repo -o /etc/yum.repos.d/oxiguitar.repo
sudo dnf install oxiguitar-musicxml

Normal system updates keep the plugin current from then on.

OxiGuitar’s Flatpak is a sandbox that cannot see the system’s plugin folders, so it needs the plugin as a Flatpak extension. Flathub comes first because Flatpak takes its runtime from there:

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists oxiguitar https://mateusrdp.github.io/oxiguitar-packages/flatpak/oxiguitar.flatpakrepo
flatpak install oxiguitar io.github.mateusrdp.OxiGuitar.Plugin.musicxml

flatpak update keeps it current and flatpak remove takes it away.

Features and their tests

Everything the MusicXML plugin does, and the tests that check it. The test names are the ones cargo test prints; a stage: is a step of scripts/test-all.py. The script fails when a feature here names no test, or names a test that doesn’t exist, so a new feature gets its row and its tests in the same pull request (the Testing page says how to run them, on your own files too).

FeatureWhat it doesTests
Recognises MusicXML by its contentsPlain files by their root (score-partwise, score-timewise), compressed .mxl by the root file their container names; nothing else.contract::its_signatures_recognise_musicxml_only, corpus::musicxml_is_recognised_by_its_contents, mxl::tests::the_container_names_the_score
Reads the header, parts and barsTitles, creators, rights; parts as tracks; time and key signatures, repeats, endings, rehearsal marks, tempo; exact durations from divisions, gaps filled.read_write::reads_the_header_parts_and_bars, time::tests::exact_durations, time::tests::fills_lengths, read_write::timewise_files_read_as_partwise_ones
Jumps and signsSegno, coda, Fine, To Coda, D.C. and D.S. with their “al Fine” and “al Coda”.read_write::reads_jumps_and_signs
Guitars open as tablatureA guitar takes its strings and frets from its tablature staff; other pitched parts get a guitar’s strings, drums none; the instrument from its sound, program or name.read_write::a_guitar_takes_its_strings_and_frets_from_its_tablature, read_write::other_parts_get_a_guitars_strings_drums_none, instruments::tests::kinds_from_clues
Text as files carry itEncodings and entities both ways; texts with markup characters survive.text::tests::decodes_what_files_come_in, text::tests::entities_both_ways, read_write::texts_with_markup_characters_survive
Writes MusicXML, plain and compressedEach guitar as a notation staff and a tablature staff; what it writes reads back the same; an empty score too.read_write::writes_what_it_reads, read_write::writes_an_empty_score_and_reads_it_back, mxl::tests::an_archive_round_trips
Names what it can’t writeEach kind of loss once, counted, with its first place, before anything is written.read_write::names_what_it_cant_write, log::tests::one_entry_per_kind_counted
Damaged filesErrors, never panics.read_write::damaged_files_are_errors_never_panics
Your MusicXML filesEvery MusicXML file of the corpus reads, writes (plain and compressed) and reads back the same, or stable from the second trip when losses were named.corpus::every_corpus_musicxml_file_round_trips
Through the newest OxiGuitarEvery corpus file OxiGuitar opens (MusicXML by this plugin, Guitar Pro by the released Guitar Pro plugins) is written as .musicxml and .mxl and read back by this plugin, a second round trip changing nothing.stage:corpus through the core
A working plugin fileThe .oxp file keeps the plugin contract, with this repository’s SDK version and with the newest release of OxiGuitar.contract::the_plugin_file_keeps_the_contract, oxiguitar_plugin_checks::the_manifest_matches_the_plugin, stage:contract (latest core)

Testing

Every test of this repository runs with one command, on your own machine, and anyone can run it. When something fails, it tells you how to report it.

Run everything

python3 scripts/test-all.py --corpus /path/to/your/files

On Windows, type python instead of python3 if that’s what you have.

You need:

  • Rust, from rustup (the version in Cargo.toml’s rust-version or newer);
  • git, and Python 3.8 or newer (nothing to install with pip);
  • on Linux, the libraries a build needs: libasound2-dev, libpipewire-0.3-dev and libclang-dev on Debian and Ubuntu (alsa-lib-devel, pipewire-devel and clang-devel on Fedora);

It runs:

  1. every Rust test of the repository (cargo test over the whole workspace), with a progress bar;
  2. the plugin against the newest release of OxiGuitar: it fetches that release’s source with git (once per release, kept in a cache folder every OxiGuitar repository on your machine shares: ~/.cache/oxiguitar-test-all, ~/Library/Caches/oxiguitar-test-all on macOS, %LOCALAPPDATA%\oxiguitar-test-all on Windows, or OXIGUITAR_TEST_CACHE), builds its oxiguitar-cli and oxiguitar-plugin-test, builds this repository’s plugin file for your system and runs the plugin contract on it;
  3. every corpus file the plugin recognises, through that release’s oxiguitar-cli: recognised, read, written as .musicxml and .mxl and read back, a second round trip changing nothing;
  4. a check of the Features page: every feature names a test, and every test it names exists.

It tests the system and processor it runs on, and only those (as Rust sees them: rustc -vV’s host). Tests for other systems are left out and the summary says so; they are not failures.

Your corpus

The corpus is any folder of files you have (searched recursively, hidden files left out): give it with --corpus DIR, or set OXIGUITAR_CORPUS=DIR. Each corpus test takes the files it understands and skips the rest, and only checks what must hold for every file (it opens, nothing panics, a round trip is stable), so your corpus doesn’t have to be ours to pass. Files are never uploaded, and never belong in the repository.

cargo test on its own uses OXIGUITAR_CORPUS too, or the repository’s ignored corpus/files/ folder, and quietly checks nothing when neither is there (that’s how CI runs). --no-corpus runs the script without one.

What you get

A line per stage while it runs, then the result. In target/test-all/<date>-<time>/:

  • summary.md: the result, your system, what failed and why, short enough to paste into a GitHub issue;
  • test-all.log: everything that happened, every command and its output, and your corpus’s file names, sizes and SHA-256 sums;
  • corpus-*.json: what each corpus test made of each file.

The script exits with 0 when everything passed, 1 when something failed, and 2 when it couldn’t start.

When something fails

  1. Update to the newest develop (git checkout develop && git pull) and run it again: it may be fixed already.
  2. Look for an issue about the same test at github.com/mateusrdp/oxiguitar-musicxml/issues.
  3. Otherwise open one: call it test-all: <the first failing test>, paste the whole summary.md, and attach test-all.log (drag it onto the text box; zip it first if it’s over 25 MB). Read the log first: it has your folder names and your corpus’s file names, so change anything you’d rather keep private.
  4. Don’t attach corpus files unless they’re yours to share. The summary lists each failing file’s SHA-256, which is often enough for us to find the same file. If a failing file is yours, attaching it helps a lot.
  5. You can also give summary.md and test-all.log to a language model along with this repository and ask it to find the cause.

Options

  • --release: an optimised test build: slower to build, faster corpus tests.
  • --ignore-rust-version: for a Rust older than rust-version (unsupported, but handy).
  • --core DIR: test against a checkout of OxiGuitar you already have, instead of its newest release; --core-version v0.21.5 picks a release.
  • --out DIR: where the results go.

Adding a feature

A new feature comes with its tests and a row on the Features page, in the same pull request; a new corpus test uses tests/support/corpus.rs. The script fails until the row names tests that exist.

Credits

Thank you to the people whose work this plugin is built on.

Code we use

ProjectAuthorsWhat it does hereLicence
OxiGuitar’s plugin SDK (oxiguitar-plugin, oxiguitar-model, and oxiguitar-plugin-test for the tests)Mateus Rocha de Paula and the OxiGuitar contributorsThe plugin interface and the score modelMIT OR Apache-2.0 for the interface and SDK; GPL-3.0-or-later for the model
musicxmlWill HedgecockReading and writing MusicXMLMIT
zipMathijs van de Nes, Marli Frost, Ryan Levick, Chris Hennick and contributorsCompressed .mxl archivesMIT
zlib-rsThe Trifecta Tech FoundationDeflate compression, in pure Rust, under zipZlib
serde_jsonDavid Tolnay, Erick Tryzelaar and contributorsTests onlyMIT OR Apache-2.0
Rust and its standard libraryThe Rust ProjectEverything elseMIT OR Apache-2.0

Standards

MusicXML, created by Michael Good and Recordare, maintained by the W3C Music Notation Community Group.

Tools

ToolUse
cargo-fuzz and libfuzzer-sysFuzzing the reader and the writer (fuzz/)
mdBookBuilds this manual
cargo-denyChecks the licences of everything we build with

Thanks

To Will Hedgecock for the musicxml library, and to Michael Good and the W3C community group for keeping a common language for notation alive.