MusicXML Export

21 views
Skip to first unread message

Jan Němeček

unread,
Aug 1, 2025, 4:04:35 PMAug 1
to PMW_Music

Dear Philip,

Thank you very much for your excellent software!

I have published several editions on CPDL, and I can hardly imagine creating them with anything other than PMW. CPDL uses MusicXML as a standard, exchangeable music format, since many music typesetting programs support exporting to MXL. As I’m currently unable to provide MusicXML files myself, they resort to OCRing my PDF files to generate MXL, which is understandably not fully reliable.

I noticed that PMW has experimental support for MusicXML input, but likely not for MusicXML export. Would it be possible to implement export functionality? I’d be happy to assist with development if needed.

Thanks again,
Jan

Philip Hazel

unread,
Aug 2, 2025, 4:55:42 AMAug 2
to pmw_...@googlegroups.com
Jan,

I am glad to learn of another happy user of PMW. Thank you for your comment. 

I experimented with MusicXML input in order to learn about it, but it was a while ago and I've forgotten most of it! MusicXML's "culture" is a bit different to PMW's, and I eventually got to an example that was going to need a huge amount of work. (It was an XML part that used two staves, and it specified the end of a slur on the upper stave before it specified the start on the lower stave.)  There were other things to do, so I left the code as partial and experimental, waiting to see if anybody actually wanted it. Nobody has commented.

I hadn't thought at all about MusicXML output from PMW. Certainly something could be done for the most straightforward musical elements, but there are features of PMW that I don't think would translate. The drawing facility is the obvious one, but handling coupled staves could be another. However, there is plenty of music that doesn't need these features. The obvious interface is to add a new -xml option, similar to -midi, to generate an additional output (or it could be instead of the PDF or PostScript output).

I am just finishing off a small update that was requested for the MIDI output. When that is done I will take a closer look at the code and the MusicXML spedification and perhaps at least set up a framework.

Regards,
Philip


--
You received this message because you are subscribed to the Google Groups "PMW_Music" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmw_music+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pmw_music/c7b41d8c-a71c-43b0-9ca9-142ccc2d5d49n%40googlegroups.com.

Jan Němeček

unread,
Aug 3, 2025, 2:35:13 AMAug 3
to PMW_Music
Philip,

Thank you very much for your positive response.

I fully understand that implementing MusicXML in any form is a significant effort. Some time ago, I wrote a Python script for my own use that converts MusicXML to PMW. I needed to perform a score that was only available in MusicXML, and I wanted to make some modifications—such as changing the instrumentation and exporting the parts. The script is not comprehensive, so I haven’t published it. However, the score itself was quite complex, which gave me some insight into the different approaches used in MusicXML and PMW, as well as the overall complexity involved.

Of course, PMW is generally much more powerful than MusicXML, and I don’t expect the drawing feature to be translatable. But that’s not something I need.

If you could establish a foundation for this functionality, that would be fantastic. I could then test it with my scores and possibly submit pull requests for further enhancements, if you’re interested. I wouldn’t attempt to implement something like this in PMW myself, as I’m unfamiliar with the codebase and my background is in Python and JavaScript. However, if a framework is already in place, I believe I could contribute.

Regards,

Jan

Philip Hazel

unread,
Aug 3, 2025, 3:17:21 AMAug 3
to pmw_...@googlegroups.com
I have started creating a framework and maybe by the end of today (or maybe not, other things are happening) I will have got it to the state of writing an empty shell of an XML file, at which point I'll push the branch (called xmlout) to GitHub. Then gradually work through the various items that PMW supports and add them. Having somebody else testing and commenting as this proceeds will be very useful! It won't be very fast, as I have other things to occupy my time (not computer related).
I also have a PMW user who is typesetting a fairly large piece in right-to-left mode (Arabic words) and who is discovering all the little details that I have overlooked, so I have to sort them out from time to time (take a look at doc/ChangeLog).

I'm impressed by your Python script. Before I added XML input support to PMW I wrote a C program to do the same, but I never finished it because I decided that it was better to convert directly into PMW's internal structures.

Regards,
Philip


Neil Killeen

