Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.53 KB

README.md

File metadata and controls

66 lines (46 loc) · 1.53 KB

mnxconverter

A Javascript/Typescript package for converting between MusicXML and the new MNX format. Works in Browser and Node.js.

Disclaimer

This converter is initially ported from Python Package https://github.com/w3c/mnxconverter and very limited in scope at the moment. So far, it only reliably converts the types of notations described in Comparing MNX and MusicXML.

Installation

First, make sure you have package installed:

npm install mnxconverter

or

yarn add mnxconverter

To convert a MusicXML file, outputting the MNX score object:

import { getScoreFromMusicXml, getMNXScore } from 'mnxconverter';
const score = getScoreFromMusicXml('<?xml your music xml goes here....>'); // get internal model
const mnxScore = getMNXScore(score); // encode model as mnx score object

// {
//   "global": {...},
//   "mnx": {...},
//   "parts": {...}
// }

Usage in Node.js

Install jsdom or any browser compatible DomParser

npm install jsdom

Set global variables

const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const { DOMParser, XPathResult } = new JSDOM().window;
global.DOMParser = DOMParser;
global.XPathResult = XPathResult;
// conversion code like above...

Credits

Highly inspired by converter developed by Adrian Holovaty

Links

MNX documentation. W3C Music Notation Community Group.