musicjson
musicjson copied to clipboard
MusicXML to OpenSheetMusicDisplay
Hello!
I'm trying to use your splendid library to convert a MusicXML file to JSON and back to XML again. Building a music processing pipeline to convert piano music to banjo tabs. However, the XML that I'm getting from the music.musicXML() function doesn't seem to be in the same format as what I download from Musescore.
Here's some example code:
// import the MusicXML file
let musicXml = "/path/to/music/from/musescore.musicxml";
let editedMusicXml;
// display it in react; this works
<OpenSheetMusicDisplay file={musicXml} />
// convert to JSON
let musicJson;
music.musicJSON(result, function(err, json) {
musicJson = json;
});
// edit the JSON a bit
// convert back to XML
music.musicXML(musicJson, function(err, xml) {
editedMusicXml = xml;
});
// try to display the updated XML in react (BANG! No good)
<OpenSheetMusicDisplay file={editedMusicXml} />
I've tried a number of things like converting to a string, serializing to a string, etc. Do you have any pointers on what I might be doing wrong here?
Thanks for any ideas!