Skip to content
OSMD
Language: English
Sponsor

Questions developers ask

Answered by the team that maintains OSMD. Written for OSMD 3.0 and checked against the released 3.0.0 on November 21, 2026; where 2.x behaves differently, the answer says so. Missing a question? Ask on Discord.

How fast does OSMD render?

Measured on November 21, 2026 with OSMD 3.0.0 from npm, in Google Chrome 158 (headless) on a MacBook Pro with an Apple M3 Pro (12 cores, 36 GB, macOS 27, on mains power). A4 portrait pages at 1000 px wide. Read is load() with the file already downloaded, render is render(). Five fresh browser sessions, each with two warm-up rounds and then ten measured rounds of every score: each cell is the median of those 50 runs in milliseconds, with the fastest and the slowest run in brackets.

Read and render times of four scores, OSMD 3.0.0, Chrome 158 on an Apple M3 Pro, measured November 21, 2026
ScoreMeasuresPagesRead, msRender, msTogether, ms
Clementi, Sonatina op. 36 No. 1, first movement3829 (7 to 13)19 (13 to 23)28 (21 to 33)
Schumann, Dichterliebe No. 127316 (13 to 20)24 (19 to 30)41 (33 to 47)
Joplin, The Entertainer92634 (30 to 43)38 (32 to 43)73 (65 to 83)
Lee Actor, Prelude to a Tragedy (orchestra, 22 parts)412477 (70 to 88)149 (139 to 193)226 (210 to 267)

The scores are test files from OSMD’s repository; the Actor prelude is the largest of them. The first score after the page opens takes longer, while Chrome compiles OSMD’s code: that is what the warm-up rounds leave out. OSMD 2.3.1, measured the same way, renders within a millisecond of these medians and takes 8 to 11 % longer to read. The timings hold for this laptop; the harness and every run are in this site’s repository, so you can measure on your own machine.

Phones are slower: two to three times as long in our earlier measurements. Since OSMD 2.0, the skylines that keep symbols from colliding are calculated geometrically instead of being read back from a canvas, which made rendering 1.8 times faster on average and up to 4 times, depending on the score.

For long scores, show something at once: renderNext() draws the next batch of measures and returns how far it got, enableIncrementalRenderingOnScroll() calls it while the user scrolls, and the options drawFromMeasureNumber and drawUpToMeasureNumber draw a range of measures only.

Why does OSMD draw with a patched VexFlow 1.2.93?

Because for OSMD the newer versions don’t draw better yet, and moving costs a lot.

VexFlow 4 and 5 bring a new formatter that spaces notes more widely. In our tests many scores look worse with it and take more room, which means more systems and more pages. VexFlow 5 also draws its symbols with a music font the page loads at runtime, Bravura or another SMuFL font. Any SMuFL font works, a real advantage, but the font has to be there before the first note is drawn. VexFlow 1.2.93 carries its symbols as outlines in its code (the Gonville font, which we still like best).

Then there are our patches. OSMD 3.0.0 changes 39 of VexFlow 1.2.93’s source files (src/VexFlowPatch, copied over VexFlow’s sources before OSMD is built), and a move means porting every one of those changes. A branch on VexFlow 4 shows how far that goes: pull request #1139.

So we stay on our patched 1.2.93 and fix what we find there. We’ll look again when a newer VexFlow gives OSMD a clear gain.