unread,
Aug 3, 2025, 3:23:03 AMAug 3
to pmw_...@googlegroups.com, pmw_...@googlegroups.com
And by the way Jan, Philip recently wrote some generic notes describing some of PMW’s design and implementation, to help with others who may be interested in contributing 😳😊

Cheers
Neil 

On 3 Aug 2025, at 17:17, Philip Hazel <philip...@gmail.com> wrote:



Jan Němeček

unread,
Aug 3, 2025, 3:40:57 AMAug 3
to PMW_Music
Thank you for the note, Neil. Are you referring to the doc/HACKNOTES file, or something else?

Cheers,

Jan

Neil Killeen

unread,
Aug 3, 2025, 4:13:45 AMAug 3
to pmw_...@googlegroups.com

Philip Hazel

unread,
Aug 4, 2025, 1:08:37 PMAug 4
to pmw_...@googlegroups.com
I have just pushed a new branch called "xmlout" to GitHub. This contains the basic framework for MusicXML output, with a similar interface to MIDI, that is, there is a new option -xml <filename>.  However, all you get at the moment is a musically empty file that lists the parts (staves) but I have not yet written the code to process the bars (measures) in each part. That comes next! Also, there is no processing of headings yet. But I thought I'd start making this available so that people can track what I'm doing. The bulk of the code is in a new source file called src/xmlout.c.

Regards,
Philip


Jan Němeček

unread,
Aug 5, 2025, 1:52:39 AMAug 5
to PMW_Music
Thank you very much, Philip. That was quick!  
I have pulled the new branch, reviewed your changes, compiled the project, and tested the new `-xml` option to check the MusicXML output it generates. I have also set up OpenSheetMusicDisplay to view the translated MusicXML. (It currently reports invalid MusicXML, but that's understandable given the limited implementation scope.)  
I am ready to begin testing and to be further involved in this activity.

Kind regards,  
Jan

Philip Hazel

unread,
Aug 5, 2025, 3:16:53 AMAug 5
to pmw_...@googlegroups.com
I hadn't heard of OpenSheetMusicDisplay - perhaps I should investigate. I have MuseScore installed on my Arch Linux box, and it just displays an empty page for my test (one bar) file. Do you get a specific error message?

Regards,
Philip


--
You received this message because you are subscribed to the Google Groups "PMW_Music" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmw_music+...@googlegroups.com.

Jan Němeček

unread,
Aug 5, 2025, 3:45:58 AMAug 5
to PMW_Music
Hi Philip,

I've tried MuseScore (as well as Rosegarden), but MuseScore refused to display the MXL files generated from my PDF scores on CPDL. Because of this, I switched to OpenSheetMusicDisplay.

https://github.com/opensheetmusicdisplay/opensheetmusicdisplay

OpenSheetMusicDisplay worked well for my scores. It's primarily designed for web development (as a JavaScript library), and I appreciate how it simplifies the testing workflow. I could easily create a simple local web app that displays a specific MXL file in the browser and automatically reloads it whenever the file changes. This makes testing PMW MXL output much easier—after making changes and rebuilding, I just check the browser, with no manual steps required. In contrast, MuseScore requires me to use the menu and re-import the file each time (at least, that's my expectation).

I'm not at my home computer right now, so I don't have the error message with me. I'll send it this evening.

Regards,
Jan

Jan Němeček

unread,
Aug 6, 2025, 12:36:06 PMAug 6
to PMW_Music
I apologize for the delayed response, Philip. The error reported by the library is "Invalid number of staves." On my GitHub, I have created a temporary, basic app to help test the PMW MusicXML output. Please refer to the README:

https://github.com/janneme/osmd-viewer/blob/main/README.md

The app includes preconfigured links to several of my scores, arranged from simpler to more complex examples. As you’ll see, the OCR-generated MusicXML files are far from perfect. However, in some cases, the rendering library may also be a limiting factor.

Regards,
Jan

Philip Hazel

