Skip to main content

ungrave: bringing engraved music back to life

Convert vector PDF scores to MusicXML without optical recognition, by reversing the engraving process.

PDFs exported from notation programs are vector files. Notes, clefs and accidentals are characters of an embedded music font placed at exact coordinates, and staff lines, stems, beams, ties and hairpins are vector paths. Music OCR tools (OMR) rasterize the vector file and then decode it using image recognition technology. ungrave reads those glyphs and paths directly from the PDF and rebuilds the notation from them. This is a much simpler task that runs quickly on any computer.

Supported source programs: Capella, Encore, Finale, MuseScore, and Sibelius. The PDF must come straight from the notation program (exported, or printed to a PDF printer): a scanned score has no glyphs to read.

Install

ungrave needs Python 3.10 or later. Install it as a command-line tool with pipx or uv:

pipx install ungrave
# or
uv tool install ungrave

Or, into the current Python environment, pip install ungrave.

To try it without installing anything, open the Colab notebook (needs a Google account; your PDF is uploaded to a temporary Google machine).

Use

ungrave score.pdf                    # writes score.mxl
ungrave score.pdf -o out.musicxml    # plain (uncompressed) MusicXML, or another name
ungrave score.pdf -p 1-2             # only pages 1 to 2
ungrave score.pdf --source finale    # don't guess the source program
ungrave score.pdf --proof            # also writes score.proof.pdf, to check the result
ungrave score.pdf --no-breaks        # let the notation program lay the score out anew

Open the resulting .mxl file (compressed MusicXML) in MuseScore, Sibelius, Finale, Dorico or any program that reads MusicXML.

The program that made the PDF is detected automatically; --source (-s) overrides it. With -p, the whole PDF is still read (for time signatures, part names and ties across pages), but only the requested pages are written.

ungrave never replaces a file it didn't write: if score.mxl already exists (for example the MusicXML exported with the PDF), it stops and asks for another name (-o), or --force.

The result keeps the PDF's line and page breaks, so that it opens looking like the original. --no-breaks leaves them out, for a new layout (other page size, larger staves, parts). Use it too when the result lays out badly: a notation program may need more room than the original's program for the same measures, and then splits systems and pushes pages.

--proof writes a PDF to check the result with: each page of the original, with the places that raised a warning marked in red, next to the same page rendered from the result, and the page's warnings listed below.

Warnings

Warnings are printed while converting. Read them: they are the converter's self-checks, and point to the places worth checking in the result.

  • mN: duration X != Y: the notes in measure N don't add up to the time signature. This usually means a misread rhythm or an unknown symbol. It can also be in the source itself: Encore allows overfull measures, and some scores end with a shortened last measure.
  • A/B mN: notes at xX start at T1 and T2: notes printed one above the other in two staves don't start at the same time in the result. A rhythm was misread in one of them, even though both measures add up.
  • unmatched arc: a curve that could not be matched to notes as a tie or slur.
  • unknown glyph U+XXXX: a music symbol the converter does not know, which is ignored.
  • lyric 'x' placed Npt from its note: a syllable printed far from any note; check its placement.
  • N staves instead of M ...: a system with hidden staves whose parts could not be identified.

What is converted

  • Staves, systems and barlines (single, double, final); any number of staves per system
  • Part names and abbreviations from the staff labels. Systems that hide empty staves are matched to the parts by their labels, or else by clef and pitch range
  • Staff groups: brackets and square brackets become part groups; braced staves (piano) become one part with several staves
  • Clefs (treble, treble-8, bass, bass-8, C clefs), key signatures (including changes after a barline), time signatures (numbers, common and cut time, additive numerators such as 2+3+2/8)
  • Notes and chords, accidentals (double ones too), dots, rests (whole-measure rests too); rhythm from beams, flags and tuplet numbers; beaming is written as printed
  • Several voices on a staff (Finale layers, Sibelius and Capella voices), including voices that enter or leave mid-measure
  • Ties (per note within chords, across system breaks, between voices) and slurs
  • Lyrics with hyphenation and several verses
  • Dynamics, hairpins, articulations (accent, staccato, staccatissimo, tenuto, marcato), fermatas, breath marks, with their placement above or below the staff
  • Text expressions, dashed text lines ("rit. - - -"), rehearsal marks, metronome marks
  • Title, subtitle, composer, lyricist and arranger from the page-1 header
  • Repeat barlines and first/second endings (voltas)
  • Early-music editions: unmetered measures (senza misura), breves, incipits (left out)
  • Page size, margins, staff size, line and page breaks, and staves hidden in some systems, so that the result opens with a layout close to the PDF

Current limits

  • Not handled: segno and coda, D.C./D.S., clef changes inside a staff, grace and cue notes, ottava lines, chord symbols, multi-measure rests, lyric extender lines.
  • Slurs from one staff to another are dropped (with a warning). A dashed text line continued across a system break becomes two lines.
  • Tempo values that aren't printed (playback tempo) can't be recovered.
  • Each source program has been tested on one or two scores. Symbols and layouts those scores don't use may be misread: watch the warnings.
  • Encore: one voice per staff; slurs are not written. Its tolerances scale with the staff size but were fitted to one score.
  • MuseScore: one voice per staff, and braces don't make braced (piano) parts yet. MuseScore 3 PDFs are untested.
  • Finale: two stemless notes in two voices at one place come out as a chord; a third layer becomes voice 1 or 2.

Contributing

Bug reports with a sample PDF help most. To work on the code, run the tests or add support for another notation program, see CONTRIBUTING.md.

License

ungrave is free software, released under the GNU General Public License, version 3 or (at your option) any later version. See LICENSE.

Metadata

Release files for ungrave 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ungrave 0.1.0
File Size Uploaded Provenance Actions
ungrave-0.1.0.tar.gz 86.4 kB Without provenance Details for ungrave-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ungrave 0.1.0
File Interpreter ABI Platform Actions
ungrave-0.1.0-py3-none-any.whl Python 3 none any Details for ungrave-0.1.0-py3-none-any.whl

Total release size: 170.4 kB

Release files / ungrave-0.1.0.tar.gz

Download URL ungrave-0.1.0.tar.gz
Size 86.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7029f720ba9c583c5ec0a50abc8266f1494ae6ebd70157b93d96274bc04cf0d9
BLAKE2b-256 checksum
How to use checksums
80476ac4b65b52e4ef96f31a1072855cc9153c2f2d9a76f5b83aea0ef2db46b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ungrave-0.1.0-py3-none-any.whl

Download URL ungrave-0.1.0-py3-none-any.whl
Size 84.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cbcc01fa60ffde2c41838608d77b32e3d52d638de1679c9af5ce91daf78c0cc
BLAKE2b-256 checksum
How to use checksums
80eda84d624b597dc255b77ef3e7d7809d483e3a9503d5928c085debac3c8a79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ungrave 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page