One number you may meet: many of VexFlow’s weekly npm downloads are version 1.2.93. That says little about which VexFlow people choose, because up to 2.3.1 every OSMD install pulled VexFlow 1.2.93 as a dependency. Since 3.0, VexFlow is inside OSMD’s build and no longer installed with it (pull request #2025).

What doesn’t OSMD do yet?

Almost all common MusicXML renders. What’s missing, as of November 21, 2026:

  • Some special percussion noteheads (issue #1588, also in the README’s limitations).
  • Pedal marks render, lines and signs alike, but the sostenuto pedal isn’t read yet, and the audio player in OSMD Extended doesn’t play pedals.

OSMD is a renderer, not an editor: you can hide, color or skip elements in code, but not move or add notes. Wavy lines, tremolos between two notes and slurs across staves arrived in OSMD 2.0. Found a score that renders wrong? Open an issue and attach the file.

Can I load files my users upload?

Yes, but treat them as untrusted. load() takes a URL, a string, a Document or a Blob (a File from an <input type="file"> is one), and its promise rejects with an Error when the file can’t be read: malformed XML (with the parser’s line and column), a file that isn’t MusicXML, a broken .mxl. A file that is valid XML but broken MusicXML can still get through load() and make render() throw. Catch both:

try {
  await osmd.load(file);
  osmd.render();
} catch (error) {
  showError(`We can't show this file: ${error.message}`);
}

OSMD’s guards against hostile files cover only two things: freezing the page (numbers with hundreds of digits in a <duration> or <divisions>) and running out of memory (a huge <staves>, <staff-lines> or <tremolo> value). Both arrived in 3.0 (pull request #2008, #2009); in 2.x some errors in load() were thrown instead of rejected (#1990).

How do I use OSMD in React, Vue or another single-page app?

Create one instance per container, and call osmd.destroy() when the component goes away. It aborts a load() that is still running, releases the score, removes OSMD’s listeners and its own elements, and leaves the rest of the container alone:

// React
useEffect(() => {
  const osmd = new OpenSheetMusicDisplay(containerRef.current);
  osmd.load(url).then(() => osmd.render()).catch((error) => {
    if (error.name !== "AbortError") { // destroy() aborted the load: not an error
      console.error(error);
    }
  });
  return () => osmd.destroy();
}, [url]);

In Vue, call osmd.destroy() in the cleanup of the effect that creates OSMD, as the Vue guide does: Vue runs that cleanup when the component unmounts too, so onUnmounted isn’t needed. After destroy(), the instance is done: create a new one to show a score again. With autoResize (on by default), OSMD 3.0 renders again only when the container’s width changes, not the window’s: a change in height alone doesn’t redraw the score. render() skips a hidden container.

destroy() is new in 3.0 (pull request #1992). In 2.x, call osmd.clear() and osmd.dispose(), then empty the container yourself.

Can I transpose a score?

Yes, in public OSMD. Set a transpose calculator, then the number of halftones, then render:

import { OpenSheetMusicDisplay, IntervalTransposeCalculator } from "opensheetmusicdisplay";

osmd.TransposeCalculator = new IntervalTransposeCalculator();
osmd.Sheet.Transpose = 3; // up a minor third
osmd.render();

IntervalTransposeCalculator moves every note by the same interval, like MuseScore’s “transpose chromatically”, so a note outside the key keeps its function. The default TransposeCalculator only counts halftones and spells each note by the new key signature: an A# in C major, transposed down a whole tone to B flat major, becomes Ab instead of G#. In 3.0 each OSMD instance has its own calculator; in 2.x one calculator was shared by every instance on the page (pull request #2002).

How do I zoom?

osmd.Zoom = 0.8; // 80 %
osmd.render();

Zoom with a capital Z, followed by render(): OSMD lays the score out again, so a smaller zoom fits more measures on a line. In 3.0 the zoom stays when you load another score; up to 2.3.1, load() set it back to 1.

Can I color notes for feedback, like red and green?

Yes. For instant changes, change a note’s SVG element directly: osmd.cursor.GNotesUnderCursor() gives the notes under the cursor, and each one’s getSVGGElement() its drawing. The wiki page Exploring the Demo shows how. To color the whole score, use the options coloringMode, defaultColorNotehead and colorStemsLikeNoteheads, then render. The cursor walks through the score note by note, so you always know which notes are current.

Lighting up keys on a virtual keyboard isn’t built in; it is a good first project, or a custom development job.

Can I sync OSMD with my own audio, video or MIDI?

Not out of the box, but OSMD gives you what you need. The cursor’s iterator knows where it stands in the score and at what tempo: osmd.cursor.Iterator.CurrentEnrolledTimestamp (in whole notes, with repeats played out) and CurrentBpm. Move the cursor with osmd.cursor.next() whenever your player’s clock passes the next note. stringsync synced audio and video this way with an older OSMD.

OSMD Extended, the sponsors’ build, has an audio player whose cursor follows the music. If you need audio and video sync built in, alphaTab has it: see how OSMD compares. Listening to a MIDI keyboard or a microphone and comparing what is played with the score is custom development.

A hosted player instead of a library?

Flat and Soundslice sell sheet music as a service. You embed their player in your page, your scores live on their platform, and you pay by the users who open it each month. You get playback and, with Soundslice, notation synced to video, without building any of it.

A library like OSMD runs inside your app, on your own files, offline if you like, and you can read and change every line of it. You build the player around it. Which fits depends on whether sheet music is a feature of your product or the product itself. The services and their prices are on how OSMD compares.

How much memory does the audio player need?

Sounds cost memory for every instrument in the score, so load them when the user presses Play, not when the page opens.

Can I replace the audio player’s sound engine?

In OSMD Extended, yes: implement the IAudioPlayer interface (playSound, stopSound, loadSoundFont and a few more) and pass it to the PlaybackManager’s constructor. The default player uses SoundFont samples.

Does OSMD handle repeats, D.C., D.S. and coda?

Yes. The layout draws them, and OSMD Extended’s audio player plays the repeats and jumps in order, with the cursor following.

Can I show the score as one endless line, or as pages?

One line: pass the option renderSingleHorizontalStaffline: true before you load the score. OSMD keeps a line at most 32,767 pixels wide (EngravingRules.SheetMaximumWidth, the Canvas size limit), so a very long score continues on a second line.

Pages: set the option pageFormat, for example "A4_P" or "Letter_L". OSMD stacks the pages vertically; to show two side by side, place their SVGs yourself.

Can I change a score after it is read, before it is drawn?

Yes: a module implementing IAfterSheetReadingModule gets the score after reading and before rendering. Most other changes go through the options (IOSMDOptions) and EngravingRules.

What changes when I upgrade from 2.x to 3.0?

3.0 is a major version because of API changes; it also brings 31 bug fixes, many of them in the layout. Most apps update without a change. What may need one:

  • 64 EngravingRules that had no effect are gone, for example BeamWidth and StemMinLength: remove the lines that set them (pull request #2015).
  • The transpose calculator, the symbol factory and the dynamics volume table belong to each instance instead of the whole page (#2002, #2006).
  • OSMD logs through its own logger, named “OSMD”: setLogLevel() no longer changes loglevel’s root logger or writes to localStorage (#2003).
  • OSMD no longer adds last(), contains() and clear() to Array.prototype (#2001).
  • Deprecated members are removed, among them the WebGL skyline options (#2005).
  • Installing OSMD no longer installs vexflow and loglevel, which are inside its build now: if your app imports one of them itself, add it to your own package.json (#2025).
  • A load() that another load(), clear() or dispose() replaces is rejected with an AbortError instead of resolving, so its .then(() => osmd.render()) doesn’t run (#1992).
  • Errors for an XML string or document reject the promise of load() instead of being thrown, with new messages (#1990).
  • load() and clear() keep osmd.Zoom instead of setting it back to 1 (#1999).
  • render() removes only OSMD’s own pages from the container, so your own elements in it stay; with autoResize, OSMD follows the container’s width, not only the window’s (#1992).
  • New: destroy() and the option onRender (#1992).

The release notes of 3.0.0 list every breaking change and the bug fixes.

Can I use OSMD in a commercial, closed-source app?

Yes. OSMD is BSD-3-Clause: use it anywhere, keep the license notice. OSMD Extended, the sponsors’ build, has its own terms, explained on the sponsor page.

MusicXML or MEI?

MusicXML is the format notation programs exchange: MuseScore, Finale, Sibelius and Dorico all export it. MEI (from the Music Encoding Initiative) is an XML format made for scholarly editions: it can record sources, variants and editorial decisions, which MusicXML has no elements for.

OSMD reads MusicXML and compressed .mxl. If your sources are MEI or Humdrum, Verovio is the better fit; it also reads MusicXML. See how OSMD compares.