Docs · OSMD 3.0
Transposition
OSMD transposes a loaded score by a number of semitones. It needs a transpose calculator first; without one, Transpose does nothing. Starting from a rendered score (see Getting started):
import { IntervalTransposeCalculator } from 'opensheetmusicdisplay';
osmd.TransposeCalculator = new IntervalTransposeCalculator();
osmd.Sheet.Transpose = 3; // semitones: C major becomes E flat major
osmd.render();
render() applies the change: there’s no need to load the score again or call updateGraphic(). Negative numbers go down.
IntervalTransposeCalculator (pull request 1770) transposes by interval, so the notes are spelled to fit the new key: an A sharp in C major becomes a G sharp in B flat major, not an A flat. The older TransposeCalculator is still there. Both are part of public OSMD, under its BSD-3 license.
One instrument
osmd.Sheet.Instruments[0].Transpose = -2; // this instrument only, on top of osmd.Sheet.Transpose
osmd.render();
An instrument’s Transpose comes on top of the score’s: after the 3 semitones up above and this 2 down, the first note of the scale, a C, is drawn as a D flat. Use it for one part of a larger score, for example a B flat clarinet written a whole tone above concert pitch (Transpose = 2).
Several scores on one page
In OSMD 3.0 each instance has its own calculator (pull request 2002). Up to 2.3.1 the calculator was shared by every OSMD on the page: setting one on a score set it on the others too.
Next: Rendering in Node.js