unread,
Aug 6, 2025, 1:18:04 PMAug 6
to pmw_...@googlegroups.com
No problem (about the delay).  Thanks for the testing app; I will look at it sometime. Meanwhile, I have got basic clefs, keys, and time signatures implemented, but I want to do some more testing before I commit. It may not be till Friday now, as I am busy for most of tomorrow. Next, I will look at notes. For my testing so far I have used musescore and, of course, PMW's own XML input facility (which gives better error messages than musescore :-)

Regards,
Philip


Philip Hazel

unread,
Aug 8, 2025, 11:25:13 AMAug 8
to pmw_...@googlegroups.com
I have just pushed the latest patch. The code should now support clefs, keys, and time signatures, though no doubt there are bugs and omissions. It also outputs comments about everything it is ignoring. This is partly to remind me of what needs doing, but also the code itself is littered with TODO comments. Next I am going to work on supporting notes and rests.

While testing I have discovered a couple of things missing in PMW's MusicXML input support, so I've now got a TODO list for that. I have also identified a few potential options for XML output. I'll publish this when I get further along. I have also discovered that MuseScore does not support the concept of "no clef" (unless I'm doing something wrong). There's a current and a deprecated way of doing this in MusicXML 4.0, but neither seems to work. 

Regards,
Philip

Philip Hazel

unread,
Aug 13, 2025, 11:39:03 AMAug 13
to pmw_...@googlegroups.com
If you have been watching my commits, you will see that I am making slow progress. It is slow because PMW and MusicXML have different ways of coding things; I've had to make a couple of additions to "base" PMW to help with the translation. It is also slow because PMW code is 30 years old and I have forgotten how a lot of it works; therefore I have to study the code to figure things out. Finally, it is slow because I'm doing this part time. :-)  I'm concentrating on getting the main items done. There will then be a lot of options and adjustments that will have to be discovered and handled. And then a lot of documentation!
There will always be PMW things that can't be translated, and similarly there will always be MusicXML things that aren't supported.

However, this has already been a useful exercise for PMW, independent of whether MusicXML output support ever reaches production standard. I discovered, and removed, an old variable that was no longer doing anything useful, and I also discovered that PMW does not support nested tuplets. Nobody has ever complained, but it ought to do that, so I have put that on a work list. 

Regards,
Philip

Jan Němeček

unread,
Aug 13, 2025, 3:54:16 PMAug 13
to PMW_Music
Hi Philip,

Thank you very much for all your hard work. I have been quite busy over the past few days, so I haven’t had the chance to follow your progress as closely as I would have liked. I have now pulled your latest changes and briefly reviewed them. There is clearly a substantial amount of code, and I fully appreciate that this is a challenging task given the different philosophies of PMW and MusicXML. Your progress is truly impressive.

I have tested the latest version by translating some of my scores, and they are already displaying in the OSMD-based viewer I shared with you. The output looks very promising.

Please don’t feel any pressure regarding my feature request—it is not urgent at all, and your development pace is more than sufficient.

Kind regards,
Jan

Philip Hazel

unread,
Aug 22, 2025, 11:36:19 AMAug 22
to pmw_...@googlegroups.com
Hi Jan,

I have a problem that perhaps you can help me with. I have basic slurs working in MusicXML export and I was adding support for modifications, such as moving the end points or changing the curvature. However, adding attributes to the <slur> element like relative-x or bezier-x has no effect when the xml file is loaded into either MuseScore or the OSMD demo page. I tried editing the slur in MuseScore, and it correctly saved and reloaded it in its own format, but when I exported it as MusicXML there were no adjustments included in the <slur> element. I am therefore stuck on this issue. I am going to leave it for now and move on to looking at accents and ornaments.

Regards,
Philip

Jan Němeček

unread,
Aug 23, 2025, 2:51:49 AMAug 23
to PMW_Music
Hi Philip,

Thank you very much for all your effort. I have experimented with this extensively but haven’t found a solution. I have submitted an issue to the OSMD project:

https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/issues/1623

Let’s see what they say.

Regards,  
Jan

Philip Hazel

