6

Anyone know of any libraries that can be used to write MusicXML data from C#? Similar to this: http://proxymusic.kenai.com/ (although this one is for java).

I would try to not write it manually, but if worse comes to worst, I will have no choice but to output and write MusicXML manually from my results.

svick
  • 236,525
  • 50
  • 385
  • 514
user488792
  • 1,943
  • 7
  • 31
  • 38

3 Answers3

7

Since MusicXML has a XML schema available, you can use xsd.exe to create the classes that represent the XML structure:

xsd /c xlink.xsd musicxml.xsd container.xsd opus.xsd

Then you can use XmlSerializer to load and save the generated classes from/to files.

(For some reason, one of the schema files, osfpvg.xsd, wasn't able to compile correctly. Here's hoping you won't need it.)

svick
  • 236,525
  • 50
  • 385
  • 514
1

To use xsd.exe, you can use this command:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\xsd.exe" "c:\dev\musicxml30\musicxml.xsd" "c:\dev\musicxml30\xlink.xsd" "c:\dev\musicxml30\xml.xsd" /c /o:"c:\dev"

Which will create a file called musicxml_xlink_xml.cs in the c:\dev folder.

Compiled Class

Manchuwook
  • 341
  • 3
  • 15
1

For me when i tried to convert the MusicXml3.0.xsd, xsd.exe failed everytime. So, what i did was

xsd.exe musicFile.xml 

which generated a schema file, and

xsd.exe musicFile.xsd /classes

which produced the required c# classes. The only thing i had to add in order for the generated xml to be read by programs like Sibelius 7 was to add

<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">

And presto!

Aiden Strydom
  • 1,198
  • 2
  • 14
  • 43