unread,
Aug 27, 2025, 9:54:14 AMAug 27
to pmw_...@googlegroups.com
I have just pushed a commit that has basic support for ornaments (trills, turns, etc.) and while testing this I have discovered that different MusicXML renderers behave in different ways, and support or do not support different features of MusicXML. I have access to MuseScore running on Linux, the OSMD online demo, and SeeScoreMac, a Mackintosh app. For example, if there's an accidental above a trill, MuseScore ignores it, but the other two display it, whereas for tremolo bars on a note, OSMD outputs nothing but the other two show them correctly. None of them seem to support brackets round an accidental, or an accidental above or below a note, or certain positioning settings.

It is of course possible that I am getting things wrong, but when two out of three do what I expect, I think I am probably generating the "right" XML.

I will carry on adding support for PMW features and try to keep a list of who supports what.  

Regards,
Philip


--
You received this message because you are subscribed to the Google Groups "PMW_Music" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmw_music+...@googlegroups.com.

Philip Hazel

unread,
Sep 17, 2025, 10:25:20 AMSep 17
to PMW_Music
Please note that the latest patch that I have just pushed has moved XML output support to be conditional, under the same "configure" option as XML input. I am assuming that the use of MusicXML is something only a few will be interested in, so there is no point in compiling unwanted code. Also, I have realized that conversions between PMW and MusicXML are always going to be approximations because there is so much mismatch between the ways they represent music. As noted above, I've realized that MusicXML renderers do not support everything. I have a friend who knows about this and when I remarked that relative-x wasn't been handled he said "Oh, nobody bothers with relative-x". Sigh.

Philip

Philip Hazel

unread,
Sep 28, 2025, 5:52:12 AM (9 days ago) Sep 28
to PMW_Music
MusicXML export has now got to the stage of being almost useful for pieces that are not too complicated. I want to take a break from working on it, in order to deal with a number of unrelated issues that have come up and then perhaps put out a new release. I have therefore merged the xmlout branch into main because I don't fancy having to deal with merging two diverging branches later. I will in due course delete the xmlout branch; please update any testing you are doing to use the main branch from now on.

Feedback on MusicXML output (and indeed input) is welcome. All XML support is still very much "experimental", which means "it might work for you but please tell me about any problems". 

Philip

Jan Němeček

unread,
Sep 29, 2025, 3:19:37 AM (8 days ago) Sep 29
to PMW_Music
Hi Philip,

Thank you very much for all your immense effort. I have seen your commits and I know how much code it is.

I fully understand your need to take a break from this activity. I am sorry that I was very little involved. With the beginning of the new school year, I started to have a lot of musical duties—editing music, rehearsing, etc.—and I had very little time for this. I was also disappointed with opensheetmusicdisplay; I thought it was an active project, but for my issue logged on August 23rd, there is still no response.

I have tested the latest code in the main branch a bit, and the most serious problems I have noticed include:

- With some scores, the translation to MusicXML fails with code 139.
- [newmovement] seems not to be supported, so it only translates the first movement.
- Figured bass (which is a fundamental part of my scores) is not supported.

But this is by no means urgent, just some test feedback.

Thank you.

Jan

Philip Hazel

unread,
Sep 29, 2025, 11:46:35 AM (7 days ago) Sep 29
to pmw_...@googlegroups.com
Jan,

Thank you for your feedback, just the kind of information I need. Could you perhaps send me (philip...@gmail.com) the score that causes the 139 error, and is this PMW's error 139? [newmovement] is not supported because MusicXML allows for only one movement per file. I think one is supposed to use the <work> and <opus> elements to tie together a number of movement files. In PMW, you can select which movement is output as XML with -xmlmovement (synonym -xm).  

Figured bass is complicated, which is why I had left it until I knew somebody actually anted it!  In PMW, figured bass is just text, but in MusicXML there are specific elements for it. This means that I will have to try to interpret figured bass text strings and match them to MusicXML values. An "interesting" challenge!  Actually, something similar could be done for ordinary text, because MusicXML has individual elements for dynamics such as f, p, mf, etc. I was thinking of perhaps having an option for interpreting text strings. I suppose there could be an option for figured bass too, though not interpreting it would only work for simple numbers that are in ordinary fonts. Anyway, once I get back to MusicXML I will take a look at all of this.

Now that I know you are looking at the main branch, I will get rid of the xmlout branch.

Regards,
Philip

Reply all
Reply to author
Forward
0 new messages